CASToR  1.0
Tomographic Reconstruction (PET/SPECT)
Functions | Variables
oInterfileIO.cc File Reference

Implementation of class Interfile management functions. More...

#include "oInterfileIO.hh"
#include <iomanip>

Go to the source code of this file.

Functions

template<class T >
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 as parameter and return the corresponding value(s) in the "ap_return" templated array.
template int IntfKeyGetValueFromFile< string > (const string &a_pathToHeader, const string &a_key, string *ap_return, int a_nbElts, int a_mandatoryFlag)
template int IntfKeyGetValueFromFile< int > (const string &a_pathToHeader, const string &a_key, int *ap_return, int a_nbElts, int a_mandatoryFlag)
template int IntfKeyGetValueFromFile< int64_t > (const string &a_pathToHeader, const string &a_key, int64_t *ap_return, int a_nbElts, int a_mandatoryFlag)
template int IntfKeyGetValueFromFile< float > (const string &a_pathToHeader, const string &a_key, float *ap_return, int a_nbElts, int a_mandatoryFlag)
template int IntfKeyGetValueFromFile< double > (const string &a_pathToHeader, const string &a_key, double *ap_return, int a_nbElts, int a_mandatoryFlag)
template int IntfKeyGetValueFromFile< long double > (const string &a_pathToHeader, const string &a_key, long double *ap_return, int a_nbElts, int a_mandatoryFlag)
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< uint16_t > (const string &a_pathToHeader, const string &a_key, uint16_t *ap_return, int a_nbElts, int a_mandatoryFlag)
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 IntfKeyGetValueFromFile< bool > (const string &a_pathToHeader, const string &a_key, bool *ap_return, int a_nbElts, int a_mandatoryFlag)
template<typename T >
int IntfKeyGetRecurringValueFromFile (const string &a_pathToHeader, const string &a_key, T *ap_return, int a_nbElts, int a_mandatoryFlag, uint16_t a_nbOccurrences)
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)
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)
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< float > (const string &a_pathToHeader, const string &a_key, float *ap_return, int a_nbElts, int a_mandatoryFlag, uint16_t a_nbOccurrences)
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)
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)
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 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< uint32_t > (const string &a_pathToHeader, const string &a_key, uint32_t *ap_return, int a_nbElts, int a_mandatoryFlag, uint16_t a_nbOccurrences)
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)
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 provided ap_ImgMatrix
.
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 IntfReadImage (const string &a_pathToHeaderFile, FLTNB ****a4p_ImgMatrix, oImageDimensionsAndQuantification *ap_ID, int vb, bool a_lerpFlag)
 Main function dedicated to Interfile 5D (1D+1D+1D time + 3D) image loading.
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.
void IntfAllocInterpImg (FLTNB **a2p_img, Intf_fields a_IF)
 Allocate memory for an image matrix to recover an image to interpolate.
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 with the reconstruction parameters.
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 corresponding to the interfile image.
template<class T >
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.
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.
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 Intf_fields structure.
int IntfWriteImgFile (const string &a_pathToImg, FLTNB *ap_ImgMatrix, oImageDimensionsAndQuantification *ap_ID, int vb)
 Main function dedicated to Interfile 3D image writing.
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.
int IntfWriteImgDynCoeffFile (const string &a_pathToImg, FLTNB **a2p_ImgMatrix, oImageDimensionsAndQuantification *ap_ID, int a_nbFbases, int vb)
 Function dedicated to Interfile image writing for dynamic coefficients images.
int IntfWriteImgFile (const string &a_pathToImg, FLTNB ****a4p_ImgMatrix, oImageDimensionsAndQuantification *ap_ID, int vb)
 Main function dedicated to Interfile 6D (dynamic dims + 3D ) image writing.
int IntfIsMHD (string a_pathToFile, vector< string > &ap_lPathToImgs)
 Check if the string in argument contains the path to a Interfile metaheader.
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 parameter.
int IntfReadHeader (const string &a_pathToHeaderFile, Intf_fields *ap_IF, int vb)
 Read an Interfile header.
int IntfWriteHeaderMainData (const string &a_path, const Intf_fields &ap_IntfF, int vb)
int IntfWriteHeaderImgData (ofstream &ap_ofile, const Intf_fields &ap_IntfF, int vb)
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 parameter.
int IntfWriteImage (vector< string > ap_pathToImgs, FLTNB **a2p_outImgMtx, uint32_t ap_dim[2], int vb)
 Write Interfile raw data whose path is provided in parameter, using the image matrix provided in parameter.
int IntfWriteImage (vector< string > ap_pathToImgs, FLTNB ****a4p_outImgMtx, uint32_t ap_dim[4], int vb)
 Write Interfile raw data whose path is provided in parameter, using the image matrix provided in parameter.
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.
void IntfKeyInitFields (Intf_fields *ap_IF)
 Init the file of an Interfile fields structure passed in parameter to their default values.
void IntfKeySetFieldsOutput (Intf_fields *ap_IF, oImageDimensionsAndQuantification *ap_ID)
 Init the keys of the Interfile header of an image to be written on disk.
void IntfKeyPrintFields (Intf_fields a_IF)
 Print all the keys of the Intf_fields structure passed in parameter, as well as their values for debugging purposes.
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 structure.
int IntfCheckKeyMatch (Intf_key ap_Key, const string &a_field)
 Check if the key matches the string passed in parameter.
int IntfKeyIsArray (Intf_key ap_Key)
 Check if the key passed in parameter is an array (contains brackets '{' and '}' )
int IntfKeyGetArrayNbElts (Intf_key a_Key)
 Return the number of elts in an Interfile array Key.
int IntfKeyGetMaxArrayKey (Intf_key ap_Key)
 Return the maximum value from an array key (key value contains brackets '{,,}' )
template<class T >
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 return variable has been instanciated with a correct number of elements.
int IntfGetVoxIdxSHTOrientation (Intf_fields a_IF, int a_voxId)
 Compute a voxel index corresponding to the default orientation (Sup/Hin/Trans)
from the orientation informations contained in the Intf_fields passed in parameter.
string IntfKeyGetEndianStr (int a_val)
 return the endian string corresponding to the value passed in parameter (see module INTF_ENDIANNESS).
string IntfKeyGetModalityStr (int a_modalityIdx)
 Convert the integer provided in parameter to the string related
to the corresponding modality as defined by the scanner objects.
int IntfKeyGetInputImgDataType (const string &a_str)
 Get the image data type corresponding to the image metadata passed in parameter.
int IntfKeyGetOutputImgDataType (oImageDimensionsAndQuantification *ap_ID)
string IntfKeyGetPixTypeStr ()
 Return the string corresponding to the nb of bytes in the type FLTNB.
int IntfKeyGetPatOrientation (Intf_fields ap_IF)
 Get the complete patient orientation from an Intf_fields structure according to the values of keys 'slice orientation', 'patient rotation', and 'patient orientation'.
void GetUserEndianness ()
 Check user/host computer endianness and write it to the global variable User_Endianness.
void IntfEraseSpaces (string *input_str)
 Erase space, blank characters (\(t,r,n)), and '!' before and after the characters in the string passed in parameter.
void IntfToLowerCase (string *ap_str)
 Set all characters of the string passed in parameter to lower case.
template<class T >
void SwapBytes (T *ap_type)

Variables

int User_Endianness = -1

Detailed Description

Implementation of class Interfile management functions.

Definition in file oInterfileIO.cc.


Function Documentation

Check user/host computer endianness and write it to the global variable User_Endianness.

This function should be called once during the initialization step of the algorithm (currently, the singleton initialization)

Definition at line 4442 of file oInterfileIO.cc.

Here is the caller graph for this function:

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.

Parameters:
ap_iImg: Image matrix to interpolate, with dimensions of the original interfile
ap_oImg: Image matrix to recover the interpolated image to the reconstruction dimensions
ap_iDimVox[3]: X,Y,Z dimensions of the image to interpolate
ap_oDimVox[3]: X,Y,Z dimensions for the reconstruction
ap_iSizeVox[3]: X,Y,Z voxel size of the image to interpolate
ap_oSizeVox[3]: X,Y,Z voxel size for the reconstruction
Returns:
0 if success, positive value otherwise.

Definition at line 1130 of file oInterfileIO.cc.

Here is the caller graph for this function:

void IntfAllocInterpImg ( FLTNB **  a2p_img,
Intf_fields  a_IF 
)

Allocate memory for an image matrix to recover an image to interpolate.

Parameters:
ap_img: pointer to 1 dimensional image matrix to recover the image to interpolate
ap_IF: Structure containing the interfile fields read in a interfile header

Definition at line 771 of file oInterfileIO.cc.

Here is the caller graph for this function:

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 with the reconstruction parameters.

Parameters:
Intf_fields*ap_IF : Structure containing the interfile fields read in a interfile header
oImageDimensionsAndQuantification*ap_ImageDimensions : Provide the Image dimensions object containing reconstruction dimensions
intvb : Verbosity level
a_lerpFlag: if true, enable linear interpolation of the image if img dimensions differ from the reconstruction dimensions

This function also checks if the matrix size of the original image is different to the reconstruction matrix size.
In this case a boolean is set up to enable interpolation during image reading

Returns:
0 if success, positive value otherwise.

Definition at line 805 of file oInterfileIO.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int IntfCheckKeyMatch ( Intf_key  ap_Key,
const string &  a_field 
)

Check if the key matches the string passed in parameter.

Parameters:
ap_Key: Structure containing the parsed key components (key, value,..)
a_line: String containing an interfile key
Returns:
1 if success, 0 otherwise (not found).

Definition at line 3904 of file oInterfileIO.cc.

Here is the caller graph for this function:

void IntfEraseSpaces ( string *  input_str)

Erase space, blank characters (\(t,r,n)), and '!' before and after the characters in the string passed in parameter.

Parameters:
string*input_str

Definition at line 4460 of file oInterfileIO.cc.

Here is the caller graph for this function:

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 corresponding to the interfile image.

Parameters:
a_IF: Interfile fields recovered from the header
ap_iFile: Ifstream pointing to an image file
ap_outImgMtx: 3D image matrix with reconstruction dimensions/voxel size
ap_inImgMtx: 3D image matrix with original dimensions/voxel size
ap_offset: Offset indicating the beginning of the data to read in the image file
a_nbVox: A number of voxels in the 3D image matrix with reconstruction dimensions/voxel size
vb: Verbosity level

It uses "number format" and "number of bytes per pixel" fields to identify the correct type
ASCII and bit images NOT supported

Returns:
0 if success, positive value otherwise.

Definition at line 894 of file oInterfileIO.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int IntfGetVoxIdxSHTOrientation ( Intf_fields  a_IF,
int  a_voxId 
)

Compute a voxel index corresponding to the default orientation (Sup/Hin/Trans)
from the orientation informations contained in the Intf_fields passed in parameter.

Parameters:
ap_IF
a_voxId: index of the voxel in a 1-D image vector
Returns:
new voxel index

Definition at line 4095 of file oInterfileIO.cc.

int IntfIsMHD ( string  a_pathToFile,
vector< string > &  ap_lPathToImgs 
)

Check if the string in argument contains the path to a Interfile metaheader.

Parameters:
a_pathToFile: String containing path to an Interfile header
ap_lPathToImgs: pointer to a list of strings containing the path to the different images

Check for '!total number of data sets' key, and the associated image file names
If the file is metaheader, the names of the header files of the images will be returned in ap_lPathToImgs list
It not, the file is a single header, that we add to the list as solo file

Returns:
1 if we have a metaheader,
0 if not,
negative value if error.

Definition at line 2022 of file oInterfileIO.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

template<class T >
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 return variable has been instanciated with a correct number of elements.

Parameters:
ap_Key
T*ap_return : Templated parameter in which the elts will be returned
Returns:
0 if success, positive value otherwise

Definition at line 4038 of file oInterfileIO.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

Return the number of elts in an Interfile array Key.

Parameters:
ap_Key
Returns:
the number of elements in the array key, or negative value if error

Definition at line 3948 of file oInterfileIO.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

string IntfKeyGetEndianStr ( int  a_val)

return the endian string corresponding to the value passed in parameter (see module INTF_ENDIANNESS).

Parameters:
a_val:
Returns:
"BIG_ENDIAN" if 0,
"LITTLE_ENDIAN" if 1,
"UNKNOWN" otherwise

Definition at line 4225 of file oInterfileIO.cc.

Here is the caller graph for this function:

int IntfKeyGetInputImgDataType ( const string &  a_str)

Get the image data type corresponding to the image metadata passed in parameter.

Parameters:
a_str: input string
Returns:
int value corresponding to the image data type (see module INTF_IMG_TYPE).

Definition at line 4270 of file oInterfileIO.cc.

Here is the caller graph for this function:

Return the maximum value from an array key (key value contains brackets '{,,}' )

Parameters:
ap_Key
Returns:
the max value in the array key.

Definition at line 3993 of file oInterfileIO.cc.

Here is the call graph for this function:

string IntfKeyGetModalityStr ( int  a_modalityIdx)

Convert the integer provided in parameter to the string related
to the corresponding modality as defined by the scanner objects.

Parameters:
a_modalityIdx
Returns:
string corresponding to the modality

Definition at line 4241 of file oInterfileIO.cc.

Definition at line 4301 of file oInterfileIO.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

Get the complete patient orientation from an Intf_fields structure according to the values of keys 'slice orientation', 'patient rotation', and 'patient orientation'.

Parameters:
ap_IF
Returns:
int value corresponding to the patient orientation (see module PATIENT_ORIENTATION).

Definition at line 4364 of file oInterfileIO.cc.

Return the string corresponding to the nb of bytes in the type FLTNB.

Returns:
string corresponding to the pixel data type

Definition at line 4337 of file oInterfileIO.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename T >
int IntfKeyGetRecurringValueFromFile ( const string &  a_pathToHeader,
const string &  a_key,
T *  ap_return,
int  a_nbElts,
int  a_mandatoryFlag,
uint16_t  a_nbOccurrences 
)

Definition at line 163 of file oInterfileIO.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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 
)
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 
)
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 
)
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 
)
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< long double > ( const string &  a_pathToHeader,
const string &  a_key,
long double *  ap_return,
int  a_nbElts,
int  a_mandatoryFlag,
uint16_t  a_nbOccurrences 
)
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 
)
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< uint32_t > ( const string &  a_pathToHeader,
const string &  a_key,
uint32_t *  ap_return,
int  a_nbElts,
int  a_mandatoryFlag,
uint16_t  a_nbOccurrences 
)
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<class T >
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 as parameter and return the corresponding value(s) in the "ap_return" templated array.

Parameters:
a_pathToHeader: path to the interfile header
a_key: the key to recover
T*ap_return : template array in which the data will be recovered
inta_nbElts : number of elements to recover
inta_mandatoryFlag : flag indicating if the data to recover if mandatory (true) or optionnal (false)

If more than one elements are to be recovered, the function first check the key has a correct Interfile kay layout (brackets and commas : {,,})
Depending on the mandatoryFlag, the function will return an error (flag > 0) or a warning (flag = 0) if the key is not found

Returns:
0 if success, and positive value otherwise (1 if error, 2 if key not found).

Definition at line 45 of file oInterfileIO.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

template int IntfKeyGetValueFromFile< bool > ( const string &  a_pathToHeader,
const string &  a_key,
bool *  ap_return,
int  a_nbElts,
int  a_mandatoryFlag 
)
template int IntfKeyGetValueFromFile< double > ( const string &  a_pathToHeader,
const string &  a_key,
double *  ap_return,
int  a_nbElts,
int  a_mandatoryFlag 
)
template int IntfKeyGetValueFromFile< float > ( const string &  a_pathToHeader,
const string &  a_key,
float *  ap_return,
int  a_nbElts,
int  a_mandatoryFlag 
)
template int IntfKeyGetValueFromFile< int > ( const string &  a_pathToHeader,
const string &  a_key,
int *  ap_return,
int  a_nbElts,
int  a_mandatoryFlag 
)
template int IntfKeyGetValueFromFile< int64_t > ( const string &  a_pathToHeader,
const string &  a_key,
int64_t *  ap_return,
int  a_nbElts,
int  a_mandatoryFlag 
)
template int IntfKeyGetValueFromFile< long double > ( const string &  a_pathToHeader,
const string &  a_key,
long double *  ap_return,
int  a_nbElts,
int  a_mandatoryFlag 
)
template int IntfKeyGetValueFromFile< string > ( const string &  a_pathToHeader,
const string &  a_key,
string *  ap_return,
int  a_nbElts,
int  a_mandatoryFlag 
)
template int IntfKeyGetValueFromFile< uint16_t > ( const string &  a_pathToHeader,
const string &  a_key,
uint16_t *  ap_return,
int  a_nbElts,
int  a_mandatoryFlag 
)
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 IntfKeyGetValueFromFile< uint8_t > ( const string &  a_pathToHeader,
const string &  a_key,
uint8_t *  ap_return,
int  a_nbElts,
int  a_mandatoryFlag 
)
void IntfKeyInitFields ( Intf_fields ap_IF)

Init the file of an Interfile fields structure passed in parameter to their default values.

Parameters:
ap_IF: Structure containing Interfile keys

Definition at line 3641 of file oInterfileIO.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int IntfKeyIsArray ( Intf_key  ap_Key)

Check if the key passed in parameter is an array (contains brackets '{' and '}' )

Parameters:
ap_Key
Returns:
1 if success, 0 otherwise (not array).

Definition at line 3926 of file oInterfileIO.cc.

Here is the caller graph for this function:

Print all the keys of the Intf_fields structure passed in parameter, as well as their values for debugging purposes.

Parameters:
ap_IF

Definition at line 3781 of file oInterfileIO.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

Init the keys of the Interfile header of an image to be written on disk.

Parameters:
ap_IF: Structure containing Interfile keys
ap_ID: oImageDimensionsAndQuantification object containing additional infos about reconstruction

Init the keys of the Interfile structure passed in parameter for output writing using the ImageDimensions object containing information about the reconstruction

Definition at line 3704 of file oInterfileIO.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

template<class T >
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.

Parameters:
a_IF: Interfile fields recovered from the header
ap_iFile: Ifstream pointing to an image file
ap_outImgMtx: 3D image matrix with reconstruction dimensions/voxel size
ap_inImgMtx: 3D image matrix with original dimensions/voxel size
ap_offset: Offset indicating the beginning of the data to read in the image file
a_nbVox: A number of voxels in the 3D image matrix with reconstruction dimensions/voxel size
vb: Verbosity level
T*bytes : Buffer of templated size, to recover any voxel value

Call an interpolation function if the original image dimensions/voxel sizes are different to the reconstruction dimensions/voxel sizes
Manage endianness and the optionnal calibration with the rescale slope/intercept interfile keys

Returns:
0 if success, positive value otherwise.

Definition at line 1013 of file oInterfileIO.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int IntfReadHeader ( const string &  a_pathToHeaderFile,
Intf_fields ap_IF,
int  vb 
)

Read an Interfile header.

Parameters:
conststring& a_pathToHeaderFile
Intf_fields*ap_IF
intvb : Verbosity level

Initialize all mandatory fields from the Intf_fields structure passed in parameter with the related interfile key from the image interfile header

Returns:
0 if success, positive value otherwise.

Definition at line 2268 of file oInterfileIO.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters:
a_pathToHeaderFile: path to the header file
ap_ImgMatrix: 1 dimensional image matrix which will recover the image.
ap_ID: Provide the Image dimensions object containing reconstruction dimensions
vb: Verbosity level
a_lerpFlag: if true, enable linear interpolation of the image if img dimensions differ from the reconstruction dimensions

Call the main functions dedicated to Interfile reading : IntfReadHeader(), IntfCheckConsistency(), then IntfReadImage()

Returns:
0 if success, positive value otherwise.

Definition at line 365 of file oInterfileIO.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int IntfReadImage ( const string &  a_pathToHeaderFile,
FLTNB ****  a4p_ImgMatrix,
oImageDimensionsAndQuantification ap_ID,
int  vb,
bool  a_lerpFlag 
)

Main function dedicated to Interfile 5D (1D+1D+1D time + 3D) image loading.

Parameters:
a_pathToHeaderFile: path to the main header file
a4p_ImgMatrix: 4 dimensional image matrix which will recover the image.
ap_ID: Provide the Image dimensions object containing reconstruction dimensions
vb: Verbosity level
a_lerpFlag: if true, enable linear interpolation of the image if img dimensions differ from the reconstruction dimensions

Check is the main header file is a metaheader associated to several image files, or a unique interfile header
Depending on the type of file input (metaheader or unique file), read the group of image files or the unique provided image file

Returns:
0 if success, positive value otherwise.

Definition at line 439 of file oInterfileIO.cc.

Here is the call graph for this function:

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.

Parameters:
a_pathToHeaderFile: path to the header file
a2p_ImgMatrix: 2 dimensional image matrix which will recover the image..
ap_ID: Provide the Image dimensions object containing reconstruction dimensions
a_nbFbases: Number of basis functions
vb: verbosity
a_lerpFlag: if true, enable linear interpolation of the image if img dimensions differ from the reconstruction dimensions

The total number of basis functions should be provided in parameters
Check is the main header file is a metaheader associated to several image files, or a unique interfile header
Depending on the type of file input (metaheader or unique file), read the group of image files or the unique provided image file

Returns:
0 if success, positive value otherwise.

Definition at line 623 of file oInterfileIO.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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 provided ap_ImgMatrix
.

Parameters:
a_pathToHeaderFile: path to the header file
ap_ImgMatrix: 1 dimensional image matrix which will recover the image.
ap_IF: Intf_fields structure containing image metadata
vb: Verbosity level
a_lerpFlag: if true, enable linear interpolation of the image if img dimensions differ from the reconstruction dimensions

Call the main functions dedicated to Interfile reading : IntfReadHeader(), and IntfReadImage()

Returns:
0 if success, positive value otherwise.

Definition at line 297 of file oInterfileIO.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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 structure.

Parameters:
ap_Key: Structure to recover the parsed key components (key, value,..)
a_line: String to process

.korig : Get original line without comments
.kcase : Get key without spaces and without comments
.klcase: Same as kcase, in lower case
.kvalue: Value of the key, without spaces

Returns:
0 if success, positive value otherwise.

Definition at line 3855 of file oInterfileIO.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

void IntfToLowerCase ( string *  ap_str)

Set all characters of the string passed in parameter to lower case.

Parameters:
string*ap_str : original string

Definition at line 4479 of file oInterfileIO.cc.

Here is the caller graph for this function:

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.

Parameters:
ap_oFile: Ofstream pointing to an image file
ap_outImgMtx: 3D image matrix with reconstruction dimensions/voxel size containing the image data
a_nbVox: A number of voxels in the 3D image matrix with reconstruction dimensions/voxel size
vb: Verbosity level
Returns:
0 if success, positive value otherwise.

Definition at line 3614 of file oInterfileIO.cc.

Here is the caller graph for this function:

int IntfWriteHeaderImgData ( ofstream &  ap_ofile,
const Intf_fields ap_IntfF,
int  vb 
)

Definition at line 3302 of file oInterfileIO.cc.

Here is the caller graph for this function:

int IntfWriteHeaderMainData ( const string &  a_path,
const Intf_fields ap_IntfF,
int  vb 
)

Definition at line 3098 of file oInterfileIO.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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 parameter.

Parameters:
a_pathToImg: th to the directory where the image will be written
ap_outImgMtx: Matrix containing the image to write
a_dim: Number of voxels in the 3D image
vb: Verbosity level For 1 dimensional image matrices
Returns:
0 if success, positive value otherwise.

Definition at line 3386 of file oInterfileIO.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int IntfWriteImage ( vector< string >  ap_pathToImgs,
FLTNB **  a2p_outImgMtx,
uint32_t  ap_dim[2],
int  vb 
)

Write Interfile raw data whose path is provided in parameter, using the image matrix provided in parameter.

Parameters:
ap_pathToImgs,:List of string containing the paths to the image to write
a2p_outImgMtx: 2 dimensional image matrix (1D temporal + 3D)
ap_imgDim[2]: Dimensions of ap_outImgMtx
vb: Verbosity level For 2 dimensional image matrices
Returns:
0 if success, positive value otherwise.

Definition at line 3427 of file oInterfileIO.cc.

Here is the call graph for this function:

int IntfWriteImage ( vector< string >  ap_pathToImgs,
FLTNB ****  a4p_outImgMtx,
uint32_t  ap_dim[4],
int  vb 
)

Write Interfile raw data whose path is provided in parameter, using the image matrix provided in parameter.

Parameters:
vector<string>ap_pathToImgs: List of string containing the paths to the image to write
FLTNB****a4p_outImgMtx : 4 dimensional image matrix (3D temporal + 3D)
intap_imgDim[4] : Dimensions of ap_outImgMtx
intvb : Verbosity level For 4 dimensional image matrices
Returns:
0 if success, positive value otherwise.

Definition at line 3515 of file oInterfileIO.cc.

Here is the call graph for this function:

int IntfWriteImgDynCoeffFile ( const string &  a_pathToImg,
FLTNB **  a2p_ImgMatrix,
oImageDimensionsAndQuantification ap_ID,
int  a_nbFbases,
int  vb 
)

Function dedicated to Interfile image writing for dynamic coefficients images.

Parameters:
a_pathToImg: string containing the path to the image basename
a2p_ImgMatrix: 2 dimensional image matrix which contains the image to write.
ap_ID: Provide the Image dimensions object containing reconstruction dimensions
a_nbFbases: Number of basis functions
vb: verbosity

Call the main functions dedicated to Interfile header and data writing
The total number of basis functions should be provided in parameters
Depending on the output writing mode (stored in sOutputManager),
One image with one file and one will be created for the whole dynamic image
or a metaheader and associated multiple 3D image raw file/headers will be generated

Returns:
0 if success, positive value otherwise.

Definition at line 1701 of file oInterfileIO.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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 Intf_fields structure.

Parameters:
a_pathToImg: path to image basename
ap_ImgMatrix: 1 dimensional image matrix which contains the image to write
ap_IntfF: Intf_fields structure containing image metadata
vb: verbosity

Call the main functions dedicated to Interfile header and data writing : IntfWriteHeaderMainData() and then IntfWriteImage()

Returns:
0 if success, positive value otherwise.

Definition at line 1553 of file oInterfileIO.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int IntfWriteImgFile ( const string &  a_pathToImg,
FLTNB ap_ImgMatrix,
oImageDimensionsAndQuantification ap_ID,
int  vb 
)

Main function dedicated to Interfile 3D image writing.

Parameters:
a_pathToImg: path to image basename
ap_ImgMatrix: 1 dimensional image matrix which contains the image to write
ap_ID: Provide the Image dimensions object containing reconstruction dimensions
vb: verbosity

Call the main functions dedicated to Interfile header and data writing :
IntfWriteHeaderMainData() and then IntfWriteImage()

Returns:
0 if success, positive value otherwise.

Definition at line 1597 of file oInterfileIO.cc.

Here is the call graph for this function:

int IntfWriteImgFile ( const string &  a_pathToImg,
FLTNB ****  a4p_ImgMatrix,
oImageDimensionsAndQuantification ap_ID,
int  vb 
)

Main function dedicated to Interfile 6D (dynamic dims + 3D ) image writing.

Parameters:
a_pathToImg: string containing the path to the image basename
a4p_ImgMatrix: 4 dimensional image matrix which contains the image to write.
ap_ID: Provide the Image dimensions object containing reconstruction dimensions
vb: verbosity

Call the main functions dedicated to Interfile header and data writing
Depending on the output writing mode (stored in sOutputManager),
One image with one file and one will be created for the whole dynamic image
or a metaheader and associated multiple 3D image raw file/headers will be generated

Returns:
0 if success, positive value otherwise.

Definition at line 1819 of file oInterfileIO.cc.

Here is the call graph for this function:

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 parameter.

Parameters:
a_path: path to the Meta interfile header to write
ap_lPathToImgs: pointer to a list of strings containing the path to the different images
a_IntfF: Structure containing interfile keys of the image to write
ap_ID: oImageDimensionsAndQuantification object containing additional infos about reconstruction
vb: verbosity
Returns:
0 if success, positive value otherwise.

Definition at line 2183 of file oInterfileIO.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters:
a_pathToImg: string containing the path to the image basename
a2p_ImgMatrix: 2 dimensional image matrix which contains the image to write.
ap_ID: Provide the Image dimensions object containing reconstruction dimensions
a_Imgfields,:Structure containing information about the projected data
vb: verbosity

Call the main functions dedicated to Interfile header and data writing
Currently work for SPECT projected data
The total number of projections should be provided in parameters
Depending on the output writing mode (stored in sOutputManager),

Returns:
0 if success, positive value otherwise.

Definition at line 1647 of file oInterfileIO.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

template<class T >
void SwapBytes ( T *  ap_type)

Definition at line 4498 of file oInterfileIO.cc.


Variable Documentation

int User_Endianness = -1

Global variable recovering endianness of user system

Definition at line 22 of file oInterfileIO.cc.

 All Classes Files Functions Variables Typedefs Defines