Data mode on Castor

Hi everyone,

I have a question regarding how data is recorded in CASToR. From what I understand, data can be recorded in either list-mode or histogram format. I’m currently reconstructing results from a PET system simulation I performed in GATE. I created the geometry file using castor-GATEMacroGeom and converted the ROOT file to CASToR format with castor-GATERootToCastor. The resulting .cdh file identifies the data mode as list-mode.

My question is:

  • Is the data mode automatically determined based on my ROOT file, macro, and scanner, or do I need to manually define it?
  • What is the key difference between list-mode and histogram-based data recording?

Thank you in advance!

Hi,
With the GATE converter, data is stored in list-mode by default for PET. If histogram data is required, the -oh option must be used with castor-GATERootToCastor. The data organization is not specific to the scanner, both type of data can be used for any system.
The choice of histogram / list-mode really depends on your needs. Several reconstruction algorithms (optimizers in CASToR) requires the information of the number of data in each histogram bin, thus are only compatible with histogram data. List-mode potentially contains additional information for each coincidence (e.g timing information) and is more dedicated to dynamic reconstruction or gating, among other uses. For “standard” reconstruction purposes, both are equivalent even if the data is handled a bit differently.

Hope this helps,
Thibaut

Hi! Thank you for the explanation!

I am trying to reconstruct images resulted from a voxelised patient phantom simulation of a PET system, so what would you recommend me choosing for the data record and algorithm settings in CASToR?

I tried doing this with list-mode data format: castor-recon -df /home/vgate/Software/examples_vm/example/PETexample/castor_recons_df.Cdh -fout /home/vgate/Software/examples_vm/example/PETexample/castor_recons -it 6:15 -dim 128,128,132 -vox 2.34,2.34,3.125 -conv gaussian,7.,7.,5.::psf -th 0 -vb 2 -opti MLEM -proj incrementalSiddon

However, the resulting images were completely black. I suspect that some of the parameters I defined might not be optimal, but I’m still unsure about the best values to use. Is there perhaps some examples available?

Hi,
You could let it convert to list-mode as in default settings. Make sure to provide the umap at reconstruction time if your simulation involves attenuation.

What do you mean by ‘black images’ ? Are the voxel values in your image all equal to 0 ? Also did you check from the ROOT files that the simulated data was consistent with your simulation (number of coincidences, detected positions, acquisition time, etc…) ?

Hi,
I do have attenuation involved in my gate simulation but I am not understanding how can I add the umap when performing the reconstruction. Do I use the same -atn command as in castor-GATErootToCastor?

I mean that when I opened the results in Image J application, they were all black. Yes I did check the root file and it was fine. I think it was because I think it my have been with the way I opened it in Image J or maybe some settings I applied wrong in reconstruction.

Either way, I tried a new simulation example and runned the castor recons like this:

castor-recon -df /home/vgate/Desktop/castor_teste/castor_teste_df.Cdh -dout /home/vgate/Desktop/castor_teste -it 2:28 -dim 111,111,47 -vox 3,3,3.27 -opti MLEM -proj joseph -conv gaussian,4.,4.,3.5::psf -conv gaussian,6.,6.,3.5::post -th 0 -slice-out 3 -flip-out Y -vb 2

but I got this error message:

***** iIterativeAlgorithm::StepInnerLoopInsideSubsetLoop() → A problem occurred inside the parallel loop over events !
***** vAlgorithm::IterateCPU() → A problem occurred while calling StepInnerLoopInsideSubsetLoop() function !
***** castor-recon() → Error while performing the reconstruction
***** Exit function called. Abort with code 1.

Hi,
Yes, with list-mode format, you must provide the umap (interfile format, and with cm-1 unit) to castor-recon with -atn (unless you use a normalization datafile but the current castor converter does not provide (yet) this file). This is due to the different way of processing list-mode and histogram data.
Your reconstruction settings seems fine to me. Really the “optimal” reconstruction parameters depends on your data, geometry and what is your purpose for the reconstruction (qualitative, quantitative imaging, etc…). So if the Root files are correct I believe the issue could come from either in CASToR conversion, or the visualization software.
How do you open it with imageJ ? Sometimes there could be issues with the interfile format so it is worth trying to directly open the raw image. Also it could be as simple as a contrast issue (some high value in the image mess up with the automatic contrast setting of the software, resulting in a ‘black’ image). Just check if there is non-nil value in the image and adapt the contrast in this case.

Hope this helps,
Thibaut

Hi,
For the umap creation, I generated it in GATE which gave me files of the type .mhd and .raw. But because the .mhd wasn’t in the interfile format, I created a file of the type .hdr compatible with Castor based on a template I saw, like this:

!INTERFILE :=
!imaging modality := PET
!version of keys := CASToRv1.0

!GENERAL DATA :=
!originating system := GATE
!data offset in bytes := 0
!name of data file := Phantom-MuMap.raw

!GENERAL IMAGE DATA :=
!type of data := Static
!total number of images := 16
imagedata byte order := LITTLEENDIAN
!number of frame groups := 1
process status :=

!STATIC STUDY (General) :=
number of dimensions := 3
!matrix size [1] := 32 ; Adjusted to match 64 KB file size
!matrix size [2] := 32 ; Adjusted to match 64 KB file size
!matrix size [3] := 16 ; Adjusted to match 64 KB file size
!number format := short float
!number of bytes per pixel := 4
scaling factor (mm/pixel) [1] := 8.8
scaling factor (mm/pixel) [2] := 8.8
scaling factor (mm/pixel) [3] := 11.2
image duration (sec) := 30
image start time (sec) := 0
data rescale offset := 0
data rescale slope := 1
!END OF INTERFILE :=

Then, when I try again the reconstruction using this settings for my simulation and adding the attenuation map from my voxelized phantom:

castor-recon -df PETSIM2_df.Cdh -atn /home/vgate/Desktop/teste2_castor/output/images/petcastorumap.hdr -it 8:8 -dim 32,32,16 -vox 8.8,8.8,11.2 -fout ReconstructedImage -conv gaussian,4.,4.,3.5::psf -conv gaussian,6.,6.,3.5::post -opti MLEM -proj joseph -vb 2

I still get the same kind of error message:

***** iScannerPET::GetPositionsAndOrientations() → Crystal index 1 (-437559610) out of range [0:13823] !
***** vProjector::Project() → A problem occurred while getting positions and orientations from scanner !
***** oProjectorManager::ComputeProjectionLine() → A problem occurred while forward projecting an event !
***** iIterativeAlgorithm::StepInnerLoopInsideSubsetLoop() → A problem occurred while computing the projection line !
-------------------------------------------------|
***** iIterativeAlgorithm::StepInnerLoopInsideSubsetLoop() → A problem occurred inside the parallel loop over events !
***** vAlgorithm::IterateCPU() → A problem occurred while calling StepInnerLoopInsideSubsetLoop() function !
***** castor-recon() → Error while performing the reconstruction
***** Exit function called. Abort with code 1.

From what I read it can be related to the crystal settings in the geometry macro file but I used the castor-GATEMacToGeom so I don’t understand why this is happening. Do you think it could be the root file from the simulation?

I uploaded the files scripts. If you have the time to give it a look I would be very thankful!

About the Image J, it is solved I learned how to opened it the right way. :slight_smile:
mainmacrobrain.txt (12.3 KB)
geom_file_castor.txt (1.8 KB)

Thank you again!

Hi,
Indeed there seems to be issue in the datafile, but both your macro and geometry file look fine to me. Could you show the command line you used with castor-GATERootToCastor to create the datafile ?

Just to let you know, you can also use castor-GATERootToCastor with the -geo option to automatically generate the geometry alongside the datafile and bypass the castor-GATEMacToGeom step.

Hope this helps,
Thibaut

Hi,

Yes i did also try using that option on castor-GATERootToCastor with -geo.

Here’s the command line I used:

castor-GATERootToCastor -i /home/vgate/Desktop/Castor_test_GE_D690_scanner/output/petbrain.root -o PET_1 -m MainMacrobrain.mac -geo -s PET_GE_Discovery690

I don’t see anything wrong in your commands or file. If you can send me your root file (to thibaut.merlin@univ-brest.fr), I could have a closer look to check what is going on here.