114 int a_rmCorrFlag,
int a_cmCorrFlag,
int a_pmCorrFlag)
179 Cerr(
"***** oDynamicDataManager::InitDynamicData() -> Respiratory motion correction is enabled for cardiac-gated data. This is not supported in the current implementation !" << endl);
186 Cerr(
"***** oDynamicDataManager::InitDynamicData() -> Involuntary patient image-based motion correction cannot be used along with respiratory or 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 occurred during the dynamic gating initialization !" << endl);
208 Cerr(
"***** oDynamicDataManager::InitDynamicData() -> A problem occurred 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 "nb_events_respiratory_gates",
248 Cerr(
"***** oDynamicDataManager::InitDynamicDataGating() -> Error while trying to read 'nb_events_respiratory_gates' in file '" << a_pathToFile <<
"' !" << endl);
253 uint64_t event_number_sum = 0;
270 "nb_events_cardiac_gates",
276 Cerr(
"***** oDynamicDataManager::InitDynamicDataGating() -> Error while trying to read 'nb_events_cardiac_gates' in file '" << a_pathToFile <<
"' !" << endl);
280 uint64_t event_number_sum = 0;
300 Cerr(
"***** oDynamicDataManager::InitDynamicDataGating() -> Error while trying to read 'nb_events_respiratory_gates' in file '" << a_pathToFile <<
"' !" << endl);
311 Cout(
" --> Provided gate duration, frame #" << fr <<
", gate #" << g <<
": " <<
m2p_durationPerGate[fr][g] << endl);
332 "nb_motion_triggers",
337 Cerr(
"***** oDynamicDataManager::InitDynamicDataPatientMotion() -> Involuntary motion correction enabled but no dynamic configuration file has been provided with the -im option," << endl
338 <<
"***** or the number of triggers could not be found in the dynamic file '" << a_pathToFile <<
"' !" << endl);
358 "timestamp_motion_triggers",
363 Cerr(
"***** oDynamicDataManager::InitDynamicDataPatientMotion() -> Involuntary motion correction enabled but list of triggers" 364 <<
" not found in the dynamic file '" << a_pathToFile <<
"' !" << endl);
380 Cerr(
"***** oDynamicDataManager::InitDynamicDataPatientMotion() -> " 381 <<
" Error, the first motion trigger must be 0 ms" 382 <<
" (the corresponding transformation parameters are usually set to 0," 383 <<
" as the acquisition start in the reference position!" << endl);
411 if(fr >= m_nbTimeFrames)
413 Cerr(
"***** oDynamicDataManager::InitDynamicDataPatientMotion() -> Error, the "<<t+1<<
"th motion trigger timestamp: "<<
mp_listPMotionTriggers[t]
414 <<
" occurs after the end of the last frame (frame "<<fr<<
", timestop :"<<
mp_ID->
GetFrameTimeStopInMs(0,fr-1) <<
" !" << endl);
437 if(fr<m_nbTimeFrames-1)
445 if (
m_verbose>=
VERBOSE_DETAIL)
Cout(
"oDynamicDataManager::InitDynamicDataPatientMotion() -> First / Last motion trigger index for each dynamic frame: " << endl);
466 uint32_t motion_subset_stop_time_ms = 0;
470 if (t<m_nbPMotionTriggers
502 * (
long double)motion_subset_start_time_ms
505 * (
long double)(motion_subset_stop_time_ms - motion_subset_start_time_ms)
553 uint64_t total_events_in_frame = 0;
564 Cout(
" --> Cardiac gating correction factors :" << endl);
566 Cout(
" Frame #" << fr <<
", cardiac gate #" << g <<
" = " << a2p_quantificationFactors[fr][g] << endl);
581 uint64_t total_events_in_frame = 0;
592 Cout(
" --> Respiratory gating correction factors :" << endl);
594 Cout(
" Frame #" << fr <<
", gate #" << rg <<
" = " << a2p_quantificationFactors[fr][rg] << endl);
613 if (
m_verbose>=
VERBOSE_DETAIL)
Cout(
"oDynamicDataManager::CheckParameters() -> Check parameters for dynamic data settings" << endl);
617 Cerr(
"***** oDynamicDataManager::CheckParameters() -> No image dimensions provided !" << endl);
623 Cerr(
"***** oDynamicDataManager::CheckParameters() -> Wrong number of time frames !" << endl);
629 Cerr(
"***** oDynamicDataManager::CheckParameters() -> Wrong number of respiratory gates !" << endl);
635 Cerr(
"***** oDynamicDataManager::CheckParameters() -> Wrong number of respiratory gates !" << endl);
641 Cerr(
"***** oDynamicDataManager::CheckParameters() -> Wrong number of involuntary motion subsets provided !" << endl);
647 Cerr(
"***** oDynamicDataManager::CheckParameters() -> Wrong verbosity level provided !" << endl);
654 if (
m_respGatingFlag)
Cout(
"oDynamicDataManager::CheckParameters() -> Respiratory gating is enabled" << endl);
655 if (
m_rMotionCorrFlag)
Cout(
"oDynamicDataManager::CheckParameters() -> Respiratory motion correction enabled" << endl);
656 if (
m_cardGatingFlag)
Cout(
"oDynamicDataManager::CheckParameters() -> Cardiac gating is enabled" << endl);
657 if (
m_cMotionCorrFlag)
Cout(
"oDynamicDataManager::CheckParameters() -> Cardiac motion correction is enabled" << endl);
658 if (
m_pMotionCorrFlag)
Cout(
"oDynamicDataManager::CheckParameters() -> Involuntary motion correction is enabled" << endl);
668 Cerr(
"***** oDynamicDataManager::CheckParameters() -> Problem while checking consistency of dynamic data !" << endl
669 <<
" The number of events in the datafile (" << a_nbEvents
670 <<
") is different from the total number of events in respiratory gates (" <<
m2p_indexLastEventRespGate[last_fr][last_rg]+1 <<
") as initialized in the gating file !" << endl);
680 Cerr(
"***** oDynamicDataManager::CheckParameters() -> Problem while checking consistency of dynamic data !" << endl
681 <<
" The number of events in the datafile (" << a_nbEvents
682 <<
") is different to the total number of events in cardiac gates (" <<
m2p_indexLastEventCardGate[last_fr][last_cg]+1 <<
") as initialized in the gating file !" << endl);
741 <<
" at event #" << a_currentEventIndex <<
", timestamp = " << a_currentTime << endl);
762 bool frame_has_changed =
false;
771 if (a_currentTime<mp_ID->GetFrameTimeStopInMs(a_bed,fr))
777 frame_has_changed =
true;
785 else if (fr==m_nbTimeFrames-1)
793 Cout(
"oDynamicDataManager::DynamicSwitch() -> Thread " << a_th <<
", frame switched to " <<
mp_currentFrameIndex[a_th] << endl);
802 bool resp_gate_has_changed =
false;
808 if (frame_has_changed)
815 bool resp_gate_found =
false;
830 <<
" on event " << a_currentEventIndex << endl
838 resp_gate_has_changed =
true;
841 resp_gate_found =
true;
859 if (frame_has_changed || resp_gate_has_changed)
865 bool card_gate_found =
false;
879 <<
" on event " << a_currentEventIndex << endl
889 card_gate_found =
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.
HPFLTNB ** m2p_listPMotionWeightInFrame
Declaration of class oImageDimensionsAndQuantification.
#define VERBOSE_DEBUG_EVENT
FLTNB GetFrameTimeStartInSec(int a_bed, int a_frame)
Get the frame time start for the given bed, in seconds as a FLTNB.
int * mp_currentRespGateIndex
uint16_t * mp_framePMotionLastIndex
#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.
uint32_t GetFrameTimeStartInMs(int a_bed, int a_frame)
Get the frame time start for the given bed, in milliseconds as a uint32_t.
#define DYNAMIC_SWITCH_END_LOOP
uint16_t * mp_framePMotionFirstIndex
int InitDynamicData(int a_nbRespGates, int a_nbCardGates, const string &a_pathTo4DDataSplittingFile, int a_rmMCorrFlag, int a_cMmCorrFlag, 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.
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.
bool m_gateDurationProvidedFlag
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 GetFrameDurationInMs(int a_bed, int a_frame)
Get the frame duration for the given bed, in milliseconds as a uint32_t.
uint32_t * mp_listPMotionTriggers
#define DEBUG_VERBOSE(IGNORED1, IGNORED2)
FLTNB GetFrameDurationInSec(int a_bed, int a_frame)
Get the frame duration for the given bed, in seconds as a FLTNB.
HPFLTNB ** m2p_durationPerGate
#define KEYWORD_OPTIONAL_ERROR
#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.