76 FLTNB* p_angles = NULL;
88 Cerr(
"***** iDataFileCT::ReadSpecificInfoInHeader() -> Number of projections should be strictly positive !" << endl);
101 Cout(
" --> Provided projection angles" << endl);
110 Cerr(
"***** iDataFileCT::ReadSpecificInfoInHeader() -> Error while reading optional fields in the header data file !" << endl);
151 m_sizeEvent =
sizeof(uint32_t) + 2*
sizeof(uint32_t);
169 Cerr(
"***** iDataFileCT::ComputeSizeEvent() -> Unknown event mode !" << endl);
176 Cerr(
"***** iDataFileCT::ComputeSizeEvent() -> Error, the Event size in bytes should be >= 0 !" << endl;);
227 Cerr(
"*****iDataFileCT::PrepareDataFile() -> Error while trying to allocate memory for the Event object!" << endl);
246 else Cout(
" --> Correct for blank" << endl);
258 else Cout(
" --> Correct for scatter events" << endl);
276 char* file_position = ap_buffer;
284 event->
SetTimeInMs(*reinterpret_cast<uint32_t*>(file_position));
285 file_position +=
sizeof(uint32_t);
289 event->SetKind(*reinterpret_cast<uint8_t*>(file_position));
290 file_position +=
sizeof(uint8_t);
305 event->SetID1(0, *reinterpret_cast<uint32_t*>(file_position));
306 file_position +=
sizeof(uint32_t);
308 event->SetID2(0, *reinterpret_cast<uint32_t*>(file_position));
309 file_position +=
sizeof(uint32_t);
318 event->
SetTimeInMs(*reinterpret_cast<uint32_t*>(file_position));
319 file_position +=
sizeof(uint32_t);
321 event->SetEventValue(0, *reinterpret_cast<FLTNBDATA*>(file_position));
336 event->SetID1(0, *reinterpret_cast<uint32_t*>(file_position));
337 file_position +=
sizeof(uint32_t);
339 event->SetID2(0, *reinterpret_cast<uint32_t*>(file_position));
340 file_position +=
sizeof(uint32_t);
357 Cout(
"iDataFileCT::DescribeSpecific() -> Here is some specific content of the CT datafile" << endl);
363 else Cout(
" --> Detector rotation is undefined !!!" << endl);
379 Cerr(
"***** iDataFileCT::CheckSpecificParameters() -> Data type should be CT !'" << endl);
385 Cerr(
"***** iDataFileCT::CheckSpecificParameters() -> Number of projections not initialized (should be >0) !" << endl);
391 Cerr(
"***** iDataFileCT::CheckSpecificParameters() -> Projection angles not initialized !" << endl);
408 fstream* p_file =
new fstream(
m_dataFileName.c_str(), ios::binary| ios::in );
410 if (!p_file->is_open())
412 Cerr(
"***** iDataFilePET::CheckFileSizeConsistency() -> Failed to open input file '" <<
m_dataFileName.c_str() <<
"' !" << endl);
417 p_file->seekg(0, ios::end);
418 int64_t sizeInBytes = p_file->tellg();
425 Cerr(
"-------------------------------------------------------------------------------------------------------------------------------------" << endl);
426 Cerr(
"***** iDataFileCT::CheckFileSizeConsistency() -> DataFile size is not consistent with the information provided by the user/datafile !" << endl);
428 Cerr(
" --> Actual size: "<< sizeInBytes << endl << endl);
429 Cerr(
" ADDITIONAL INFORMATION ABOUT THE DATAFILE INITIALIZATION" << endl);
431 else Cerr(
" --> No information about the kind of events in the data" << endl);
433 else Cerr(
" --> No blank correction term in the data" << endl);
435 else Cerr(
" --> No scatter correction term in the data" << endl);
437 Cerr(
"----------------------------------------------------------------------------------------------------------------------------------------" << endl);
457 Cerr(
"***** iDataFileCT::CheckSpecificConsistencyWithAnotherDataFile() -> Event kind flags are inconsistent !" << endl);
463 Cerr(
"***** iDataFileCT::CheckSpecificConsistencyWithAnotherDataFile() -> Blank correction flags are inconsistent !" << endl);
469 Cerr(
"***** iDataFileCT::CheckSpecificConsistencyWithAnotherDataFile() -> Scatter correction flags are inconsistent !" << endl);
475 Cerr(
"***** iDataFileCT::CheckSpecificConsistencyWithAnotherDataFile() -> Data modes are inconsistent (list-mode or histogram) !" << endl);
493 Cerr(
"***** iDataFileCT::InitAngles() -> Number of projection angles not initialized !'" << endl);
530 m_headerFileName = path_name.append(img_name).append(
"_CstrProj").append(
".Cdh");
541 datafile_name.append(
"_").append(ss.str());
543 m2p_dataFile[th] =
new fstream( datafile_name.c_str(), ios::binary | ios::out | ios::trunc);
548 ofstream output_file(
m_dataFileName.c_str(), ios::out | ios::trunc);
570 Cerr(
"*****iDataFileCT::WriteEvent() -> Error while trying to write projection datafile (list-mode)" << endl);
579 Cerr(
"*****iDataFileCT::WriteEvent() -> Error while trying to write projection datafile (histogram)" << endl);
600 m2p_dataFile[a_th]->write(reinterpret_cast<char*>(&time),
sizeof(uint32_t));
614 m2p_dataFile[a_th]->write(reinterpret_cast<char*>(&blank_corr_factor),
sizeof(
FLTNB));
617 uint32_t id1 = ap_Event->
GetID1(0);
618 uint32_t id2 = ap_Event->
GetID2(0);
619 m2p_dataFile[a_th]->write(reinterpret_cast<char*>(&id1),
sizeof(uint32_t));
620 m2p_dataFile[a_th]->write(reinterpret_cast<char*>(&id2),
sizeof(uint32_t));
638 m2p_dataFile[a_th]->write(reinterpret_cast<char*>(&time),
sizeof(uint32_t));
642 uint8_t event_kind = ap_Event->
GetKind();
643 m2p_dataFile[a_th]->write(reinterpret_cast<char*>(&event_kind),
sizeof(uint8_t));
655 m2p_dataFile[a_th]->write(reinterpret_cast<char*>(&blank_corr_factor),
sizeof(
FLTNB));
658 uint32_t id1 = ap_Event->
GetID1(0);
659 uint32_t id2 = ap_Event->
GetID2(0);
660 m2p_dataFile[a_th]->write(reinterpret_cast<char*>(&id1),
sizeof(uint32_t));
661 m2p_dataFile[a_th]->write(reinterpret_cast<char*>(&id2),
sizeof(uint32_t));
679 if (!headerFile.is_open())
681 Cerr(
"***** iDataFileCT::WriteHeader() -> Failed to open output header file '" <<
m_headerFileName <<
"' !" << endl);
687 headerFile <<
"Number of events: " <<
m_nbEvents << endl;
693 headerFile <<
"Data type: CT" << endl;
703 headerFile <<
"Projection angles: " <<
mp_angles[0];
712 headerFile <<
"Scanner rotation direction: " << rot_direction << endl;
730 FLTNB* p_angles = NULL;
734 Cerr(
"*****iDataFileCT::PROJ_GetScannerSpecificParameters() -> An error occurred while trying to get CT geometric parameters from the scanner object !" << endl);
This class is designed to be a mother virtual class for DataFile.
static sScannerManager * GetInstance()
Instanciate the singleton object and Initialize member variables if not already done, return a pointer to this object otherwise.
bool GetScatCorrectionFlag()
Simply return m_scatCorrectionFlag.
#define VERBOSE_DEBUG_EVENT
#define MODE_NORMALIZATION
int GetDetectorRotDirection()
Simply return m_detectorRotDirection.
int InitAngles(FLTNB *ap_angles)
allocate memory for the mp_angles variable using m_nbProjections and initialize the projection angles...
int SetSpecificParametersFrom(vDataFile *ap_DataFile)
Initialize all parameters specific to CT from the provided datafile.
uint32_t GetID2(int a_line)
bool m_blankCorrectionFlag
Inherit from iEventCT. Class for CT list-mode events.
iDataFileCT()
iDataFileCT constructor. Initialize the member variables to their default values. ...
bool m_ignoreScatCorrectionFlag
uint16_t m_nbOfProjections
int ReadSpecificInfoInHeader(bool a_affectQuantificationFlag)
Read through the header file and recover specific CT information.
static sOutputManager * GetInstance()
Instanciate the singleton object and Initialize member variables if not already done, return a pointer to this object otherwise.
Declaration of class iDataFileCT.
bool m_ignoreBlankCorrectionFlag
bool m_scatCorrectionFlag
string GetFileFromPath(const string &a_pathToFile)
Simply return the file from a path string passed in parameter.
int WriteHeader()
Generate a header file according to the data output information.
bool GetIgnoreNormCorrectionFlag()
Get the boolean that says if the normalization correction is ignored or not.
int WriteListEvent(iEventListCT *ap_Event, int a_th)
Write a CT list-mode event.
const string & GetPathName()
int ComputeSizeEvent()
Computation of the size of each event according to the mandatory/optional correction fields...
#define VERBOSE_DEBUG_LIGHT
Singleton class that manages output writing on disk (images, sinograms, etc). It also manages loggi...
vEvent * GetEventSpecific(char *ap_buffer, int a_th)
Read an event from the position pointed by 'ap_buffer', parse the generic or modality-specific inform...
int ReadDataASCIIFile(const string &a_file, const string &a_keyword, T *ap_return, int a_nbElts, bool a_mandatoryFlag)
Look for "a_nbElts" elts in the "a_file" file matching the "a_keyword" string passed as parameter a...
Singleton class that Instantiate and initialize the scanner object.
oImageDimensionsAndQuantification * mp_ID
int PROJ_GetScannerSpecificParameters()
Get SPECT specific parameters for projections from the scanner object, through the scannerManager...
int CheckSpecificParameters()
Check parameters specific to CT data.
void DescribeSpecific()
Implementation of the pure virtual eponym function that simply prints info about the datafile...
Inherit from iEventCT. Class for CT histogram mode events.
int PROJ_InitFile()
Initialize the fstream objets for output writing as well as some other variables specific to the Proj...
bool GetBlankCorrectionFlag()
Simply return m_blankCorrectionFlag.
#define SPEC_TRANSMISSION
bool GetEventKindFlag()
Simply return m_eventKindFlag.
int m_detectorRotDirection
int CheckSpecificConsistencyWithAnotherDataFile(vDataFile *ap_DataFile)
Check consistency between 'this' and the provided datafile, for specific characteristics.
uint16_t GetNbProjections()
const string & GetBaseName()
void SetTimeInMs(uint32_t a_value)
Set the timestamp of the Event.
int WriteEvent(vEvent *ap_Event, int a_th=0)
Write event according to the chosen type of data.
Mother class for the Event objects.
vEvent ** m2p_BufferEvent
Inherit from vDataFile. Class that manages the reading of a CT input file (header + data)...
uint32_t GetID1(int a_line)
int GetNbThreadsForProjection()
Get the number of threads used for projections.
bool GetIgnoreScatCorrectionFlag()
Get the boolean that says if the scatter correction is ignored or not.
#define DEBUG_VERBOSE(IGNORED1, IGNORED2)
FLTNB m_calibrationFactor
~iDataFileCT()
iDataFileCT destructor.
int GetCTSpecificParameters(uint16_t *ap_nbOfProjections, FLTNB *&ap_angles, int *ap_headRotDirection)
Transfer geometric information recovered from the datafile to the scanner object. ...
int WriteHistoEvent(iEventHistoCT *ap_Event, int a_th)
Write a CT histogram event.
int PrepareDataFile()
Store different kind of information inside arrays (data relative to specific correction as well as ba...
int CheckFileSizeConsistency()
This function is implemented in child classes Check if file size is consistent. ...
FLTNB GetEventValue(int a_bin)