105 int a_rmCorrFlag,
int a_cmCorrFlag,
int a_dmCorrFlag,
int a_pmCorrFlag)
107 if (
m_verbose>=3)
Cout(
"oDynamicDataManager::InitDynamicData() -> Initialize dynamic data management" << endl);
168 Cerr(
"***** oDynamicDataManager::InitDynamicData()-> Respiratory motion correction is enabled for cardiac-gated data. This is not supported in the current implementation !" << endl);
175 Cerr(
"***** oDynamicDataManager::InitDynamicData()-> Involuntary patient image-based motion correction cannot be used along with respiratory or cardiac motion correction !" << endl);
180 if ( (a_rmCorrFlag + a_rmCorrFlag + a_dmCorrFlag) >1 )
182 Cerr(
"***** oDynamicDataManager::InitDynamicData()-> Incorrect image-based motion initialization."<<endl);
183 Cerr(
"***** Please use -rm for respiratory motion, -cm for cardiac motion, or -dm for double respiratory and cardiac motion correction !" << endl);
193 if(
m_verbose >=3)
Cout(
"oDynamicDataManager::InitDynamicData()-> Initializing data for gated reconstruction... " << endl);
197 Cerr(
"***** oDynamicDataManager::InitDynamicData()-> A problem occured during the dynamic gating initialization !" << endl);
205 Cerr(
"***** oDynamicDataManager::InitDynamicData()-> A problem occured during the patient involuntary motion correction initialization !" << endl);
212 if(
m_respGatingFlag)
Cout(
"oDynamicDataManager::InitDynamicData()-> Respiratory gating enabled" << endl);
213 if(
m_rMotionCorrFlag)
Cout(
"oDynamicDataManager::InitDynamicData()-> Respiratory image-based motion correction enabled" << endl);
214 if(
m_cardGatingFlag)
Cout(
"oDynamicDataManager::InitDynamicData()-> Cardiac gating enabled" << endl);
215 if(
m_cMotionCorrFlag)
Cout(
"oDynamicDataManager::InitDynamicData()-> Cardiac image-based motion correction enabled" << endl);
216 if(
m_pMotionCorrFlag)
Cout(
"oDynamicDataManager::InitDynamicData()-> Involuntary image-based patient motion correction enabled" << endl);
236 if(
m_verbose >=3)
Cout(
"oDynamicDataManager::InitDynamicDataGating() ... " << endl);
243 "respiratory_gates_data_splitting",
249 Cerr(
"***** oDynamicDataManager::InitDynamicDataGating() -> Error while trying to read 'respiratory_gates_data_splitting' in file '" << a_pathToFile <<
"' !" << endl);
254 uint64_t event_number_sum = 0;
255 if (
m_verbose>=3)
Cout(
"oDynamicDataManager::InitDynamicDataGating() :" << endl);
272 "cardiac_gates_data_splitting",
278 Cerr(
"***** oDynamicDataManager::InitDynamicDataGating() -> Error while trying to read 'cardiac_gates_data_splitting' in file '" << a_pathToFile <<
"' !" << endl);
283 uint64_t event_number_sum = 0;
284 if (
m_verbose >=3)
Cout(
"oDynamicDataManager::InitDynamicDataGating() :" << endl);
312 if(
m_verbose >=3)
Cout(
"oDynamicDataManager::InitDynamicDataPatientMotion() ... " << endl);
313 Cerr(
"!!!!! WARNING oDynamicDataManager::InitDynamicDataGating() -> Still WiP !" << endl);
316 "nb_involuntary_motion_triggers",
321 Cerr(
"***** oDynamicDataManager::InitDynamicDataPatientMotion() -> Involuntary motion correction enabled but could" << endl
322 <<
" not find the number of triggers in the dynamic file '" << a_pathToFile <<
"' !" << endl);
330 "list_involuntary_motion_triggers",
335 Cerr(
"***** oDynamicDataManager::InitDynamicDataPatientMotion() -> Involuntary motion correction enabled but list of triggers" << endl
336 <<
" not found in the dynamic file '" << a_pathToFile <<
"' !" << endl);
355 if(
m_verbose >=3)
Cout(
"oDynamicDataManager::SetDynamicSpecificQuantificationFactors() ... " << endl);
365 uint64_t total_events_in_frame = 0;
368 if (
m_verbose>=3)
Cout(
"oDynamicDataManager::SetDynamicSpecificQuantificationFactors() -> Cardiac gating correction factors :" << endl);
372 if (
m_verbose>=3)
Cout(
"Frame #" << fr <<
", cardiac gate #" << g <<
" = " << a2p_quantificationFactors[fr][g] << endl);
379 uint64_t total_events_in_frame = 0;
382 if (
m_verbose>=3)
Cout(
"oDynamicDataManager::SetDynamicSpecificQuantificationFactors() -> Respiratory gating correction factors :" << endl);
385 int rg = int(g/m_nbCardGates);
387 if (
m_verbose>=3)
Cout(
"Frame #" << fr <<
", gate #" << g <<
" = " << a2p_quantificationFactors[fr][g] << endl);
409 if (
m_verbose>=3)
Cout(
"oDynamicDataManager::CheckParameters() -> Check parameters for dynamic data settings" << endl);
414 Cerr(
"***** oDynamicDataManager::CheckParameters() -> No image dimensions provided !" << endl);
420 Cerr(
"***** oDynamicDataManager::CheckParameters() -> Wrong number of respiratory gates !" << endl);
426 Cerr(
"***** oDynamicDataManager::CheckParameters() -> Wrong number of respiratory gates !" << endl);
432 Cerr(
"***** oDynamicDataManager::CheckParameters() -> Wrong number of involuntary motion subsets provided !" << endl);
438 Cerr(
"***** oDynamicDataManager::CheckParameters() -> Wrong verbosity level provided !" << endl);
444 if (
m_respGatingFlag)
Cout(
"oDynamicDataManager::CheckParameters() -> Respiratory gating is enabled" << endl);
445 if (
m_rMotionCorrFlag)
Cout(
"oDynamicDataManager::CheckParameters() -> Respiratory motion correction enabled" << endl);
446 if (
m_cardGatingFlag)
Cout(
"oDynamicDataManager::CheckParameters() -> Cardiac gating is enabled" << endl);
447 if (
m_cMotionCorrFlag)
Cout(
"oDynamicDataManager::CheckParameters() -> Cardiac motion correction is enabled" << endl);
448 if (
m_pMotionCorrFlag)
Cout(
"oDynamicDataManager::CheckParameters() -> Involuntary motion correction is enabled" << endl);
458 Cerr(
"***** oDynamicDataManager::CheckParameters() -> Problem while checking consistency of dynamic data !" << endl
459 <<
" The number of events in the datafile (" << a_nbEvents
460 <<
") is different from the total number of events in respiratory gates (" <<
m2p_indexLastEventRespGate[last_fr][last_rg] <<
") as initialized in the gating file !" << endl);
470 Cerr(
"***** oDynamicDataManager::CheckParameters() -> Problem while checking consistency of dynamic data !" << endl
471 <<
" The number of events in the datafile (" << a_nbEvents
472 <<
") is different to the total number of events in cardiac gates (" <<
m2p_indexLastEventRespGate[last_fr][last_rg] <<
") as initialized in the gating file !" << endl);
491 #ifdef CASTOR_VERBOSE
492 if (
m_verbose >=4)
Cout(
"oDynamicDataManager::ResetCurrentDynamicIndices() -> Reset indices" << endl);
525 #ifdef CASTOR_VERBOSE
526 if (
m_verbose >=4)
Cout(
"oDynamicDataManager::DynamicSwitch() -> Enter function" << endl);
547 #ifdef CASTOR_VERBOSE
548 if (
m_verbose >=4)
Cout(
"oDynamicDataManager::DynamicSwitch() -> Thread " << a_th <<
", gate for patient motion correction switched to " <<
mp_currentPMotionIndex[a_th] << endl
549 <<
" at event #" << a_currentEventIndex <<
", timestamp = " << a_currentTime << endl);
570 bool frame_has_changed =
false;
578 if (a_currentTime<mp_ID->GetFrameTimeStopInMs(a_bed,fr))
584 frame_has_changed =
true;
592 #ifdef CASTOR_VERBOSE
594 Cout(
"oDynamicDataManager::DynamicSwitch() -> Thread " << a_th <<
", frame switched to " <<
mp_currentFrameIndex[a_th] << endl);
602 bool resp_gate_has_changed =
false;
608 if (frame_has_changed)
627 #ifdef CASTOR_VERBOSE
629 <<
" on event " << a_currentEventIndex << endl
637 resp_gate_has_changed =
true;
647 bool card_gate_has_changed =
false;
653 if (frame_has_changed || resp_gate_has_changed)
672 #ifdef CASTOR_VERBOSE
674 <<
" on event " << a_currentEventIndex << endl
681 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.
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.
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...
int * mp_currentFrameIndex
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
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