75 FLTNB* p_angles = NULL;
87 Cerr(
"***** iDataFileCT::ReadSpecificInfoInHeader() -> Number of projections should be strictly positive !" << endl);
100 Cout(
" --> Provided projection angles" << endl);
109 Cerr(
"***** iDataFileCT::ReadSpecificInfoInHeader() -> Error while reading optional fields in the header data file !" << endl);
150 m_sizeEvent =
sizeof(uint32_t) + 2*
sizeof(uint32_t);
168 Cerr(
"***** iDataFileCT::ComputeSizeEvent() -> Unknown event mode !" << endl);
175 Cerr(
"***** iDataFileCT::ComputeSizeEvent() -> Error, the Event size in bytes should be >= 0 !" << endl;);
226 Cerr(
"*****iDataFileCT::PrepareDataFile() -> Error while trying to allocate memory for the Event object!" << endl);
245 else Cout(
" --> Correct for blank" << endl);
257 else Cout(
" --> Correct for scatter events" << endl);
275 char* file_position = ap_buffer;
283 event->
SetTimeInMs(*reinterpret_cast<uint32_t*>(file_position));
284 file_position +=
sizeof(uint32_t);
288 event->SetKind(*reinterpret_cast<uint8_t*>(file_position));
289 file_position +=
sizeof(uint8_t);
304 event->SetID1(0, *reinterpret_cast<uint32_t*>(file_position));
305 file_position +=
sizeof(uint32_t);
307 event->SetID2(0, *reinterpret_cast<uint32_t*>(file_position));
308 file_position +=
sizeof(uint32_t);
317 event->
SetTimeInMs(*reinterpret_cast<uint32_t*>(file_position));
318 file_position +=
sizeof(uint32_t);
320 event->SetEventValue(0, *reinterpret_cast<FLTNBDATA*>(file_position));
335 event->SetID1(0, *reinterpret_cast<uint32_t*>(file_position));
336 file_position +=
sizeof(uint32_t);
338 event->SetID2(0, *reinterpret_cast<uint32_t*>(file_position));
339 file_position +=
sizeof(uint32_t);
356 Cout(
"iDataFileCT::DescribeSpecific() -> Here is some specific content of the CT datafile" << endl);
362 else Cout(
" --> Detector rotation is undefined !!!" << endl);
378 Cerr(
"***** iDataFileCT::CheckSpecificParameters() -> Data type should be CT !'" << endl);
384 Cerr(
"***** iDataFileCT::CheckSpecificParameters() -> Number of projections not initialized (should be >0) !" << endl);
390 Cerr(
"***** iDataFileCT::CheckSpecificParameters() -> Projection angles not initialized !" << endl);
407 fstream* p_file =
new fstream(
m_dataFileName.c_str(), ios::binary| ios::in );
409 if (!p_file->is_open())
411 Cerr(
"***** iDataFilePET::CheckFileSizeConsistency() -> Failed to open input file '" <<
m_dataFileName.c_str() <<
"' !" << endl);
416 p_file->seekg(0, ios::end);
417 int64_t sizeInBytes = p_file->tellg();
424 Cerr(
"-------------------------------------------------------------------------------------------------------------------------------------" << endl);
425 Cerr(
"***** iDataFileCT::CheckFileSizeConsistency() -> DataFile size is not consistent with the information provided by the user/datafile !" << endl);
427 Cerr(
" --> Actual size: "<< sizeInBytes << endl << endl);
428 Cerr(
" ADDITIONAL INFORMATION ABOUT THE DATAFILE INITIALIZATION" << endl);
430 else Cerr(
" --> No information about the kind of events in the data" << endl);
432 else Cerr(
" --> No blank correction term in the data" << endl);
434 else Cerr(
" --> No scatter correction term in the data" << endl);
436 Cerr(
"----------------------------------------------------------------------------------------------------------------------------------------" << endl);
456 Cerr(
"***** iDataFileCT::CheckSpecificConsistencyWithAnotherDataFile() -> Event kind flags are inconsistent !" << endl);
462 Cerr(
"***** iDataFileCT::CheckSpecificConsistencyWithAnotherDataFile() -> Blank correction flags are inconsistent !" << endl);
468 Cerr(
"***** iDataFileCT::CheckSpecificConsistencyWithAnotherDataFile() -> Scatter correction flags are inconsistent !" << endl);
474 Cerr(
"***** iDataFileCT::CheckSpecificConsistencyWithAnotherDataFile() -> Data modes are inconsistent (list-mode or histogram) !" << endl);
492 Cerr(
"***** iDataFileCT::InitAngles() -> Number of projection angles not initialized !'" << endl);
540 datafile_name.append(
"_").append(ss.str());
542 m2p_dataFile[th] =
new fstream( datafile_name.c_str(), ios::binary | ios::out | ios::trunc);
547 ofstream output_file(
m_dataFileName.c_str(), ios::out | ios::trunc);
569 Cerr(
"*****iDataFileCT::WriteEvent() -> Error while trying to write projection datafile (list-mode)" << endl);
578 Cerr(
"*****iDataFileCT::WriteEvent() -> Error while trying to write projection datafile (histogram)" << endl);
599 m2p_dataFile[a_th]->write(reinterpret_cast<char*>(&time),
sizeof(uint32_t));
616 uint32_t id1 = ap_Event->
GetID1(0);
617 uint32_t id2 = ap_Event->
GetID2(0);
618 m2p_dataFile[a_th]->write(reinterpret_cast<char*>(&id1),
sizeof(uint32_t));
619 m2p_dataFile[a_th]->write(reinterpret_cast<char*>(&id2),
sizeof(uint32_t));
637 m2p_dataFile[a_th]->write(reinterpret_cast<char*>(&time),
sizeof(uint32_t));
641 uint8_t event_kind = ap_Event->
GetKind();
642 m2p_dataFile[a_th]->write(reinterpret_cast<char*>(&event_kind),
sizeof(uint8_t));
657 uint32_t id1 = ap_Event->
GetID1(0);
658 uint32_t id2 = ap_Event->
GetID2(0);
659 m2p_dataFile[a_th]->write(reinterpret_cast<char*>(&id1),
sizeof(uint32_t));
660 m2p_dataFile[a_th]->write(reinterpret_cast<char*>(&id2),
sizeof(uint32_t));
678 if (!headerFile.is_open())
680 Cerr(
"***** iDataFileCT::WriteHeader() -> Failed to open output header file '" <<
m_headerFileName <<
"' !" << endl);
686 headerFile <<
"Number of events: " <<
m_nbEvents << endl;
692 headerFile <<
"Data type: CT" << endl;
702 headerFile <<
"Projection angles: " <<
mp_angles[0];
711 headerFile <<
"Scanner rotation direction: " << rot_direction << endl;
729 FLTNB* p_angles = NULL;
733 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)