104 int a_rmCorrFlag,
int a_cmCorrFlag,
int a_dmCorrFlag,
int a_pmCorrFlag)
171 Cerr(
"***** oDynamicDataManager::InitDynamicData() -> Respiratory motion correction is enabled for cardiac-gated data. This is not supported in the current implementation !" << endl);
178 Cerr(
"***** oDynamicDataManager::InitDynamicData() -> Involuntary patient image-based motion correction cannot be used along with respiratory or cardiac motion correction !" << endl);
183 if ( (a_rmCorrFlag + a_cmCorrFlag + a_dmCorrFlag) >1 )
185 Cerr(
"***** oDynamicDataManager::InitDynamicData() -> Incorrect image-based motion initialization."<<endl);
186 Cerr(
"***** Please use -rm for respiratory motion, -cm for cardiac motion, or -dm for double respiratory and cardiac motion correction !" << endl);
196 if(
m_verbose>=
VERBOSE_DETAIL)
Cout(
"oDynamicDataManager::InitDynamicData() -> Initializing data for gated reconstruction... " << endl);
200 Cerr(
"***** oDynamicDataManager::InitDynamicData() -> A problem occured during the dynamic gating initialization !" << endl);
208 Cerr(
"***** oDynamicDataManager::InitDynamicData() -> A problem occured during the patient involuntary motion correction initialization !" << endl);
215 if (
m_respGatingFlag)
Cout(
"oDynamicDataManager::InitDynamicData() -> Respiratory gating enabled" << endl);
216 if (
m_rMotionCorrFlag)
Cout(
"oDynamicDataManager::InitDynamicData() -> Respiratory image-based motion correction enabled" << endl);
217 if (
m_cardGatingFlag)
Cout(
"oDynamicDataManager::InitDynamicData() -> Cardiac gating enabled" << endl);
218 if (
m_cMotionCorrFlag)
Cout(
"oDynamicDataManager::InitDynamicData() -> Cardiac image-based motion correction enabled" << endl);
219 if (
m_pMotionCorrFlag)
Cout(
"oDynamicDataManager::InitDynamicData() -> Involuntary image-based patient motion correction enabled" << endl);
242 "respiratory_gates_data_splitting",
248 Cerr(
"***** oDynamicDataManager::InitDynamicDataGating() -> Error while trying to read 'respiratory_gates_data_splitting' in file '" << a_pathToFile <<
"' !" << endl);
253 uint64_t event_number_sum = 0;
270 "cardiac_gates_data_splitting",
276 Cerr(
"***** oDynamicDataManager::InitDynamicDataGating() -> Error while trying to read 'cardiac_gates_data_splitting' in file '" << a_pathToFile <<
"' !" << endl);
280 uint64_t event_number_sum = 0;
309 "nb_involuntary_motion_triggers",
314 Cerr(
"***** oDynamicDataManager::InitDynamicDataPatientMotion() -> Involuntary motion correction enabled but"
315 <<
" number of triggers could not be found in the dynamic file '" << a_pathToFile <<
"' !" << endl);
330 "list_involuntary_motion_triggers",
335 Cerr(
"***** oDynamicDataManager::InitDynamicDataPatientMotion() -> Involuntary motion correction enabled but list of triggers"
336 <<
" not found in the dynamic file '" << a_pathToFile <<
"' !" << endl);
355 if(fr >= m_nbTimeFrames)
359 if(fr<m_nbTimeFrames)
385 uint64_t total_events_in_frame = 0;
392 if (
m_verbose>=
VERBOSE_DETAIL)
Cout(
" Frame #" << fr <<
", cardiac gate #" << g <<
" = " << a2p_quantificationFactors[fr][g] << endl);
399 uint64_t total_events_in_frame = 0;
405 int rg = int(g/m_nbCardGates);
426 if (
m_verbose>=
VERBOSE_DETAIL)
Cout(
"oDynamicDataManager::CheckParameters() -> Check parameters for dynamic data settings" << endl);
430 Cerr(
"***** oDynamicDataManager::CheckParameters() -> No image dimensions provided !" << endl);
436 Cerr(
"***** oDynamicDataManager::CheckParameters() -> Wrong number of time frames !" << endl);
442 Cerr(
"***** oDynamicDataManager::CheckParameters() -> Wrong number of respiratory gates !" << endl);
448 Cerr(
"***** oDynamicDataManager::CheckParameters() -> Wrong number of respiratory gates !" << endl);
454 Cerr(
"***** oDynamicDataManager::CheckParameters() -> Wrong number of involuntary motion subsets provided !" << endl);
460 Cerr(
"***** oDynamicDataManager::CheckParameters() -> Wrong verbosity level provided !" << endl);
467 if (
m_respGatingFlag)
Cout(
"oDynamicDataManager::CheckParameters() -> Respiratory gating is enabled" << endl);
468 if (
m_rMotionCorrFlag)
Cout(
"oDynamicDataManager::CheckParameters() -> Respiratory motion correction enabled" << endl);
469 if (
m_cardGatingFlag)
Cout(
"oDynamicDataManager::CheckParameters() -> Cardiac gating is enabled" << endl);
470 if (
m_cMotionCorrFlag)
Cout(
"oDynamicDataManager::CheckParameters() -> Cardiac motion correction is enabled" << endl);
471 if (
m_pMotionCorrFlag)
Cout(
"oDynamicDataManager::CheckParameters() -> Involuntary motion correction is enabled" << endl);
481 Cerr(
"***** oDynamicDataManager::CheckParameters() -> Problem while checking consistency of dynamic data !" << endl
482 <<
" The number of events in the datafile (" << a_nbEvents
483 <<
") is different from the total number of events in respiratory gates (" <<
m2p_indexLastEventRespGate[last_fr][last_rg] <<
") as initialized in the gating file !" << endl);
493 Cerr(
"***** oDynamicDataManager::CheckParameters() -> Problem while checking consistency of dynamic data !" << endl
494 <<
" The number of events in the datafile (" << a_nbEvents
495 <<
") is different to the total number of events in cardiac gates (" <<
m2p_indexLastEventRespGate[last_fr][last_rg] <<
") as initialized in the gating file !" << endl);
553 <<
" at event #" << a_currentEventIndex <<
", timestamp = " << a_currentTime << endl);
574 bool frame_has_changed =
false;
583 if (a_currentTime<mp_ID->GetFrameTimeStopInMs(a_bed,fr))
589 frame_has_changed =
true;
599 Cout(
"oDynamicDataManager::DynamicSwitch() -> Thread " << a_th <<
", frame switched to " <<
mp_currentFrameIndex[a_th] << endl);
607 bool resp_gate_has_changed =
false;
613 if (frame_has_changed)
634 <<
" on event " << a_currentEventIndex << endl
642 resp_gate_has_changed =
true;
652 bool card_gate_has_changed =
false;
658 if (frame_has_changed || resp_gate_has_changed)
679 <<
" on event " << a_currentEventIndex << endl
686 card_gate_has_changed =
true;
int InitDynamicDataGating(const string &a_pathToGateFile)
Initialisation of arrays containing informations about the data splitting and respiratory/cardiac gat...
int CheckParameters(int64_t a_nbEvents)
Check all mandatory parameters.
Declaration of class oImageDimensionsAndQuantification.
#define VERBOSE_DEBUG_EVENT
int * mp_currentRespGateIndex
#define DYNAMIC_SWITCH_NOTHING
#define DYNAMIC_SWITCH_CONTINUE
void ResetCurrentDynamicIndices()
Reset to 0 the multithreaded dynamic arrays gathering the indices of current frame, gates and involuntary motion.
uint16_t * mp_framePMotionFirstIndex
int DynamicSwitch(int64_t a_index, uint32_t a_time, int a_bed, int a_th)
This function is called in the reconstruction event loop. It is used to check if the current event be...
#define VERBOSE_DEBUG_LIGHT
int * mp_currentFrameIndex
uint16_t * mp_frameNbPMotionTriggers
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...
Declaration of class oDynamicDataManager.
~oDynamicDataManager()
oDynamicDataManager destructor.
oDynamicDataManager()
oDynamicDataManager constructor. Initialize the member variables to their default values...
int * mp_currentCardGateIndex
oImageDimensionsAndQuantification * mp_ID
int SetDynamicSpecificQuantificationFactors(FLTNB **a2p_quantificationFactors)
Compute gate-specific quantificative factors using the number of events within each gate...
int64_t ** m2p_indexLastEventCardGate
int64_t ** m2p_nbEventsPerCardGate
#define KEYWORD_MANDATORY
int InitDynamicDataPatientMotion(const string &a_pathToFile)
Initialisation of involuntary patient motion correction information, if any.
int * mp_currentPMotionIndex
int GetNbTimeFrames()
Get the number of time frames.
int64_t ** m2p_indexLastEventRespGate
int64_t ** m2p_nbEventsPerRespGate
int GetNbThreadsForProjection()
Get the number of threads used for projections.
uint32_t * mp_listPMotionTriggers
#define DEBUG_VERBOSE(IGNORED1, IGNORED2)
int InitDynamicData(int a_nbRespGates, int a_nbCardGates, const string &a_pathTo4DDataSplittingFile, int a_rmMCorrFlag, int a_cMmCorrFlag, int a_dmCorrFlag, int a_pMotionCorrFlag)
Main function for instanciation and initialization of the member variables and arrays. Call the specific initialization function depending of the type of dataset.
#define DYNAMIC_SWITCH_DEFORMATION
uint32_t GetFrameTimeStopInMs(int a_bed, int a_frame)
Get the frame time stop for the given bed, in milliseconds as a uint32_t.