58 ifstream input_file(a_pathToHeader.c_str(), ios::in);
64 while(!input_file.eof())
66 getline(input_file, line);
76 Cerr(
"***** IntfKeyGetValueFromFile()-> Error : couldn't correctly read interfile key '"<< line <<
"' !" << endl);
87 Cerr(
"***** IntfKeyGetValueFromFile()-> Exception when trying to read tag '" << a_key <<
"' in file '" << a_pathToHeader <<
"'." << endl);
98 Cerr(
"***** IntfKeyGetValueFromFile() -> " << a_nbElts <<
" requested for interfile key " << a_key <<
" , but this key is not an array !" << endl);
106 Cerr(
"***** IntfKeyGetValueFromFile() -> Nb of elements to recover (=" << a_nbElts <<
") does not correspond to the number of elements found in the key '"
114 Cerr(
"***** IntfKeyGetValueFromFile() -> " << a_nbElts <<
" requested for interfile key " << a_key <<
" , but this key is not an array !" << endl);
125 if (a_mandatoryFlag > 0)
127 Cerr(
"***** IntfKeyGetValueFromFile()-> Error when reading Interfile '" << a_pathToHeader <<
"'. Key '" << a_key <<
"' was not found." << endl);
138 Cerr(
"***** IntfKeyGetValueFromFile()-> Couldn't find or read data-file '"<< a_pathToHeader <<
"' !" << endl);
145 template int IntfKeyGetValueFromFile<int>(
const string& a_pathToHeader,
const string& a_key,
int* ap_return,
int a_nbElts,
int a_mandatoryFlag);
147 template int IntfKeyGetValueFromFile<float>(
const string& a_pathToHeader,
const string& a_key,
float* ap_return,
int a_nbElts,
int a_mandatoryFlag);
153 template int IntfKeyGetValueFromFile<bool>(
const string& a_pathToHeader,
const string& a_key,
bool* ap_return,
int a_nbElts,
int a_mandatoryFlag);
175 uint16_t a_nbOccurrences)
177 ifstream input_file(a_pathToHeader.c_str(), ios::in);
179 uint16_t nb_occurences_cur =0;
184 while(!input_file.eof())
186 getline(input_file, line);
196 Cerr(
"***** IntfKeyGetValueFromFile()-> Error : couldn't correctly read interfile key '"<< line <<
"' !" << endl);
207 if(nb_occurences_cur < a_nbOccurrences)
217 Cerr(
"***** IntfKeyGetValueFromFile()-> Exception when trying to read tag '" << a_key <<
"' in file '" << a_pathToHeader <<
"'." << endl);
228 Cerr(
"***** IntfKeyGetValueFromFile() -> " << a_nbElts <<
" requested for interfile key " << a_key <<
" , but this key is not an array !" << endl);
236 Cerr(
"***** IntfKeyGetValueFromFile() -> Nb of elements to recover (=" << a_nbElts <<
") does not correspond to the number of elements found in the key '"
244 Cerr(
"***** IntfKeyGetValueFromFile() -> " << a_nbElts <<
" requested for interfile key " << a_key <<
" , but this key is not an array !" << endl);
255 if (a_mandatoryFlag > 0)
257 Cerr(
"***** IntfKeyGetValueFromFile()-> Error when reading Interfile '" << a_pathToHeader <<
"'. Key '" << a_key <<
"' was not found." << endl);
268 Cerr(
"***** IntfKeyGetValueFromFile()-> Couldn't find or read data-file '"<< a_pathToHeader <<
"' !" << endl);
310 if(vb >= 3)
Cout(
"IntfReadProjectionImage()-> Read Interfile header : "<< a_pathToHeaderFile << endl);
318 Cerr(
"***** IntfReadProjectionImage()-> Error : while trying to read the interfile header '"<< a_pathToHeaderFile <<
"' !" << endl);
325 int nb_tot_pixels = ap_IF->
mtx_size[0]
330 ifstream img_file(ap_IF->
path_to_image.c_str(), ios::binary | ios::in);
341 Cerr(
"***** IntfReadProjectionImage()-> Error occurred while trying to read the image file at the path: '"<< ap_IF->
path_to_image <<
"' !" << endl);
358 Cerr(
"***** IntfCheckDimensionsConsistency() -> Originating systems are not the same !" << endl);
364 Cerr(
"***** IntfCheckDimensionsConsistency() -> Numbers of dimensions are not the same !" << endl);
368 for (
int dim=0; dim<((int)ImgFields1.
nb_dims); dim++)
373 Cerr(
"***** IntfCheckDimensionsConsistency() -> The sizes of the dimension " << dim+1 <<
" are not the same !" << endl);
378 for (
int dim=0; dim<std::min(3,((
int)ImgFields1.
nb_dims)); dim++)
383 Cerr(
"***** IntfCheckDimensionsConsistency() -> Voxel sizes of dimension " << dim+1 <<
" are not the same !" << endl);
390 Cerr(
"***** IntfCheckDimensionsConsistency() -> Slice thicknesses are not the same !" << endl);
396 Cerr(
"***** IntfCheckDimensionsConsistency() -> Bed displacements between two successive bed positions are not the same !" << endl);
412 if (vb>=2)
Cout(
"IntfLoadImageFromScratch() -> Read Interfile image '" << a_pathToHeaderFile <<
"'" << endl);
420 Cerr(
"***** IntfLoadImageFromScratch() -> A problem occured while trying to read the interfile header '" << a_pathToHeaderFile <<
"' !" << endl);
427 Cerr(
"***** IntfLoadImageFromScratch() -> Cannot handle a number of dimensions higher than 3 !" << endl);
438 ifstream img_file(ap_ImgFields->
path_to_image.c_str(), ios::binary | ios::in);
441 Cerr(
"***** IntfLoadImageFromScratch() -> Input image file '" << ap_ImgFields->
path_to_image <<
"' is missing or corrupted !" << endl);
462 if (vb>=2)
Cout(
"IntfWriteImageFromIntfFields() -> Write 3D image with output base name '" << a_pathToImg <<
"'" << endl);
467 Cerr(
"***** IntfWriteImageFromIntfFields() -> Error : while trying to write the interfile header '"<< a_pathToImg <<
"' !" << endl);
472 string path_to_image = a_pathToImg;
473 path_to_image.append(
".img");
481 Cerr(
"***** IntfWriteImageFromIntfFields() -> Error : while trying to write the interfile image '"<< path_to_image <<
"' !" << endl);
510 if (vb>=3)
Cout(
"IntfReadImage()-> Read Interfile header : "<< a_pathToHeaderFile << endl);
519 Cerr(
"***** IntfReadImage()-> Error : while trying to read the interfile header '"<< a_pathToHeaderFile <<
"' !" << endl);
526 Cerr(
"***** IntfReadImage()-> Error : while checking consistencies between the reconstruction parameters and the interfile keys in the header '"<< a_pathToHeaderFile <<
"' !" << endl);
532 FLTNB* pimg_erp = NULL;
536 ifstream img_file(Img_fields.
path_to_image.c_str(), ios::binary | ios::in);
547 Cerr(
"***** IntfReadImage()-> Error occurred while trying to read the image file at the path: '"<< Img_fields.
path_to_image <<
"' !" << endl);
552 if(pimg_erp)
delete[] pimg_erp;
579 FLTNB**** a4p_ImgMatrix,
584 if(vb >= 5)
Cout(
"IntfReadImage()****" << endl);
591 vector<string> lpath_to_headers;
595 if(
IntfIsMHD(a_pathToHeaderFile, lpath_to_headers) < 0 )
597 Cerr(
"***** IntfReadImage()-> Error : while trying to read the interfile header '"<< a_pathToHeaderFile <<
"' !" << endl);
602 if(lpath_to_headers.size() == 1)
607 Cerr(
"***** IntfReadImage()-> Error : while trying to read the interfile header '"<< a_pathToHeaderFile <<
"' !" << endl);
614 Cerr(
"***** IntfReadImage()-> Error : while checking consistencies between the reconstruction parameters and the interfile keys in the header '"<< a_pathToHeaderFile <<
"' !" << endl);
622 FLTNB* pimg_erp = NULL;
626 ifstream img_file(Img_fields.
path_to_image.c_str(), ios::binary | ios::in);
645 Cerr(
"***** IntfReadImage()-> Error occurred while trying to read the image file at the path: '"<< Img_fields.
path_to_image <<
"' !" << endl);
650 if(pimg_erp)
delete[] pimg_erp;
662 Cerr(
"***** IntfReadImage()-> Error : while trying to read the interfile metaheader '"<< a_pathToHeaderFile <<
"' !" << endl);
672 if(lpath_to_headers.size() != (uint32_t)(dims[0]*dims[1]*dims[2]))
674 Cerr(
"***** IntfReadImage()-> Error : number of interfile images ("<< lpath_to_headers.size() <<
675 ") not consistent with the number of images to load (" << dims[0]*dims[1]*dims[2]<<
") !" << endl);
681 FLTNB* pimg_erp = NULL;
685 for(
int d1=0 ; d1<dims[0] ; d1++)
686 for(
int d2=0 ; d2<dims[1] ; d2++)
687 for(
int d3=0 ; d3<dims[2] ; d3++)
689 int idx_img = d1*dims[1]*dims[2] + d2*dims[2] + d3;
696 Cerr(
"***** IntfReadImage()-> Error : while trying to read the interfile header '"<< a_pathToHeaderFile <<
"' !" << endl);
703 Cerr(
"***** IntfReadImage()-> Error : while checking consistencies between the reconstruction parameters and the interfile keys in the header '"
704 << a_pathToHeaderFile <<
"' !" << endl);
709 ifstream img_file(Img_fields.
path_to_image.c_str(), ios::binary | ios::in);
720 Cerr(
"***** IntfReadImage()-> Error occurred while trying to read the image file at the path: '"<< Img_fields.
path_to_image <<
"' !" << endl);
726 if(pimg_erp)
delete[] pimg_erp;
765 FLTNB** a2p_ImgMatrix,
771 if(vb >= 5)
Cout(
"IntfReadImgDynCoeffFile" << endl);
778 vector<string> lpath_to_headers;
782 if(
IntfIsMHD(a_pathToHeaderFile, lpath_to_headers) <0)
784 Cerr(
"***** IntfReadImgDynCoeffFile()-> Error : while trying to read the interfile header '"<< a_pathToHeaderFile <<
"' !" << endl);
791 if(lpath_to_headers.size() == 1)
796 Cerr(
"***** IntfReadImgDynCoeffFile()-> Error : while trying to read the interfile header '"<< a_pathToHeaderFile <<
"' !" << endl);
803 Cerr(
"***** IntfReadImgDynCoeffFile()-> Error : while checking consistencies between the reconstruction parameters and the interfile keys in the header '"<< a_pathToHeaderFile <<
"' !" << endl);
809 FLTNB* pimg_erp = NULL;
812 ifstream img_file(Img_fields.
path_to_image.c_str(), ios::binary | ios::in);
821 for(
int bf=0 ; bf<a_nbFbases ; bf++)
826 Cerr(
"***** IntfReadImgDynCoeffFile()-> Error occurred while trying to read the image file at the path: '"<< Img_fields.
path_to_image <<
"' !" << endl);
831 if(pimg_erp)
delete[] pimg_erp;
843 Cerr(
"***** IntfReadImgDynCoeffFile()-> Error : while trying to read the interfile metaheader '"<< a_pathToHeaderFile <<
"' !" << endl);
848 if(lpath_to_headers.size() != (uint32_t)a_nbFbases)
850 Cerr(
"***** IntfReadImgDynCoeffFile()-> Error : number of interfile images ("<< lpath_to_headers.size() <<
851 ") not consistent with the number of parametric images (" << a_nbFbases<<
") !" << endl);
857 FLTNB* pimg_erp = NULL;
860 for(
int bf=0 ; bf<a_nbFbases ; bf++)
865 Cerr(
"***** IntfReadImgDynCoeffFile()-> Error : while trying to read the interfile header '"<< a_pathToHeaderFile <<
"' !" << endl);
872 Cerr(
"***** IntfReadImgDynCoeffFile()-> Error : while checking consistencies between the reconstruction parameters and the interfile keys in the header '"<< a_pathToHeaderFile <<
"' !" << endl);
876 ifstream img_file(Img_fields.
path_to_image.c_str(), ios::binary | ios::in);
887 Cerr(
"***** IntfReadImgDynCoeffFile()-> Error occurred while trying to read the image file at the path: '"<< Img_fields.
path_to_image <<
"' !" << endl);
893 if(pimg_erp)
delete[] pimg_erp;
916 uint32_t nb_vox = a_IF.
mtx_size[0] *
921 *a2p_img =
new FLTNB[ nb_vox ];
922 ::memset(*a2p_img, 0,
sizeof(
FLTNB) * nb_vox);
948 if(vb >= 5)
Cout(
"IntfCheckConsistency()" << endl);
955 Cerr(
"***** IntfCheckConsistency()-> Error : some mandatory keys not initialized. Cannot read the interfile image !" << endl);
958 Cerr(
" Error when trying to read path to image data" << endl);
960 Cerr(
" Error when trying to read data voxel type " << endl);
962 Cerr(
" Error when trying to read matrix size (image dimensions) : x= " << ap_IF->
mtx_size[0] <<
", y= " << ap_IF->
mtx_size[1] <<
", z= " << ap_IF->
mtx_size[2]<< endl);
970 Cerr(
"***** IntfCheckConsistency()-> WARNING : No information found about voxel size ('scaling factor (mm/pixel)' tags.). Missing voxel sizes will be set to 1mm !" << endl);
1001 Cerr(
"***** IntfCheckConsistency()-> Error : Image dimensions don't match reconstructions dimensions/voxel sizes");
1002 Cerr(
" and linear interpolation is disabled (a_lerpFlag is false) !" << endl);
1003 Cerr(
"***** Recovered image dimensions (x;y;z): "<< ap_IF->
mtx_size[0] <<
" ; "<< ap_IF->
mtx_size[1] <<
" ; " << ap_IF->
mtx_size[2] << endl);
1037 FLTNB* ap_outImgMatrix,
1038 FLTNB* ap_inImgMatrix,
1039 uint32_t* ap_offset,
1043 if(vb >= 5)
Cout(
"IntfGetPixelTypeAndReadData() " << endl);
1052 error =
IntfReadData(a_IF, ap_iFile, ap_outImgMatrix, ap_inImgMatrix, ap_offset, a_nbVox, vb, &flt);
1057 error =
IntfReadData(a_IF, ap_iFile, ap_outImgMatrix, ap_inImgMatrix, ap_offset, a_nbVox, vb, &db);
1064 error =
IntfReadData(a_IF, ap_iFile, ap_outImgMatrix, ap_inImgMatrix, ap_offset, a_nbVox, vb, &s_int);
1069 error =
IntfReadData(a_IF, ap_iFile, ap_outImgMatrix, ap_inImgMatrix, ap_offset, a_nbVox, vb, &s_int);
1074 error =
IntfReadData(a_IF, ap_iFile, ap_outImgMatrix, ap_inImgMatrix, ap_offset, a_nbVox, vb, &s_int);
1079 error =
IntfReadData(a_IF, ap_iFile, ap_outImgMatrix, ap_inImgMatrix, ap_offset, a_nbVox, vb, &s_int);
1101 error =
IntfReadData(a_IF, ap_iFile, ap_outImgMatrix, ap_inImgMatrix, ap_offset, a_nbVox, vb, &u_int);
1106 error =
IntfReadData(a_IF, ap_iFile, ap_outImgMatrix, ap_inImgMatrix, ap_offset, a_nbVox, vb, &u_int);
1111 error =
IntfReadData(a_IF, ap_iFile, ap_outImgMatrix, ap_inImgMatrix, ap_offset, a_nbVox, vb, &u_int);
1116 error =
IntfReadData(a_IF, ap_iFile, ap_outImgMatrix, ap_inImgMatrix, ap_offset, a_nbVox, vb, &u_int);
1122 Cerr(
"***** IntfGetPixelTypeAndReadData-> Error occurred when trying to read an interfile image !" << endl);
1156 FLTNB* ap_outImgMatrix,
1157 FLTNB* ap_inImgMatrix,
1163 if(vb >= 5)
Cout(
"IntfReadData() " << endl);
1173 pimg = ap_inImgMatrix;
1178 pimg = ap_outImgMatrix;
1211 bytes = (T*)malloc(nb_vox*
sizeof(T));
1213 ap_iFile->seekg(*a_offset);
1215 ap_iFile->read((
char*)bytes, nb_vox*
sizeof(T));
1218 for (
int v=0; v<nb_vox; v++)
1233 *a_offset +=
sizeof(T);
1247 Cerr(
"***** IntfReadData-> Error occurred when interpolating the interfile image to the reconstruction dimensions !" << endl);
1275 const uint32_t ap_iDimVox[3],
const uint32_t ap_oDimVox[3],
1276 const FLTNB ap_iSizeVox[3],
const FLTNB ap_oSizeVox[3])
1480 FLTNB const posOldImage[] = {-((
FLTNB)(ap_iDimVox[0]))*ap_iSizeVox[0]*((
FLTNB)0.5) ,
1481 -((
FLTNB)(ap_iDimVox[1]))*ap_iSizeVox[1]*((
FLTNB)0.5) ,
1482 -((
FLTNB)(ap_iDimVox[2]))*ap_iSizeVox[2]*((
FLTNB)0.5) };
1484 FLTNB const posNewImage[] = {-((
FLTNB)(ap_oDimVox[0]))*ap_oSizeVox[0]*((
FLTNB)0.5) ,
1485 -((
FLTNB)(ap_oDimVox[1]))*ap_oSizeVox[1]*((
FLTNB)0.5) ,
1486 -((
FLTNB)(ap_oDimVox[2]))*ap_oSizeVox[2]*((
FLTNB)0.5) };
1489 uint32_t
const iDimVoxPad[]
1491 ap_iDimVox[ 0 ] + 2,
1492 ap_iDimVox[ 1 ] + 2,
1496 uint32_t
const nElts = iDimVoxPad[ 0 ] *
1502 ::memset( pPadIData, 0,
sizeof(
FLTNB ) * nElts );
1504 for( uint32_t k = 0; k < ap_iDimVox[ 2 ]; ++k )
1505 for( uint32_t j = 0; j < ap_iDimVox[ 1 ]; ++j )
1506 for( uint32_t i = 0; i < ap_iDimVox[ 0 ]; ++i )
1508 pPadIData[ ( i + 1 ) + ( j + 1 ) * iDimVoxPad[ 0 ]
1509 + ( k + 1 ) * iDimVoxPad[ 0 ] * iDimVoxPad[ 1 ] ] =
1510 ap_iImg[ i + j * ap_iDimVox[ 0 ]
1511 + k * ap_iDimVox[ 0 ] * ap_iDimVox[ 1 ] ];
1516 FLTNB const boundMin[]
1518 posOldImage[ 0 ] - ap_iSizeVox[ 0 ] * ((
FLTNB)0.5),
1519 posOldImage[ 1 ] - ap_iSizeVox[ 1 ] * ((
FLTNB)0.5),
1520 posOldImage[ 2 ] - ap_iSizeVox[ 2 ] * ((
FLTNB)0.5)
1523 FLTNB const boundMax[]
1525 posOldImage[ 0 ] + ((
FLTNB)ap_iDimVox[ 0 ]) * ap_iSizeVox[ 0 ]
1526 + ap_iSizeVox[ 0 ] * ((
FLTNB)0.5),
1527 posOldImage[ 1 ] + ((
FLTNB)ap_iDimVox[ 1 ]) * ap_iSizeVox[ 1 ]
1528 + ap_iSizeVox[ 1 ] * ((
FLTNB)0.5),
1529 posOldImage[ 2 ] + ((
FLTNB)ap_iDimVox[ 2 ]) * ap_iSizeVox[ 2 ]
1530 + ap_iSizeVox[ 2 ] * ((
FLTNB)0.5)
1537 for( uint32_t i = 0; i < 3; ++i )
1539 pOldCoordCenter[ i ] =
new FLTNB[ iDimVoxPad[ i ] ];
1541 for( uint32_t j = 0; j < iDimVoxPad[ i ]; ++j )
1543 pOldCoordCenter[ i ][ j ] = posOldImage[ i ] - ap_iSizeVox[ i ] / 2.0
1544 + j * ap_iSizeVox[ i ];
1551 for( uint32_t i = 0; i < 3; ++i )
1553 pNewCoordCenter[ i ] =
new FLTNB[ ap_oDimVox[ i ] ];
1555 for( uint32_t j = 0; j < ap_oDimVox[ i ]; ++j )
1557 pNewCoordCenter[ i ][ j ] = posNewImage[ i ] + ap_oSizeVox[ i ] / 2.0
1558 + j * ap_oSizeVox[ i ];
1563 FLTNB const invSizeX = 1.0 / ap_iSizeVox[ 0 ];
1564 FLTNB const invSizeY = 1.0 / ap_iSizeVox[ 1 ];
1565 FLTNB const invSizeZ = 1.0 / ap_iSizeVox[ 2 ];
1571 for( uint32_t k = 0; k < ap_oDimVox[ 2 ]; ++k )
1574 FLTNB const z = pNewCoordCenter[ 2 ][ k ];
1575 if( z < boundMin[ 2 ] || z > boundMax[ 2 ] )
continue;
1578 int32_t
const zBin = ( z - boundMin[ 2 ] ) * invSizeZ;
1581 FLTNB const zComposantI0 = invSizeZ * ( pOldCoordCenter[ 2 ][ zBin + 1 ] - z );
1582 FLTNB const zComposantI1 = invSizeZ * ( z - pOldCoordCenter[ 2 ][ zBin ] );
1584 for( uint32_t j = 0; j < ap_oDimVox[ 1 ]; ++j )
1587 FLTNB const y = pNewCoordCenter[ 1 ][ j ];
1588 if( y < boundMin[ 1 ] || y > boundMax[ 1 ] )
continue;
1591 int32_t
const yBin = ( y - boundMin[ 1 ] ) * invSizeY;
1594 FLTNB const yComposantI0 = invSizeY * ( pOldCoordCenter[ 1 ][ yBin + 1 ]
1596 FLTNB const yComposantI1 = invSizeY * ( y
1597 - pOldCoordCenter[ 1 ][ yBin ] );
1599 for( uint32_t i = 0; i < ap_oDimVox[ 0 ]; ++i )
1602 FLTNB const x = pNewCoordCenter[ 0 ][ i ];
1603 if( x < boundMin[ 0 ] || x > boundMax[ 0 ] )
continue;
1606 int32_t
const xBin = ( x - boundMin[ 0 ] ) * invSizeX;
1609 FLTNB const xComposantI0 = invSizeX * (
1610 pOldCoordCenter[ 0 ][ xBin + 1 ] - x );
1611 FLTNB const xComposantI1 = invSizeX * ( x
1612 - pOldCoordCenter[ 0 ][ xBin ] );
1615 for( uint32_t kk = 0; kk < 2; ++kk )
1617 for( uint32_t jj = 0; jj < 2; ++jj )
1619 for( uint32_t ii = 0; ii < 2; ++ii )
1621 pKernelData[ ii + jj * 2 + kk * 2 * 2 ] =
1624 ( yBin + jj ) * iDimVoxPad[ 0 ] +
1625 ( zBin + kk ) * iDimVoxPad[ 0 ] * iDimVoxPad[ 1 ]
1633 FLTNB const xInterpVal0 = pKernelData[ 0 ] * xComposantI0 +
1634 pKernelData[ 1 ] * xComposantI1;
1636 FLTNB const xInterpVal1 = pKernelData[ 2 ] * xComposantI0 +
1637 pKernelData[ 3 ] * xComposantI1;
1639 FLTNB const xInterpVal2 = pKernelData[ 4 ] * xComposantI0 +
1640 pKernelData[ 5 ] * xComposantI1;
1642 FLTNB const xInterpVal3 = pKernelData[ 6 ] * xComposantI0 +
1643 pKernelData[ 7 ] * xComposantI1;
1646 FLTNB const yInterpVal0 = xInterpVal0 * yComposantI0 +
1647 xInterpVal1 * yComposantI1;
1649 FLTNB const yInterpVal1 = xInterpVal2 * yComposantI0 +
1650 xInterpVal3 * yComposantI1;
1653 FLTNB const interpValTot = yInterpVal0 * zComposantI0 +
1654 yInterpVal1 * zComposantI1;
1656 ap_oImg[ i + j * ap_oDimVox[ 0 ]
1657 + k * ap_oDimVox[ 0 ] * ap_oDimVox[ 1 ] ] = interpValTot;
1663 for( uint32_t i = 0; i < 3; ++i )
1665 delete[] pOldCoordCenter[ i ];
1666 delete[] pNewCoordCenter[ i ];
1668 delete[] pOldCoordCenter;
1669 delete[] pNewCoordCenter;
1671 delete[] pKernelData;
1699 if (vb>=3)
Cout(
"IntfWriteImgFile (with Intf_fields)" << endl);
1704 Cerr(
"***** IntfWriteImgFile()-> Error : while trying to write the interfile header for'"<< a_pathToImg <<
"' !" << endl);
1708 string path_to_image = a_pathToImg;
1709 path_to_image.append(
".img");
1714 Cerr(
"***** IntfWriteImgFile()-> Error : while trying to write the interfile image '"<< path_to_image <<
"' !" << endl);
1743 if (vb>=3)
Cout(
"IntfWriteImgFile (3D image)" << endl);
1751 Cerr(
"***** IntfWriteImgFile()-> Error : while trying to write the interfile header for'"<< a_pathToImg <<
"' !" << endl);
1755 string path_to_image = a_pathToImg;
1756 path_to_image.append(
".img");
1761 Cerr(
"***** IntfWriteImgFile()-> Error : while trying to write the interfile image '"<< path_to_image <<
"' !" << endl);
1793 if (vb>=3)
Cout(
"IntfWriteProjFile ..." << endl);
1796 vector<string> lpath_to_images;
1797 lpath_to_images.push_back(a_pathToImg);
1801 Cerr(
"***** IntfWriteProjFile()-> Error : while trying to write the interfile header for'"<< lpath_to_images[0] <<
"' !" << endl);
1814 Cerr(
"***** IntfWriteFile()-> Error : while trying to write the interfile image '"<< a_pathToImg <<
"' !" << endl);
1847 if (vb>=3)
Cout(
"IntfWriteImgDynCoeffFile ..." << endl);
1859 vector<string> lpath_to_images;
1863 lpath_to_images.push_back(a_pathToImg);
1867 Cerr(
"***** IntfWriteImgDynCoeffFile()-> Error : while trying to write the interfile header for'"<< lpath_to_images[0] <<
"' !" << endl);
1875 for(
int bf=0 ; bf<a_nbParImgs ; bf++)
1878 lpath_to_images.push_back(a_pathToImg);
1881 stringstream ss; ss << bf + 1;
1882 lpath_to_images[idx_file].append(
"_par").append(ss.str());
1885 string path_to_hdr = lpath_to_images[idx_file] +
".hdr";
1886 string path_to_img = lpath_to_images[idx_file] +
".img";
1890 ifstream fcheck(path_to_hdr.c_str());
1895 string dos_instruction =
"del " + path_to_hdr;
1896 system(dos_instruction.c_str());
1898 remove(path_to_hdr.c_str());
1902 ofstream ofile(path_to_hdr.c_str(), ios::out | ios::app);
1903 ofile << setprecision(std::numeric_limits<FLTNB>::digits10 +1);
1904 ofile <<
"!INTERFILE := " << endl;
1905 ofile <<
"!name of data file := " <<
GetFileFromPath(path_to_img) << endl;
1907 ofile <<
"!data offset in bytes := " << 0 << endl;
1911 Cerr(
"***** IntfWriteImgDynCoeffFile()-> Error : while trying to write the interfile header for'"<< lpath_to_images[idx_file] <<
"' !" << endl);
1920 if(
IntfWriteMHD(a_pathToImg, lpath_to_images, Img_fields, ap_ID, vb) )
1922 Cerr(
"***** IntfWriteImgDynCoeffFile()-> Error : while trying to write the interfile header '"<< a_pathToImg <<
"' !" << endl);
1931 dims[0] = a_nbParImgs;
1936 Cerr(
"***** IntfWriteImgDynCoeffFile()-> Error : while trying to write the interfile image '"<< a_pathToImg <<
"' !" << endl);
1967 if (vb>=3)
Cout(
"IntfWriteImgFile (static/dynamic image) ..." << endl);
1977 vector<string> lpath_to_images;
1981 lpath_to_images.push_back(a_pathToImg);
1985 Cerr(
"***** IntfWriteImgFile()-> Error : while trying to write the interfile header for'"<< lpath_to_images[0] <<
"' !" << endl);
1998 lpath_to_images.push_back(a_pathToImg);
2002 stringstream ss; ss << fr + 1;
2003 lpath_to_images[idx_file].append(
"_fr").append(ss.str());
2008 stringstream ss; ss << rg + 1;
2009 lpath_to_images[idx_file].append(
"_rg").append(ss.str());
2014 stringstream ss; ss << cg + 1;
2015 lpath_to_images[idx_file].append(
"_cg").append(ss.str());
2019 string path_to_hdr = lpath_to_images[idx_file];
2020 string path_to_img = lpath_to_images[idx_file];
2024 ifstream fcheck(path_to_hdr.append(
".hdr").c_str());
2029 string dos_instruction =
"del " + path_to_hdr;
2030 system(dos_instruction.c_str());
2032 remove(path_to_hdr.c_str());
2036 ofstream ofile(path_to_hdr.c_str(), ios::out | ios::app);
2037 ofile << setprecision(std::numeric_limits<FLTNB>::digits10 +1);
2038 ofile <<
"!INTERFILE := " << endl;
2039 ofile <<
"!name of data file := " <<
GetFileFromPath(path_to_img).append(
".img") << endl;
2041 ofile <<
"!data offset in bytes := " << 0 << endl;
2045 Cerr(
"***** IntfWriteImgFile()-> Error : while trying to write the interfile header for'"<< lpath_to_images[idx_file] <<
"' !" << endl);
2061 if(
IntfWriteMHD(a_pathToImg, lpath_to_images, Img_fields, ap_ID, vb) )
2063 Cerr(
"***** IntfWriteImgFile()-> Error : while trying to write the interfile header '"<< a_pathToImg <<
"' !" << endl);
2079 Cerr(
"***** IntfWriteImgFile()-> Error : while trying to write the interfile image '"<< a_pathToImg <<
"' !" << endl);
2168 int IntfIsMHD(
string a_pathToFile, vector<string> &ap_lPathToImgs)
2171 ifstream hfile(a_pathToFile.c_str(), ios::in);
2179 getline(hfile, line);
2182 if(line.empty())
continue;
2190 Cerr(
"***** IntfIsMHD()-> Error : couldn't correctly read interfile key '"<< line <<
"' !" << endl);
2202 uint16_t nb_datasets = 0;
2205 Cerr(
"***** IntfIsMHD()-> Error when trying to read data from 'total number of data set' key. Recovered value = " << Key.
kvalue << endl);
2213 string file_key =
"";
2214 string file_keyp =
"%";
2215 string file_key_space =
"";
2216 string file_keyp_space =
"%";
2217 file_key_space.append(
"data set [").append(ss.str()).append(
"]");
2218 file_keyp_space.append(
"data set [").append(ss.str()).append(
"]");
2219 file_key.append(
"data set[").append(ss.str()).append(
"]");
2220 file_keyp.append(
"data set[").append(ss.str()).append(
"]");
2227 getline(hfile, line);
2230 if(line.empty())
continue;
2235 Cerr(
"***** IntfIsMHD()-> Error : couldn't correctly read interfile key '"<< line <<
"' !" << endl);
2253 Cerr(
"***** IntfIsMHD()-> Error : when trying to read Interfile array key: '"<< line <<
"' !" << endl);
2256 else if(nb_elts != 3)
2258 Cerr(
"***** IntfIsMHD()-> Error : when trying to read Interfile array key: '"<< line <<
"' !" << endl);
2259 Cerr(
" 3 elements are expected following the format {xxx, path_to_the_img_file, xxx} (xxx = ignored data)" << endl);
2265 Cerr(
"***** IntfIsMHD()-> Error : when trying to read Interfile array key: '"<< line <<
"' !" << endl);
2268 ap_lPathToImgs.at(file_idx).append(elts_str[1]);
2271 ap_lPathToImgs.at(file_idx).append(Key.
kvalue);
2279 file_key.append(
"data set [").append(ss.str()).append(
"]");
2280 file_keyp.append(
"data set [").append(ss.str()).append(
"]");
2286 if(nb_datasets != ap_lPathToImgs.size())
2289 Cerr(
"***** IntfIsMHD()-> The number of recovered file in the metaheader ("<<ap_lPathToImgs.size()<<
")");
2290 Cerr(
"does not correspond to the expected number of datasets ("<<nb_datasets<<
")!"<< endl);
2301 Cerr(
"***** IntfIsMHD()-> Error : couldn't read header file '"<< a_pathToFile <<
"' !" << endl);
2307 ap_lPathToImgs.push_back(a_pathToFile);
2330 const vector<string>& ap_lPathToImgs,
2336 string path_to_mhd_file = a_pathToMhd;
2337 path_to_mhd_file.append(
".mhd");
2338 ofstream ofile(path_to_mhd_file.c_str(), ios::out);
2339 ofile << setprecision(std::numeric_limits<FLTNB>::digits10 +1);
2347 ofile <<
"!INTERFILE := " << endl;
2349 ofile << endl <<
"!GENERAL DATA := " << endl;
2350 ofile <<
"data description:=image" << endl;
2351 ofile <<
"!originating system := " << p_scanMgr->
GetScannerName() << endl;
2354 ofile << endl <<
"%DATA MATRIX DESCRIPTION:=" << endl;
2355 ofile <<
"number of time frames := " << a_IntfF.
nb_time_frames << endl;
2356 ofile <<
"number of time windows := " << a_IntfF.
nb_resp_gates *
2358 ofile <<
"number of respiratory gates := " << a_IntfF.
nb_resp_gates << endl;
2359 ofile <<
"number of cardiac gates := " << a_IntfF.
nb_card_gates << endl;
2361 ofile << endl <<
"%DATA SET DESCRIPTION:="<< endl;
2364 ofile <<
"!total number of data sets:=" << nb_imgs << endl;
2367 if(ap_lPathToImgs.size() != nb_imgs)
2369 Cerr(
"***** IntfWriteMHD()-> Error : nb of provided string inconsistent with the expected number of dynamic images: '"<< nb_imgs <<
"' !" << endl);
2374 for(
int ds=0 ; ds<nb_imgs ; ds++)
2376 string path_to_header = ap_lPathToImgs.at(ds);
2377 ofile <<
"%data set ["<<ds+1<<
"]:={0," <<
GetFileFromPath(path_to_header).append(
".hdr") <<
",UNKNOWN}"<< endl;
2382 Cerr(
"***** IntfWriteMHD()-> Error : couldn't find output Metaheader interfile '"<< path_to_mhd_file <<
"' !" << endl);
2419 Cout(
"--------------------------------------------------------------- " << endl);
2420 Cout(
"IntfReadHeader()-> Start reading header interfile " << a_pathToHeaderFile << endl);
2421 Cout(
"--------------------------------------------------------------- " << endl);
2425 ifstream input_file(a_pathToHeaderFile.c_str(), ios::in);
2431 while(!input_file.eof())
2433 getline(input_file, line);
2445 Cerr(
"***** ReadIntfHeader()-> Error : couldn't correctly read interfile key '"<< line <<
"' !" << endl);
2449 if (vb >=10)
Cout(
"ReadIntfHeader()-> Key " << Key.
kcase << endl);
2468 if ( Key.
kvalue.size()>0 )
2480 string header_file_directory =
GetPathOfFile(a_pathToHeaderFile);
2486 Cerr(
"***** ReadIntfHeader()-> Error : path to interfile image file is empty !" << endl);
2501 if (endianness ==
"littleendian")
2515 Cerr(
"***** ReadIntfHeader()-> Warning : data_offset value was already set to " << ap_IF->
data_offset << endl);
2516 Cerr(
"***** The header may contain both 'data offset in bytes' and 'data starting block' fields " << endl);
2521 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'data starting block' key. Recovered value = " << Key.
kvalue << endl);
2536 Cerr(
"***** ReadIntfHeader()-> Warning : data_offset value was already set to " << ap_IF->
data_offset << endl);
2537 Cerr(
"***** The header may contain both 'data offset in bytes' and 'data starting block' fields " << endl);
2542 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'data offset in bytes' key. Recovered value = " << Key.
kvalue << endl);
2554 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'number format' key. Recovered value = " << Key.
kvalue << endl);
2565 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'originating system' key. Recovered value = " << Key.
kvalue << endl);
2576 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'multiple bed displacement' key. Recovered value = " << Key.
kvalue << endl);
2587 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'matrix size [1]' key. Recovered value = " << Key.
kvalue << endl);
2598 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'matrix size [2]' key. Recovered value = " << Key.
kvalue << endl);
2615 Cerr(
"***** ReadIntfHeader()-> Array reading for 'matrix size [3]' key not implemented yet. Single value expected." << endl);
2622 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'matrix size [3]' key. Recovered value = " << Key.
kvalue << endl);
2644 Cerr(
"***** ReadIntfHeader()-> Array reading for 'matrix size [4]' key not implemented yet. Single value expected." << endl);
2653 Cerr(
"***** ReadIntfHeader()-> WARNING : both 'number of time frames' and 'matrix size [4]' keys have been provided");
2654 Cerr(
" 'number of time frames' selected by default" << endl);
2658 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'matrix size [4]' key. Recovered value = " << Key.
kvalue << endl);
2677 Cerr(
"***** ReadIntfHeader()-> Array reading for 'matrix size [5]' key not implemented yet. Single value expected." << endl);
2684 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'matrix size [5]' key. Recovered value = " << Key.
kvalue << endl);
2702 Cerr(
"***** ReadIntfHeader()-> Array reading for 'matrix size [6]' key not implemented yet. Single value expected." << endl);
2709 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'matrix size [6]' key. Recovered value = " << Key.
kvalue << endl);
2727 Cerr(
"***** ReadIntfHeader()-> Array reading for 'matrix size [7]' key not implemented yet. Single value expected." << endl);
2734 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'matrix size [7]' key. Recovered value = " << Key.
kvalue << endl);
2747 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'scaling factor (mm/pixel) [1]' key. Recovered value = " << Key.
kvalue << endl);
2758 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'scaling factor (mm/pixel) [2]' key. Recovered value = " << Key.
kvalue << endl);
2770 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'scaling factor (mm/pixel) [3]' key. Recovered value = " << Key.
kvalue << endl);
2782 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'slice thickness (pixels)' key. Recovered value = " << Key.
kvalue << endl);
2794 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'centre-centre slice separation (pixels)' key.");
2795 Cerr(
" Recovered value = " << Key.
kvalue << endl);
2798 Cerr(
"***** ReadIntfHeader()-> WARNING : 'centre-centre slice separation (pixels)' has no use in the current implementation !"<< endl);
2809 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'number of time frames' or 'number of frame groups' keys.");
2810 Cerr(
"Recovered value = " << Key.
kvalue << endl);
2822 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'number of respiratory gates' key. Recovered value = " << Key.
kvalue << endl);
2834 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'number of cardiac gates' key. Recovered value = " << Key.
kvalue << endl);
2845 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'total number of images' key. Recovered value = " << Key.
kvalue << endl);
2856 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'number of bytes per pixel' key. Recovered value = " << Key.
kvalue << endl);
2866 string slice_orientation;
2869 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'slice orientation' key. Recovered value = " << Key.
kvalue << endl);
2873 if (slice_orientation ==
"transverse")
2875 else if (slice_orientation ==
"sagittal")
2877 else if (slice_orientation ==
"coronal")
2886 string pat_rotation;
2889 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'patient rotation' key. Recovered value = " << Key.
kvalue << endl);
2893 if (pat_rotation ==
"supine")
2895 else if (pat_rotation ==
"prone")
2905 string pat_orientation;
2908 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'patient orientation' key. Recovered value = " << Key.
kvalue << endl);
2912 if (pat_orientation ==
"head_in")
2914 else if (pat_orientation ==
"feet_in")
2926 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'rescale slope' key. Recovered value = " << Key.
kvalue << endl);
2933 Cerr(
"***** ReadIntfHeader()-> Error : field 'resclale slope' units should be >0!" << endl);
2948 Cerr(
"***** ReadIntfHeader()-> WARNING : Error when trying to read numeric value from 'quantification units' key. Actual value = " << Key.
kvalue << endl);
2949 Cerr(
"***** This key will be ignored" << endl);
2956 Cerr(
"***** ReadIntfHeader()-> Error : field 'quantification units' should be >0!" << endl);
2967 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'rescale intercept' key. Recovered value = " << Key.
kvalue << endl);
2973 Cerr(
"***** ReadIntfHeader()-> Error : field 'resclale intercept' units should be >0!" << endl);
2987 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'type of data' key. Recovered value = " << Key.
kvalue << endl);
3001 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'study duration (sec)' key. Recovered value = " << Key.
kvalue << endl);
3015 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'study duration (sec)' key. Recovered value = " << Key.
kvalue << endl);
3026 FLTNB pause_duration;
3029 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'study duration (sec)' key. Recovered value = " << Key.
kvalue << endl);
3043 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'number of time windows ' key. Recovered value = " << Key.
kvalue << endl);
3046 Cerr(
"***** ReadIntfHeader()-> WARNING : 'number of time windows' has no use in the current implementation !"<< endl);
3056 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'process status' key. Recovered value = " << Key.
kvalue << endl);
3069 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'number of energy windows' key. Recovered value = " << Key.
kvalue << endl);
3082 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'number of detector heads' key. Recovered value = " << Key.
kvalue << endl);
3094 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'number of projections' key. Recovered value = " << Key.
kvalue << endl);
3106 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'extent of rotation' key. Recovered value = " << Key.
kvalue << endl);
3117 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'direction_rotation' key. Recovered value = " << Key.
kvalue << endl);
3130 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'start angle' key. Recovered value = " << Key.
kvalue << endl);
3142 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'projection_angles' key. Recovered value = " << Key.
kvalue << endl);
3154 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'Center of rotation to detector distance' key.");
3155 Cerr(
" Recovered value = " << Key.
kvalue << endl);
3167 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'Radius' key. Recovered value = " << Key.
kvalue << endl);
3177 Cerr(
"***** ReadIntfHeader()-> Error : compressed interfile images not handled by the current implementation !" << endl);
3187 Cerr(
"***** ReadIntfHeader()-> Error : encoded interfile images not handled by the current implementation !" << endl);
3199 Cerr(
"***** ReadIntfHeader()-> Error when trying to read data from 'number of slices' key. Recovered value = " << Key.
kvalue << endl);
3211 Cerr(
"***** ReadIntfHeader()-> Error : couldn't find or read header interfile '"<< a_pathToHeaderFile <<
"' !" << endl);
3241 Cerr(
"***** ReadIntfHeader()-> Error : nb of recovered frame duration ('"<< ap_IF->
image_duration.size()
3242 <<
") does not match the nb of recovered pauses between frames ('"<< ap_IF->
frame_group_pause.size() <<
") !" << endl);
3270 Cout(
"--------------------------------------------------------------- " << endl);
3271 Cout(
"IntfWriteHeaderMainData()-> Start writing header interfile " << a_path << endl);
3272 Cout(
"--------------------------------------------------------------- " << endl);
3275 string path_to_header, path_to_image;
3276 path_to_header = a_path;
3278 path_to_header.append(
".hdr");
3282 ofstream ofile(path_to_header.c_str(), ios::out);
3283 ofile << setprecision(std::numeric_limits<FLTNB>::digits10 +1);
3289 ofile <<
"!INTERFILE := " << endl;
3292 string imaging_modality;
3294 imaging_modality =
"PET";
3296 imaging_modality =
"SPECT";
3298 imaging_modality =
"CT";
3300 imaging_modality =
"UNKOWN";
3302 ofile <<
"!imaging modality := " << imaging_modality << endl;
3306 ofile <<
"!version of keys := " <<
"3.3" << endl;
3308 ofile <<
"!version of keys := " <<
"CASToRv" <<
CASTOR_VERSION << endl;
3312 ofile << endl <<
"!GENERAL DATA := " << endl;
3313 ofile <<
"!originating system := " << p_scanMgr->
GetScannerName() << endl;
3320 ofile <<
"!data offset in bytes := " << 0 << endl;
3321 ofile <<
"!name of data file := " << path_to_image << endl;
3324 ofile << endl <<
"!GENERAL IMAGE DATA " << endl;
3329 ofile <<
"!type of data := " << data_type_str << endl;
3333 ofile <<
"!total number of images := " << nb_imgs << endl;
3340 ofile <<
"number of time frames := " << ap_IntfF.
nb_time_frames << endl;
3342 ofile <<
"number of time windows := " << ap_IntfF.
nb_resp_gates *
3345 ofile <<
"number of respiratory gates := " << ap_IntfF.
nb_resp_gates << endl;
3347 ofile <<
"number of cardiac gates := " << ap_IntfF.
nb_card_gates << endl;
3351 ofile <<
"!number of projections := " << ap_IntfF.
nb_projections << endl;
3352 ofile <<
"!extent of rotation := " << ap_IntfF.
extent_rotation << endl;
3354 ofile <<
"process status := " << ap_IntfF.
process_status << endl;
3358 ofile << endl <<
"!DYNAMIC STUDY (General) :=" << endl;
3362 ofile << endl <<
"!GSPECT STUDY (General) :=" << endl;
3365 ofile << endl <<
"!SPECT STUDY (General) :=" << endl;
3366 ofile << endl <<
"!SPECT STUDY ("<< ap_IntfF.
process_status <<
" data) :="<< endl;
3370 ofile << endl <<
"!GATED STUDY (General) :=" << endl;
3372 ofile << endl <<
"!STATIC STUDY (General) :=" << endl;
3385 ofile <<
"!number of frame groups :=" << ap_IntfF.
nb_time_frames << endl;
3392 ofile <<
"!Dynamic Study (each frame group) :=" << endl;
3393 ofile <<
"!frame group number := " << fr+1 << endl;
3401 ofile <<
"!Respiratory Gated Study (each time window) :=" << endl;
3402 ofile <<
"!time window number := " << rg+1 << endl;
3410 ofile <<
"!Cardiac Gated Study (each time window) :=" << endl;
3411 ofile <<
"!time window number := " << cg+1 << endl;
3417 Cerr(
"***** IntfWriteHeaderMainData()-> Error : while trying to write the interfile header '"<< path_to_header <<
"' !" << endl);
3422 ofile <<
"!number of images in this time window :="
3428 ofile <<
"!number of images in this time window :="
3436 ofile <<
"!number of images this frame group :="
3441 ofile <<
"!image duration (sec) := " << ap_IntfF.
image_duration[fr] << endl;
3443 ofile <<
"pause between frame groups (sec) " << 0.0 << endl;
3445 ofile <<
"pause between frame groups (sec) " << ap_IntfF.
frame_group_pause[fr] << endl;
3449 ofile <<
"!END OF INTERFILE := " << endl;
3453 Cerr(
"***** IntfWriteHeaderMainData()-> Error : couldn't find output header interfile '"<< a_path <<
"' !" << endl);
3486 ap_ofile <<
"start angle := " << ap_IntfF.
first_angle << endl;
3490 if( ap_IntfF.
radius.find(
"{}") != string::npos )
3491 ap_ofile <<
"Center of rotation to detector distance := " << ap_IntfF.
radius << endl;
3493 ap_ofile <<
"Radius := " << ap_IntfF.
radius << endl;
3495 ap_ofile <<
"!matrix size [1] := " << ap_IntfF.
mtx_size[0] << endl;
3496 ap_ofile <<
"!matrix size [2] := " << ap_IntfF.
mtx_size[1] << endl;
3497 ap_ofile <<
"!number format := " << ap_IntfF.
nb_format << endl;
3498 ap_ofile <<
"!number of bytes per pixel := " <<
sizeof(
FLTNB) << endl;
3499 ap_ofile <<
"scaling factor (mm/pixel) [1] := " << ap_IntfF.
vox_size[0] << endl;
3500 ap_ofile <<
"scaling factor (mm/pixel) [2] := " << ap_IntfF.
vox_size[1] << endl;
3501 ap_ofile <<
"!data offset in bytes := " << 0 << endl;
3505 ap_ofile <<
"number of dimensions := " << 3 << endl;
3506 ap_ofile <<
"!matrix size [1] := " << ap_IntfF.
mtx_size[0] << endl;
3507 ap_ofile <<
"!matrix size [2] := " << ap_IntfF.
mtx_size[1] << endl;
3508 ap_ofile <<
"!matrix size [3] := " << ap_IntfF.
mtx_size[2] << endl;
3509 ap_ofile <<
"!number format := " << ap_IntfF.
nb_format << endl;
3510 ap_ofile <<
"!number of bytes per pixel := " <<
sizeof(
FLTNB) << endl;
3511 ap_ofile <<
"scaling factor (mm/pixel) [1] := " << ap_IntfF.
vox_size[0] << endl;
3512 ap_ofile <<
"scaling factor (mm/pixel) [2] := " << ap_IntfF.
vox_size[1] << endl;
3513 ap_ofile <<
"scaling factor (mm/pixel) [3] := " << ap_IntfF.
vox_size[2] << endl;
3518 ap_ofile <<
"data rescale slope := " << ap_IntfF.
rescale_slope << endl;
3537 Cerr(
"***** IntfWriteHeaderImgData()-> Error : couldn't open provided interfile header file !" << endl);
3563 if(vb >= 5)
Cout(
"IntfWriteImage()*" << endl);
3565 ofstream img_file(a_pathToImg.c_str(), ios::binary | ios::out);
3572 Cerr(
"***** IntfWriteImage()-> Error occurred when writing the image file '"<< a_pathToImg <<
"' !" << endl);
3578 Cerr(
"***** IntfWriteImage()-> Error occurred while trying to write the image file '"<< a_pathToImg <<
"' !" << endl);
3604 if(vb >= 5)
Cout(
"IntfWriteImage()**" << endl);
3606 if(ap_pathToImgs.size() == 1)
3610 ifstream fcheck(ap_pathToImgs.at(0).append(
".img").c_str());
3615 string dos_instruction =
"del " + ap_pathToImgs.at(0);
3616 system(dos_instruction.c_str());
3618 remove(ap_pathToImgs.at(0).c_str());
3623 ofstream img_file(ap_pathToImgs.at(0).c_str(), ios::binary | ios::out | ios::app);
3628 for(uint32_t d1=0 ; d1<ap_dim[0] ; d1++)
3629 if(
IntfWriteData(&img_file, a2p_outImgMtx[d1], ap_dim[1], vb) )
3631 Cerr(
"***** IntfWriteImage()-> Error occurred when writing the image file '"<< ap_pathToImgs.at(d1) <<
"' !" << endl);
3637 Cerr(
"***** IntfWriteImage()-> Error occurred while trying to write the image file at the path: '"<< ap_pathToImgs.at(0) <<
"' !" << endl);
3643 if(ap_pathToImgs.size()!=ap_dim[0])
3645 Cerr(
"***** IntfWriteImage()-> Error : number of interfile images ("<< ap_pathToImgs.size() <<
") not consistent with the number of images to load (" << ap_dim[0] <<
") !" << endl);
3649 for(uint32_t d1=0 ; d1<ap_dim[0] ; d1++)
3651 ofstream img_file(ap_pathToImgs.at(d1).append(
".img").c_str(), ios::binary | ios::out);
3656 if(
IntfWriteData(&img_file, a2p_outImgMtx[d1], ap_dim[1], vb) )
3658 Cerr(
"***** IntfWriteImage()-> Error occurred when writing the image file '"<< ap_pathToImgs.at(d1) <<
"' !" << endl);
3664 Cerr(
"***** IntfWriteImage()-> Error occurred while trying to write the image file at the path: '"<< ap_pathToImgs.at(d1) <<
"' !" << endl);
3692 if(vb >= 5)
Cout(
"IntfWriteImage()" << endl);
3694 if(ap_pathToImgs.size() == 1)
3698 ifstream fcheck(ap_pathToImgs.at(0).append(
".img").c_str());
3703 string dos_instruction =
"del " + ap_pathToImgs.at(0);
3704 system(dos_instruction.c_str());
3706 remove(ap_pathToImgs.at(0).c_str());
3711 ofstream img_file(ap_pathToImgs.at(0).c_str(), ios::binary | ios::out | ios::app);
3716 for(uint32_t d1=0 ; d1<ap_dim[0] ; d1++)
3717 for(uint32_t d2=0 ; d2<ap_dim[1] ; d2++)
3718 for(uint32_t d3=0 ; d3<ap_dim[2] ; d3++)
3719 if(
IntfWriteData(&img_file, a4p_outImgMtx[d1][d2][d3], ap_dim[3], vb) )
3721 int idx_img = d1*ap_dim[1]*ap_dim[2] + d2*ap_dim[2] + d3;
3722 Cerr(
"***** IntfWriteImage()-> Error occurred when writing the image file '"<< ap_pathToImgs.at(idx_img) <<
"' !" << endl);
3728 Cerr(
"***** IntfWriteImage()-> Error occurred while trying to write the image file '"<< ap_pathToImgs.at(0) <<
"' !" << endl);
3736 if(ap_pathToImgs.size() != ap_dim[0]*ap_dim[1]*ap_dim[2])
3738 Cerr(
"***** IntfWriteImage()-> Error : number of interfile images (="<< ap_pathToImgs.size()
3739 <<
") not consistent with the number of images to load (="
3740 << ap_dim[0]*ap_dim[1]*ap_dim[2] <<
") !" << endl);
3744 for(uint32_t d1=0 ; d1<ap_dim[0] ; d1++)
3745 for(uint32_t d2=0 ; d2<ap_dim[1] ; d2++)
3746 for(uint32_t d3=0 ; d3<ap_dim[2] ; d3++)
3748 int idx_img = d1*ap_dim[1]*ap_dim[2] + d2*ap_dim[2] + d3;
3749 ofstream img_file(ap_pathToImgs.at(idx_img).append(
".img").c_str(), ios::binary | ios::out);
3754 if(
IntfWriteData(&img_file, a4p_outImgMtx[d1][d2][d3], ap_dim[3], vb) )
3756 Cerr(
"***** IntfWriteImage()-> Error occurred when writing the image file '"<< ap_pathToImgs.at(idx_img) <<
"' !" << endl);
3762 Cerr(
"***** IntfWriteImage()-> Error occurred while trying to write the image file at the path: '"<< ap_pathToImgs.at(idx_img) <<
"' !" << endl);
3791 if(vb >= 5)
Cout(
"IntfWriteData() " << endl);
3795 if (ap_oFile->write(reinterpret_cast<char*>(ap_outImgMatrix), a_nbVox*
sizeof(
FLTNB)) )
3825 for(
int d=0 ; d<7 ; d++)
3827 for(
int d=0 ; d<3 ; d++)
3843 for(
int d=0 ; d<3 ; d++)
3964 Cout(
"// ------ IntfKeyPrintFields ------ // " << endl << endl);
3969 Cout(
"nb_dims : " <<
unsigned(a_IF.
nb_dims) << endl);
3970 for(
int i=0 ; i<7 ; i++)
3971 Cout(
"mtx_size["<<i<<
"] : " << a_IF.
mtx_size[i] << endl);
3972 for(
int i=0 ; i<3 ; i++)
3973 Cout(
"vox_size["<<i<<
"] : " << a_IF.
vox_size[i] << endl);
3987 for(
int i=0 ; i<3 ; i++)
3989 for(
int i=0 ; i<3 ; i++)
3994 Cout(
"image_duration(fr) : " << endl);
3997 Cout(
"pause_duration(fr) : " << endl);
4014 Cout(
"// ------ ------------------ ------ // " << endl << endl);
4038 string intf_sep =
":=";
4041 int pos = a_line.find_first_of(
';',0);
4042 ap_Key->
korig = a_line.substr(0, pos);
4045 pos = ap_Key->
korig.find_first_of(intf_sep);
4048 if (ap_Key->
korig.find(intf_sep) == string::npos)
4049 ap_Key->
korig.append(
":=");
4088 if(ap_Key.
klcase == a_field)
4109 if(ap_Key.
kvalue.find(
"{") != string::npos &&
4110 ap_Key.
kvalue.find(
"}") != string::npos)
4132 string val_str = a_Key.
kvalue;
4134 size_t pos = val_str.find_first_of(
'{')+1;
4136 while (pos < val_str.length())
4138 size_t pos_c = val_str.find_first_of(
",", pos);
4141 if(pos_c == string::npos)
4143 pos_c = val_str.find_first_of(
"}", pos);
4146 Cerr(
"***** IntfKeyGetArrayNbElts-> Error : closing bracket not found in interfile array key : "<< a_Key.
korig <<
" !" << endl);
4157 Cerr(
"***** IntfKeyGetArrayNbElts-> Error : closing bracket not found in interfile array key : "<< a_Key.
korig <<
" !" << endl);
4177 string val_str = ap_Key.
kvalue;
4178 if (val_str ==
"")
return(max);
4180 size_t pos = val_str.find_first_of(
'{')+1;
4182 while (pos < val_str.length())
4184 size_t pos_c = val_str.find_first_of(
",", pos);
4187 if(pos_c == string::npos) pos_c = val_str.find_first_of(
"}", pos);
4191 Cerr(
"***** IntfKeyGetMaxArrayKey()-> An error occured when trying to recover the following value from the array key : "<< val_str.substr(pos,pos_c-pos) <<
" !" << endl);
4195 if (value > max) max = value;
4221 string val_str = a_Key.
kvalue;
4226 Cerr(
"***** IntfKeyGetArrayElts-> Error : Problem reading the following interfile array key : "<< a_Key.
korig <<
" !" << endl);
4232 Cerr(
"***** IntfKeyGetArrayElts-> Error : no elements in the array key : "<< a_Key.
korig <<
" !" << endl);
4236 size_t pos = val_str.find_first_of(
'{')+1;
4240 while (pos < val_str.length())
4242 size_t pos_c = val_str.find_first_of(
",", pos);
4245 if(pos_c == string::npos) pos_c = val_str.find_first_of(
"}", pos);
4249 Cerr(
"***** IntfKeyGetMaxArrayKey()-> An error occured when trying to recover the following value from the array key : "<< val_str.substr(pos,pos_c-pos) <<
" !" << endl);
4279 int dimXY=dimX*dimY;
4282 int z = a_voxId/dimXY;
4283 int y = (a_voxId - z*dimXY) / dimX;
4284 int x = a_voxId - z*dimXY - y*dimX;
4387 a_voxId = X + Y*dimX + Z*dimX*dimY;
4408 if(a_val == 0)
return "BIGENDIAN";
4409 if(a_val == 1)
return "LITTLEENDIAN";
4424 if(a_modalityIdx == 0)
4426 else if(a_modalityIdx == 1)
4453 if (a_str ==
"static")
4455 if (a_str ==
"dynamic")
4457 if (a_str ==
"gated")
4459 if (a_str ==
"tomographic")
4461 if (a_str ==
"gspect")
4521 if (
sizeof(
FLTNB) == 4)
return "short float";
4522 else if (
sizeof(
FLTNB) == 8)
return "long float";
4523 else if (
sizeof(
FLTNB) == 16)
return "long long float";
4526 Cerr(
"***** oInterfileIO::IntfKeyGetPixTypeStr() -> Size of current float type (" <<
sizeof(
FLTNB) <<
") does not correspond to a known type !" << endl);
4643 input_str->erase(0, input_str->find_first_not_of(
" !\t\r\n"));
4644 input_str->erase(input_str->find_last_not_of(
" \t\r\n")+1 , input_str->length());
4662 std::transform(ap_str->begin(), ap_str->end(), ap_str->begin(), ::tolower);
4681 char *buffer =
reinterpret_cast<char*
>(ap_type);
4682 std::reverse(buffer, buffer +
sizeof(T));
#define INTF_SUPINE_FEETIN_CORONAL
static sScannerManager * GetInstance()
Instanciate the singleton object and Initialize member variables if not already done, return a pointer to this object otherwise.
string direction_rotation
template int IntfKeyGetRecurringValueFromFile< uint32_t >(const string &a_pathToHeader, const string &a_key, uint32_t *ap_return, int a_nbElts, int a_mandatoryFlag, uint16_t a_nbOccurrences)
FLTNB GetFrameTimeStartInSec(int a_bed, int a_frame)
Get the frame time start for the given bed, in seconds as a FLTNB.
void IntfKeyInitFields(Intf_fields *ap_IF)
Init the file of an Interfile fields structure passed in parameter to their default values...
template int IntfKeyGetValueFromFile< int >(const string &a_pathToHeader, const string &a_key, int *ap_return, int a_nbElts, int a_mandatoryFlag)
#define INTF_PRONE_HEADIN_CORONAL
FLTNB GetVoxSizeX()
Get the voxel's size along the X axis, in mm.
FLTNB * IntfLoadImageFromScratch(const string &a_pathToHeaderFile, Intf_fields *ap_ImgFields, int vb)
int IntfCheckDimensionsConsistency(Intf_fields ImgFields1, Intf_fields ImgFields2)
template int IntfKeyGetValueFromFile< uint16_t >(const string &a_pathToHeader, const string &a_key, uint16_t *ap_return, int a_nbElts, int a_mandatoryFlag)
int IntfKeyGetValueFromFile(const string &a_pathToHeader, const string &a_key, T *ap_return, int a_nbElts, int a_mandatoryFlag)
Look for "a_nbElts" elts in the "a_pathToHeader" interfile header matching the "a_keyword" key passed...
template int IntfKeyGetRecurringValueFromFile< string >(const string &a_pathToHeader, const string &a_key, string *ap_return, int a_nbElts, int a_mandatoryFlag, uint16_t a_nbOccurrences)
void GetUserEndianness()
Check user/host computer endianness and write it to the global variable User_Endianness.
void IntfKeySetFieldsOutput(Intf_fields *ap_IF, oImageDimensionsAndQuantification *ap_ID)
Init the keys of the Interfile header of an image to be written on disk.
FLTNB GetVoxSizeZ()
Get the voxel's size along the Z axis, in mm.
#define INTF_PRONE_FEETIN_TRANSAXIAL
string IntfKeyGetModalityStr(int a_modalityIdx)
Convert the integer provided in parameter to the string related to the corresponding modality as de...
int ImageInterpolation(FLTNB *ap_iImg, FLTNB *ap_oImg, const uint32_t ap_iDimVox[3], const uint32_t ap_oDimVox[3], const FLTNB ap_iSizeVox[3], const FLTNB ap_oSizeVox[3])
Trilinear interpolation.
#define INTF_PRONE_FEETIN_CORONAL
template int IntfKeyGetRecurringValueFromFile< uint8_t >(const string &a_pathToHeader, const string &a_key, uint8_t *ap_return, int a_nbElts, int a_mandatoryFlag, uint16_t a_nbOccurrences)
template int IntfKeyGetValueFromFile< float >(const string &a_pathToHeader, const string &a_key, float *ap_return, int a_nbElts, int a_mandatoryFlag)
#define INTF_SUPINE_FEETIN_SAGITTAL
int IntfReadImage(const string &a_pathToHeaderFile, FLTNB *ap_ImgMatrix, oImageDimensionsAndQuantification *ap_ID, int vb, bool a_lerpFlag)
Main function dedicated to Interfile 3D image loading.
int IntfKeyGetPatOrientation(Intf_fields ap_IF)
Get the complete patient orientation from an Intf_fields structure according to the values of keys 's...
#define INTF_PRONE_FEETIN_SAGITTAL
template int IntfKeyGetValueFromFile< long double >(const string &a_pathToHeader, const string &a_key, long double *ap_return, int a_nbElts, int a_mandatoryFlag)
vector< FLTNB > frame_group_pause
static sOutputManager * GetInstance()
Instanciate the singleton object and Initialize member variables if not already done, return a pointer to this object otherwise.
int IntfKeyGetRecurringValueFromFile(const string &a_pathToHeader, const string &a_key, T *ap_return, int a_nbElts, int a_mandatoryFlag, uint16_t a_nbOccurrences)
int IntfReadHeader(const string &a_pathToHeaderFile, Intf_fields *ap_IF, int vb)
Read an Interfile header.
template int IntfKeyGetValueFromFile< uint8_t >(const string &a_pathToHeader, const string &a_key, uint8_t *ap_return, int a_nbElts, int a_mandatoryFlag)
template int IntfKeyGetValueFromFile< bool >(const string &a_pathToHeader, const string &a_key, bool *ap_return, int a_nbElts, int a_mandatoryFlag)
int IntfWriteImgFile(const string &a_pathToImg, FLTNB *ap_ImgMatrix, const Intf_fields &ap_IntfF, int vb)
Main function dedicated to Interfile 3D image writing. Recover image information from a provided In...
string GetFileFromPath(const string &a_pathToFile)
Simply return the file from a path string passed in parameter.
#define KEYWORD_MANDATORY_NOT_FOUND
int IntfWriteMHD(const string &a_pathToMhd, const vector< string > &ap_lPathToImgs, Intf_fields a_IntfF, oImageDimensionsAndQuantification *ap_ID, int vb)
Write an Interfile meta header at the path provided in parameter, using the field stack provided in p...
int IntfWriteImageFromIntfFields(const string &a_pathToImg, FLTNB *ap_ImgMatrix, Intf_fields Img_fields, int vb)
int ConvertFromString(const string &a_str, string *a_result)
Copy the 'a_str' string in the position pointed by 'a_result'.
#define INTF_SUPINE_HEADIN_SAGITTAL
FLTNB GetVoxSizeY()
Get the voxel's size along the Y axis, in mm.
string IntfKeyGetEndianStr(int a_val)
return the endian string corresponding to the value passed in parameter (see module INTF_ENDIANNESS)...
int IntfWriteProjFile(const string &a_pathToImg, FLTNB **a2p_ImgMatrix, oImageDimensionsAndQuantification *ap_ID, Intf_fields a_Imgfields, int vb)
Function dedicated to Interfile image writing for projected data.
#define SCANNER_SPECT_CONVERGENT
int IntfReadProjectionImage(const string &a_pathToHeaderFile, FLTNB *ap_ImgMatrix, Intf_fields *ap_IF, int vb, bool a_lerpFlag)
Main function which reads a projection Interfile 3D projection image and store its content in the pro...
int IntfKeyGetOutputImgDataType(oImageDimensionsAndQuantification *ap_ID)
int IntfReadData(Intf_fields a_IF, ifstream *ap_iFile, FLTNB *ap_outImgMatrix, FLTNB *ap_inImgMatrix, uint32_t *a_offset, int a_nbVox, int vb, T *bytes)
Templated function which read an image voxel by voxel and store it in the ap_outImgMtx image matrix...
Singleton class that manages output writing on disk (images, sinograms, etc). It also manages loggi...
template int IntfKeyGetRecurringValueFromFile< double >(const string &a_pathToHeader, const string &a_key, double *ap_return, int a_nbElts, int a_mandatoryFlag, uint16_t a_nbOccurrences)
int IntfKeyGetInputImgDataType(const string &a_str)
Get the image data type corresponding to the image metadata passed in parameter.
template int IntfKeyGetRecurringValueFromFile< float >(const string &a_pathToHeader, const string &a_key, float *ap_return, int a_nbElts, int a_mandatoryFlag, uint16_t a_nbOccurrences)
Singleton class that Instantiate and initialize the scanner object.
FLTNB GetFinalTimeStopInSec(int a_bed)
Get the last frame time stop for the given bed, in seconds as a FLTNB.
int IntfKeyIsArray(Intf_key ap_Key)
Check if the key passed in parameter is an array (contains brackets '{' and '}' ) ...
#define INTF_SUPINE_HEADIN_TRANSAXIAL
int IntfWriteHeaderMainData(const string &a_path, const Intf_fields &ap_IntfF, int vb)
int IntfWriteData(ofstream *ap_oFile, FLTNB *ap_outImgMatrix, int a_nbVox, int vb)
Write the content of the image matrix in the file pointed by ofstream.
int IntfCheckKeyMatch(Intf_key ap_Key, const string &a_field)
Check if the key matches the string passed in parameter.
vScanner * GetScannerObject()
#define INTF_SUPINE_HEADIN_CORONAL
int IntfKeyGetArrayNbElts(Intf_key a_Key)
Return the number of elts in an Interfile array Key.
vector< FLTNB > image_duration
template int IntfKeyGetValueFromFile< uint32_t >(const string &a_pathToHeader, const string &a_key, uint32_t *ap_return, int a_nbElts, int a_mandatoryFlag)
template int IntfKeyGetRecurringValueFromFile< int >(const string &a_pathToHeader, const string &a_key, int *ap_return, int a_nbElts, int a_mandatoryFlag, uint16_t a_nbOccurrences)
void SwapBytes(T *ap_type)
Interfile key elements. This structure is used to recover and process the elements of an Interfile ...
template int IntfKeyGetValueFromFile< string >(const string &a_pathToHeader, const string &a_key, string *ap_return, int a_nbElts, int a_mandatoryFlag)
#define SCANNER_SPECT_PINHOLE
FLTNB GetMultiBedDisplacementInMm()
uint16_t ctr_to_ctr_separation
int IntfIsMHD(string a_pathToFile, vector< string > &ap_lPathToImgs)
Check if the string in argument contains the path to a Interfile metaheader.
string GetPathOfFile(const string &a_pathToFile)
Simply return the path to the directory of a file path string passed in parameter.
int IntfGetVoxIdxSHTOrientation(Intf_fields a_IF, int a_voxId)
Compute a voxel index corresponding to the default orientation (Sup/Hin/Trans) from the orientation...
int GetNbCardGates()
Get the number of cardiac gates.
#define KEYWORD_OPTIONAL_NOT_FOUND
bool MergeDynImages()
Indicate if a dynamic serie of 3D images should be merged in one file (true) or written on disk as on...
int IntfReadImgDynCoeffFile(const string &a_pathToHeaderFile, FLTNB **a2p_ImgMatrix, oImageDimensionsAndQuantification *ap_ID, int a_nbFbases, int vb, bool a_lerpFlag)
Function dedicated to Interfile image reading for dynamic coefficients images.
Interfile fields. This structure contains all the Interfile keys currently managed by CASToR Decl...
FLTNB multiple_bed_displacement
int IntfCheckConsistency(Intf_fields *ap_IF, oImageDimensionsAndQuantification *ap_ID, int vb, int a_lerpFlag)
Check if the mandatory fields have been initialize in the ap_IF structure, and check consistencies wi...
string IntfKeyGetPixTypeStr()
Return the string corresponding to the nb of bytes in the type FLTNB.
int IntfWriteImgDynCoeffFile(const string &a_pathToImg, FLTNB **a2p_ImgMatrix, oImageDimensionsAndQuantification *ap_ID, int a_nbParImgs, int vb)
Function dedicated to Interfile image writing for dynamic coefficients images.
uint16_t nb_detector_heads
FLTNB GetFrameTimeStopInSec(int a_bed, int a_frame)
Get the frame time stop for the given bed, in seconds as a FLTNB.
int IntfWriteHeaderImgData(ofstream &ap_ofile, const Intf_fields &ap_IntfF, int vb)
int IntfKeyGetArrayElts(Intf_key a_Key, T *ap_return)
Get all the elements in an array key in a templated array passed in parameter. It assumes the retur...
int GetNbTimeFrames()
Get the number of time frames.
INTNB GetNbVoxXYZ()
Get the total number of voxels.
#define INTF_SUPINE_FEETIN_TRANSAXIAL
int IntfWriteImage(const string &a_pathToImg, FLTNB *ap_outImgMtx, uint32_t a_dim, int vb)
Write Interfile raw data whose path is provided in parameter, using image matrix provided in paramete...
#define INTF_PRONE_HEADIN_SAGITTAL
This class is designed to manage all dimensions and quantification related stuff. ...
void IntfToLowerCase(string *ap_str)
Set all characters of the string passed in parameter to lower case.
int IntfRecoverKey(Intf_key *ap_Key, const string &a_line)
Process the line passed in parameter and write the key information in the ap_Key Intf_key member stru...
INTNB GetNbVoxX()
Get the number of voxels along the X axis.
This group of functions manages Interfile image file format.
INTNB GetNbVoxZ()
Get the number of voxels along the Z axis.
template int IntfKeyGetValueFromFile< double >(const string &a_pathToHeader, const string &a_key, double *ap_return, int a_nbElts, int a_mandatoryFlag)
int GetNbRespGates()
Get the number of respiratory gates.
uint32_t nb_energy_windows
void IntfEraseSpaces(string *input_str)
Erase space, blank characters ((t,r,n)), and '!' before and after the characters in the string passed...
template int IntfKeyGetRecurringValueFromFile< int64_t >(const string &a_pathToHeader, const string &a_key, int64_t *ap_return, int a_nbElts, int a_mandatoryFlag, uint16_t a_nbOccurrences)
template int IntfKeyGetRecurringValueFromFile< uint16_t >(const string &a_pathToHeader, const string &a_key, uint16_t *ap_return, int a_nbElts, int a_mandatoryFlag, uint16_t a_nbOccurrences)
template int IntfKeyGetRecurringValueFromFile< long double >(const string &a_pathToHeader, const string &a_key, long double *ap_return, int a_nbElts, int a_mandatoryFlag, uint16_t a_nbOccurrences)
FLTNB GetFrameDurationInSec(int a_bed, int a_frame)
Get the frame duration for the given bed, in seconds as a FLTNB.
#define INTF_PRONE_HEADIN_TRANSAXIAL
int IntfKeyGetMaxArrayKey(Intf_key ap_Key)
Return the maximum value from an array key (key value contains brackets '{,,}' )
template int IntfKeyGetRecurringValueFromFile< bool >(const string &a_pathToHeader, const string &a_key, bool *ap_return, int a_nbElts, int a_mandatoryFlag, uint16_t a_nbOccurrences)
void IntfKeyPrintFields(Intf_fields a_IF)
Print all the keys of the Intf_fields structure passed in parameter, as well as their values for debu...
template int IntfKeyGetValueFromFile< int64_t >(const string &a_pathToHeader, const string &a_key, int64_t *ap_return, int a_nbElts, int a_mandatoryFlag)
int IntfGetPixelTypeAndReadData(Intf_fields a_IF, ifstream *ap_iFile, FLTNB *ap_outImgMatrix, FLTNB *ap_inImgMatrix, uint32_t *ap_offset, int a_nbVox, int vb)
The purpose of this function is to call the templated ReadData() function with the data type correspo...
Generic class for scanner objects.
INTNB GetNbVoxY()
Get the number of voxels along the Y axis.
bool FLTNBIsEqual(FLTNB a, FLTNB b, FLTNB a_eps)
Comparison of FLTNB numbers.
void IntfAllocInterpImg(FLTNB **a2p_img, Intf_fields a_IF)
Allocate memory for an image matrix to recover an image to interpolate.
bool is_mtx_size_different
string originating_system