9 #ifndef OINTERFILEIO_HH 10 #define OINTERFILEIO_HH 1 13 #include "sScannerManager.hh" 33 #define INTF_BIG_ENDIAN 0 35 #define INTF_LITTLE_ENDIAN 1 46 #define INTF_IMG_STATIC 0 48 #define INTF_IMG_DYNAMIC 1 50 #define INTF_IMG_PET 2 52 #define INTF_IMG_SPECT 3 54 #define INTF_IMG_GATED 4 56 #define INTF_IMG_GSPECT 5 58 #define INTF_IMG_UNKNOWN 6 74 #define INTF_LERP_DISABLED false 76 #define INTF_LERP_ENABLED true 91 #define UINT32_str "unsigned integer" 93 #define INT32_str "signed integer" 95 #define FLT32_str "short float" 96 #define FLT32_str2 "float" 98 #define FLT64_str "long float" 100 #define LONGDOUBLE_str "long long float" 102 #define ASCII_str "ASCII" 114 #define INTF_SUPINE_HEADIN_TRANSAXIAL 0 116 #define INTF_SUPINE_HEADIN_SAGITTAL 1 118 #define INTF_SUPINE_HEADIN_CORONAL 2 120 #define INTF_SUPINE_FEETIN_TRANSAXIAL 3 122 #define INTF_SUPINE_FEETIN_SAGITTAL 4 124 #define INTF_SUPINE_FEETIN_CORONAL 5 126 #define INTF_PRONE_HEADIN_TRANSAXIAL 6 128 #define INTF_PRONE_HEADIN_SAGITTAL 7 130 #define INTF_PRONE_HEADIN_CORONAL 8 132 #define INTF_PRONE_FEETIN_TRANSAXIAL 9 134 #define INTF_PRONE_FEETIN_SAGITTAL 10 136 #define INTF_PRONE_FEETIN_CORONAL 11 150 #define INTF_TRANSVERSE 0 152 #define INTF_CORONAL 1 154 #define INTF_SAGITTAL 2 170 #define INTF_SUPINE 0 186 #define INTF_HEADIN 0 188 #define INTF_FEETIN 1 237 uint32_t mtx_size[7];
295 uint32_t cmtx_size[3];
378 #include "gVariables.hh" 379 #include "sOutputManager.hh" 380 #include "gOptions.hh" 397 template <
typename T>
int IntfKeyGetValueFromFile(
const string& a_pathToHeader,
const string& a_key, T* ap_return,
int a_nbElts,
int a_mandatoryFlag);
413 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);
501 FLTNB**** a4p_ImgMatrix,
521 FLTNB** a2p_ImgMatrix,
562 FLTNB* ap_outImgMatrix,
563 FLTNB* ap_inImgMatrix,
588 FLTNB* ap_outImgMatrix,
589 FLTNB* ap_inImgMatrix,
610 const uint32_t ap_iDimVox[3],
const uint32_t ap_oDimVox[3],
611 const FLTNB ap_iSizeVox[3],
const FLTNB ap_oSizeVox[3],
612 const FLTNB ap_iOffVox[3],
const FLTNB ap_oOffVox[3] );
722 int IntfWriteImage(
const string& a_pathToImg,
FLTNB* ap_outImgMtx, uint32_t a_dim,
int vb);
734 int IntfWriteImage(vector<string> ap_pathToImgs,
FLTNB** a2p_outImgMtx, uint32_t ap_dim[2],
int vb);
746 int IntfWriteImage(vector<string> ap_pathToImgs,
FLTNB**** a4p_outImgMtx, uint32_t ap_dim[4],
int vb);
786 int IntfIsMHD(
string a_pathToFile, vector<string> &ap_lPathToImgs);
1041 template <
class Type>
void SwapBytes(Type *ap_type);
void IntfKeySetFieldsOutput(Intf_fields *ap_IF, oImageDimensionsAndQuantification *ap_ID)
Init the keys of the Interfile header of an image to be written on disk.
string direction_rotation
int IntfWriteImgDynCoeffFile(const string &a_pathToImg, FLTNB **a2p_ImgMatrix, oImageDimensionsAndQuantification *ap_ID, int a_nbParImgs, int vb, bool a_mergeDynImgFlag=false)
void IntfAllocInterpImg(FLTNB **a2p_img, Intf_fields a_IF)
Allocate memory for an image matrix to recover an image to interpolate.
int IntfKeyGetPatOrientation(Intf_fields ap_IF)
Get the complete patient orientation from an Intf_fields structure according to the values of keys 's...
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 IntfKeyGetInputImgDataType(const string &a_str)
Get the image data type corresponding to the image metadata passed in parameter.
int IntfIsMHD(string a_pathToFile, vector< string > &ap_lPathToImgs)
Check if the string in argument contains the path to a Interfile metaheader.
string IntfKeyGetModalityStr(int a_modalityIdx)
Convert the integer provided in parameter to the string related to the corresponding modality as de...
int IntfKeyGetArrayNbElts(Intf_key ap_Key)
Return the number of elts in an Interfile array Key.
int IntfWriteHeaderMainData(const string &a_path, const Intf_fields &ap_IntfF, int vb)
void SwapBytes(Type *ap_type)
Use std::reverse to swap the bits of a variable of any type.
FLTNB bed_relative_position
void IntfToLowerCase(string *ap_str)
Set all characters of the string passed in parameter to lower case.
int IntfKeyGetOutputImgDataType(oImageDimensionsAndQuantification *ap_ID)
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...
vector< FLTNB > frame_group_pause
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...
vector< FLTNB > image_start_time
string IntfKeyGetPixTypeStr()
Return the string corresponding to the nb of bytes in the type FLTNB.
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...
void IntfEraseSpaces(string *input_str)
Erase space, blank characters ((t,r,n)), and '!' before and after the characters in the string passed...
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 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 IntfWriteImageFromIntfFields(const string &a_pathToImg, FLTNB *ap_ImgMatrix, Intf_fields Img_fields, int vb)
int IntfCheckKeyMatch(Intf_key a_Key, const string &a_field)
Check if the key matches the string passed in parameter.
int IntfWriteContentOfInputDataHeaderIntoInterfileHeader(ofstream &ap_ofile, int vb)
int IntfCheckDimensionsConsistency(Intf_fields ImgFields1, Intf_fields ImgFields2)
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...
int IntfWriteWholeDynBasisCoeffImgFile(const string &a_pathToImg, FLTNB ****a4p_ImgMatrix, oImageDimensionsAndQuantification *ap_ID, int vb)
Main function dedicated to Interfile 6D (dynamic dims + 3D ) image writing of basis function coeffici...
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...
bool bed_position_provided
string IntfKeyGetPatientNameTag()
Recover datafile name(s) stored in sOutputManager in one string.
int IntfGetVoxIdxSHTOrientation(Intf_fields a_IF, int a_voxId)
Compute a voxel index corresponding to the default orientation (Sup/Hin/Trans) from the orientation...
void IntfKeyInitFields(Intf_fields *ap_IF)
Init the file of an Interfile fields structure passed in parameter to their default values...
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 key elements. This structure is used to recover and process the elements of an Interfile ...
uint16_t ctr_to_ctr_separation
int IntfKeyIsArray(Intf_key ap_Key)
Check if the key passed in parameter is an array (contains brackets '{' and '}' ) ...
Interfile fields. This structure contains all the Interfile keys currently managed by CASToR Decl...
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 GetUserEndianness()
Check user/host computer endianness and write it to the global variable User_Endianness.
FLTNB * IntfLoadImageFromScratch(const string &a_pathToHeaderFile, Intf_fields *ap_ImgFields, int vb)
uint16_t nb_detector_heads
int IntfKeyGetRecurringValueFromFile(const string &a_pathToHeader, const string &a_key, T *ap_return, int a_nbElts, int a_mandatoryFlag, uint16_t a_nbOccurrences)
vector< FLTNB > image_duration
int IntfGetPixelTypeAndReadData(Intf_fields a_IF, ifstream *ap_iFile, FLTNB *ap_outImgMatrix, FLTNB *ap_inImgMatrix, uint32_t *a_offset, int a_nbVox, int vb)
The purpose of this function is to call the templated ReadData() function with the data type correspo...
int IntfWriteHeaderImgData(ofstream &ap_ofile, const Intf_fields &ap_IntfF, int vb)
This class is designed to manage all dimensions and quantification related stuff. ...
Declaration of class oImageDimensionsAndQuantification.
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], const FLTNB ap_iOffVox[3], const FLTNB ap_oOffVox[3])
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...
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.
uint32_t nb_energy_windows
uint32_t nb_img_in_frame_groups
int IntfReadHeader(const string &a_pathToHeaderFile, Intf_fields *ap_IntfFields, int vb)
Read an Interfile header.
int IntfKeyGetMaxArrayKey(Intf_key ap_Key)
Return the maximum value from an array key (key value contains brackets '{,,}' )
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...
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...
bool is_mtx_size_different
string originating_system