SPECT reconstruction with scatter

Dear CASToR community,

I am appealing for some help getting CASToR to reconstruct some SPECT projection data with scatter correction.

I have attached the Matlab code we’re using to convert SPECT projection data from Interfile into CASToR .cdh/.cdf files. I also attach the result of this code when we feed it three interfiles (photopeak and upper/lower scatter windows). The code estimates the scatter component (in counts/sec) using the Triple Energy Window method.

When we run the resulting datafiles through castor-recon.exe, we get the attached error message. As there is a mismatch between the expected and actual sizes, I suspect the problem relates to the bit depth of the variables as I write them to the .cdf file, or a problem with the header and CASToR not recognising the fact that I’ve included normalisation factors. As we are using the pre-compiled binaries, we haven’t changed the default FLTNMDATA variable, so I am writing variables of this type as 32-bit floats.

I can’t spot any other issues with the conversion code, but I’m obviously missing something. I would appreciate any help anyone can offer. I have already had some very helpful email exchanges with Michael Ljungberg in Lund, who has already got this working. But rather than continue to hassle Michael, I thought I would give him a break and appeal to the wider community!

Kind regards,

James.

James Scuffham, MSc, PhD, MIPEM

image002.png

image004.png

sct.cdf (1.34 MB)

sct.cdh (1.32 KB)

CASTOR.m (5.81 KB)

Hello James,

Apparently something went wrong when generating the binary datafile, though I can’t tell exactly why from your matlab code.

This error occurs when the binary datafile doesn’t have the expected size. The size is computed from the number of event, and what mandatory/optional fields are in your data. From your header, the datafile should contain 1966080 events with normalization and scatter correction factors. Each event will be composed of (time(uint32) + event value (FLNTBDATA) + scat factor (FLTNBDATA) + norm factor (FLTNBDATA) + 2ID (2uint32). As you said, default FLNTBDATA is 32-bits floats, so this means the code will expect a datafile with a size equal to 1966080*(6*4bytes) = 47185920 bytes. (The error message erroneously states the expected size is 39321600 bytes because there is a small typo in your data header for the normalization field. It should be “Normalization correction flag” instead of “Normalisation correction flag”, unless it won’t enable normalization factors).

Now looking at your binary datafile with an hexa editor, it seems your conversion stopped after 58354 events (see attached file) for some reasons. Besides, each event has the correct number of fields, but it seems that all pixel data and scat factor are equals to 0.

Hope it helps !

Best regards,

Thibaut