Remove the loop on the subsets, and try again:

Do J=1,mtxsizJ

Do I=1,mtxsizI

Do K=1,AllAngles

I1=I

J1=J

K1=(K-1)

Write(1) ITime,Mat(i1,j1,k1),

- (K1-1),MtxsizI*(J1-1)+(I1-1)

EndDo

EndDo

EndDo

Remove the loop on the subsets, and try again:

Do J=1,mtxsizJ

Do I=1,mtxsizI

Do K=1,AllAngles

I1=I

J1=J

K1=(K-1)

Write(1) ITime,Mat(i1,j1,k1),

- (K1-1),MtxsizI*(J1-1)+(I1-1)

EndDo

EndDo

EndDo

OK but then it does not match what you suggested previously

Then, first subset will contain Mat(i=0,j=0,k=0), Mat(i=0,j=0,k=N), Mat(i=0,j=0,k=2*N), … and the resulting subsets will be better balanced.

Hälsningar / Best regards

Michael

Let’s N = mtxsizI*mtxsizJ*AllAngles and S be the number of subsets where AllAngles is a multiple of S

Your data are considered in CASToR as a 1D vector of size N (Data(1:N)) and not as a 3D matrix (Mat(1:mtxsizI,1:mtxsizJ,1:AllAngles)). This is the confusing part.

When looping on the “histogram events”, CASToR will read the following events for the first subset: Data(1),Data(S+1),Data(2*S+1),Data(3*S+1), …,Data(N-S+1)

and the following events for the second subset: Data(2),Data(S+2),Data(2*S+2),Data(3*S+2), …, Data(N-S+2).

If the data are written as:

iEvent = 1

Do J=1,mtxsizJ

Do I=1,mtxsizI

Do K=1,AllAngles

I1=I

J1=J

K1=K

Data(iEvent) = Mat(I1,I1,K1)

Angle(iEvent) = K1-1

Bin(iEvent) = MtxsizI*(J1-1)+(I1-1)

Write(ITime, Data(iEvent), Angle(iEvent), Bin(iEvent))

iEvent = iEvent + 1

EndDo

EndDo

EndDo

then, Data(1) = Mat(1,1,1), Data(S+1) = Mat(1,1,S+1), Data(2*S+1) = Mat(1,1,2*S+1), Data(3*S+1)=Mat(1,1,3*S+1), … , Data(N-S+1) = Mat(mtxsizI,mtxSizJ,AllAngles-S+1)

and Data(2) = Mat(1,1,2), Data(S+2) = Mat(1,1,S+2), Data(2*S+2) = Mat(1,1,2*S+2), Data(3*S+2)=Mat(1,1,3*S+2), … , Data(N-S+2)= Mat(mtxsizI,mtxSizJ,AllAngles-S+2).

Hope this helps,

Claude

Hi all

Look like my conversion program works now. I also got the attenuation correction to work. Simind and Castor has a different orientations so I solved this by starting at 180 degrees instead of flipping the end result. This also aligned to the orientation of the attenuation map.

I have a question concerning the scatter. The value I add to the *.cdf file – is it added in the forward projector or is it subtracted in some way? I assume the scatter value should be normalised to the total value I also add.

Second question – what does the “ Normalization factor of the corresponding sinogram bin“ value actually do in SPECT histograms?

Best regards

Michael

Hi Michael,

The scatter rate is normalized by the frame/acquisition duration in seconds (if provided) and added to the forward projection value. The normalization factor is a multiplicative correction factor applied during forward & backward projection.

Best regards,

Thibaut Merlin

Hi Michael,

To complete Thibaut's answer:

- the scatter amount is given as a rate in counts/sec. The "counts" refer to a raw number of scatter counts for this given bin (directly comparable to the prompts). A rate is needed for the generalization when we reconstruct from a list-mode for which the time frames are not predefined, so it is flexible.

- the normalization factor is optional and in SPECT it can be used for pixelated detectors like CZT-based detectors to normalize for variable efficiency from a pixel to another.

Finally, in CASToR, we took the decision to always consider additive contributions part of the model (added to the forward projection) and all multiplicative corrections are also combined within the system matrix elements. This corresponds to the "Ordinary Poisson" model. However, you are still allowed to provide any value in the "Amount of data in the bin" field.

Cheers

Simon