[Castor-users] Writing .Cdf file

tmerlin Thibaut.Merlin at univ-brest.fr
Mon May 15 17:24:36 CEST 2017


Hi Konstantinos,

The out of range projection index errors usually means the code can't 
correctly read the binary datafile as you said. Judging from the values 
in your cdf file, I think something went wrong during your conversion. 
Expected types are float for the data, and unsigned integers (4 bytes) 
for time & ids. I suggest trying something like this in your program:

   uint32_t id1, id2,** timeMS;    float** data;

   // recover data

   for (id1=0; id1<bins_elts; id1++)
   {
     for (id2=0; id2<nCrystalsTot; id2++)
     {
       fwrite((char*)(&timeMS[id1][id2]) ,  sizeof(uint32_t), 1, pFile);
       fwrite((char*)(&data[id1][id2]) ,  sizeof(float),  1, pFile);
       fwrite((char*)(&id1) ,  sizeof(uint32_t),  1, pFile);
       fwrite((char*)(&id2) ,  sizeof(uint32_t),  1, pFile);
     }
   }

Besides, I am not sure why your datafile header states 188811 events, 
while I would expect 107928 events from your numbers (nb of projections 
* nb of pixels).

Best regards,

Thibaut



On 15/05/2017 12:55, Konstantinos P. Chatzipapas, MSc wrote:
>
> Dear users/developers,
>
> I am trying to create a program that will write experimental results 
> to the appropriate .Cdf ascii format. I am using this loop:
>
>   char buffer [20];
>   sprintf(buffer, "CDF_CstrProj.Cdf");
>   pFile = fopen (buffer, "w");
>   for (id1=0; id1<bins_elts; id1++)
>   {
>     for (id2=0; id2<nCrystalsTot; id2++)
>     {
>       fprintf(pFile,"%6d ",timeMS[id1][id2]);
>       fprintf(pFile,"%6d ",data[id1][id2]);
>       fprintf(pFile,"%6d ",id1);
>       fprintf(pFile,"%6d ",id2);
>     }
>   }
>
> Where id1 is the projectionID (0-35) and id2 is the pixelID (0-2997). 
> Data are the counts. I am using integers in data but I have also try 
> it with floats. Then by using a .Cdh I try to reconstruct. There is a 
> problem there. Probably castor-recon does not recognize the file 
> correct, because I am getting this fault repeatedly (the "Projection 
> index" only change:
>
> ***** oIterativeAlgorithm::StepInnerLoopInsideSubsetLoop() -> A 
> problem occured while computing the projection line !
> ***** iScannerSPECTConv::GetPositionsAndOrientations() -> Projection 
> index (538976288) out of range [0:35] !
> ***** vProjector::Project() -> A problem occured while getting 
> positions and orientations from scanner !
> ***** oProjectorManager::ComputeProjectionLine() -> A problem occured 
> while forward projecting an event !
>
> I am attaching the file in order that you take a look and help me.
>
> Thank you in advance,
>
> Konstantinos
>
> -- 
> ------------------------------------------------------------------------
>  Konstantinos P. Chatzipapas
>  Physicist, MSc
>  Faculty of Medical Physics
> *University of Patras*
>
>      web page: /Physics Magazine <http://www.physicsmag.com>/
>
>
>
> _______________________________________________
> Castor-users mailing list
> Castor-users at lists.castor-project.org
> http://lists.castor-project.org/listinfo/castor-users

-- 
Thibaut MERLIN -- PhD

Docteur en Imagerie Médicale au Laboratoire de Traitement de l'Information Medicale (LaTIM - INSERM UMR 1101)
Bâtiment 1
CHRU Morvan - 2, Av. Foch
29609 Brest CEDEX - FRANCE
Tel: 06.75.12.24.90

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.castor-project.org/pipermail/castor-users/attachments/20170515/e0a7db57/attachment.html>


More information about the Castor-users mailing list