115 int a_rmCorrFlag,
int a_cmCorrFlag,
int a_pmCorrFlag)
180 Cerr(
"***** oDynamicDataManager::InitDynamicData() -> Respiratory motion correction is enabled for cardiac-gated data. This is not supported in the current implementation !" << endl);
187 Cerr(
"***** oDynamicDataManager::InitDynamicData() -> Involuntary patient image-based motion correction cannot be used along with respiratory or cardiac motion correction !" << endl);
197 if(
m_verbose>=
VERBOSE_DETAIL)
Cout(
"oDynamicDataManager::InitDynamicData() -> Initializing data for gated reconstruction... " << endl);
201 Cerr(
"***** oDynamicDataManager::InitDynamicData() -> A problem occurred during the dynamic gating initialization !" << endl);
209 Cerr(
"***** oDynamicDataManager::InitDynamicData() -> A problem occurred during the patient involuntary motion correction initialization !" << endl);
216 if (
m_respGatingFlag)
Cout(
"oDynamicDataManager::InitDynamicData() -> Respiratory gating enabled" << endl);
217 if (
m_rMotionCorrFlag)
Cout(
"oDynamicDataManager::InitDynamicData() -> Respiratory image-based motion correction enabled" << endl);
218 if (
m_cardGatingFlag)
Cout(
"oDynamicDataManager::InitDynamicData() -> Cardiac gating enabled" << endl);
219 if (
m_cMotionCorrFlag)
Cout(
"oDynamicDataManager::InitDynamicData() -> Cardiac image-based motion correction enabled" << endl);
220 if (
m_pMotionCorrFlag)
Cout(
"oDynamicDataManager::InitDynamicData() -> Involuntary image-based patient motion correction enabled" << endl);
243 "nb_events_respiratory_gates",
249 Cerr(
"***** oDynamicDataManager::InitDynamicDataGating() -> Error while trying to read 'nb_events_respiratory_gates' in file '" << a_pathToFile <<
"' !" << endl);
254 uint64_t event_number_sum = 0;
271 "nb_events_cardiac_gates",
277 Cerr(
"***** oDynamicDataManager::InitDynamicDataGating() -> Error while trying to read 'nb_events_cardiac_gates' in file '" << a_pathToFile <<
"' !" << endl);
281 uint64_t event_number_sum = 0;
301 Cerr(
"***** oDynamicDataManager::InitDynamicDataGating() -> Error while trying to read 'nb_events_respiratory_gates' in file '" << a_pathToFile <<
"' !" << endl);
312 Cout(
" --> Provided gate duration, frame #" << fr <<
", gate #" << g <<
": " <<
m2p_durationPerGate[fr][g] << endl);
333 "nb_motion_triggers",
338 Cerr(
"***** oDynamicDataManager::InitDynamicDataPatientMotion() -> Involuntary motion correction enabled but no dynamic configuration file has been provided with the -im option," << endl
339 <<
"***** or the number of triggers could not be found in the dynamic file '" << a_pathToFile <<
"' !" << endl);
361 "timestamp_motion_triggers",
366 Cerr(
"***** oDynamicDataManager::InitDynamicDataPatientMotion() -> Involuntary motion correction enabled but list of triggers" 367 <<
" not found in the dynamic file '" << a_pathToFile <<
"' !" << endl);
380 for (
int pm=(m_nbPMotionTriggers-1) ; pm>0 ; pm--)
382 new_m_nbPMotionTriggers--;
383 m_nbPMotionTriggers = new_m_nbPMotionTriggers;
393 Cerr(
"***** oDynamicDataManager::InitDynamicDataPatientMotion() -> " 394 <<
" Error, the first motion trigger must be 0 ms" 395 <<
" (the corresponding transformation parameters are usually set to 0," 396 <<
" as the acquisition start in the reference position!" << endl);
450 if (
m_verbose>=
VERBOSE_DETAIL)
Cout(
"oDynamicDataManager::InitDynamicDataPatientMotion() -> First / Last motion trigger index for each dynamic frame: " << endl);
479 uint32_t motion_subset_stop_time_ms;
523 uint32_t motion_subset_stop_time_ms;
533 * (
long double) motion_subset_start_time_ms
536 * (
long double) (motion_subset_stop_time_ms - motion_subset_start_time_ms)
549 * (
long double)motion_subset_start_time_ms
552 * (
long double)(motion_subset_stop_time_ms - motion_subset_start_time_ms)
599 uint64_t total_events_in_frame = 0;
610 Cout(
" --> Cardiac gating correction factors :" << endl);
612 Cout(
" Frame #" << fr <<
", cardiac gate #" << g <<
" = " << a2p_quantificationFactors[fr][g] << endl);
632 uint64_t total_events_in_frame = 0;
643 Cout(
" --> Respiratory gating correction factors :" << endl);
645 Cout(
" Frame #" << fr <<
", gate #" << rg <<
" = " << a2p_quantificationFactors[fr][rg] << endl);
664 if (
m_verbose>=
VERBOSE_DETAIL)
Cout(
"oDynamicDataManager::CheckParameters() -> Check parameters for dynamic data settings" << endl);
668 Cerr(
"***** oDynamicDataManager::CheckParameters() -> No image dimensions provided !" << endl);
674 Cerr(
"***** oDynamicDataManager::CheckParameters() -> Wrong number of time frames !" << endl);
680 Cerr(
"***** oDynamicDataManager::CheckParameters() -> Wrong number of respiratory gates !" << endl);
686 Cerr(
"***** oDynamicDataManager::CheckParameters() -> Wrong number of respiratory gates !" << endl);
692 Cerr(
"***** oDynamicDataManager::CheckParameters() -> Wrong number of involuntary motion subsets provided !" << endl);
698 Cerr(
"***** oDynamicDataManager::CheckParameters() -> Wrong verbosity level provided !" << endl);
705 if (
m_respGatingFlag)
Cout(
"oDynamicDataManager::CheckParameters() -> Respiratory gating is enabled" << endl);
706 if (
m_rMotionCorrFlag)
Cout(
"oDynamicDataManager::CheckParameters() -> Respiratory motion correction enabled" << endl);
707 if (
m_cardGatingFlag)
Cout(
"oDynamicDataManager::CheckParameters() -> Cardiac gating is enabled" << endl);
708 if (
m_cMotionCorrFlag)
Cout(
"oDynamicDataManager::CheckParameters() -> Cardiac motion correction is enabled" << endl);
709 if (
m_pMotionCorrFlag)
Cout(
"oDynamicDataManager::CheckParameters() -> Involuntary motion correction is enabled" << endl);
719 Cerr(
"***** oDynamicDataManager::CheckParameters() -> Problem while checking consistency of dynamic data !" << endl
720 <<
" The number of events in the datafile (" << a_nbEvents
721 <<
") 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);
731 Cerr(
"***** oDynamicDataManager::CheckParameters() -> Problem while checking consistency of dynamic data !" << endl
732 <<
" The number of events in the datafile (" << a_nbEvents
733 <<
") 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);
792 <<
" at event #" << a_currentEventIndex <<
", timestamp = " << a_currentTime << endl);
813 bool frame_has_changed =
false;
822 if (a_currentTime<mp_ID->GetFrameTimeStopInMs(a_bed,fr))
828 frame_has_changed =
true;
836 else if (fr==m_nbTimeFrames-1)
844 Cout(
"oDynamicDataManager::DynamicSwitch() -> Thread " << a_th <<
", frame switched to " <<
mp_currentFrameIndex[a_th] << endl);
853 bool resp_gate_has_changed =
false;
859 if (frame_has_changed)
866 bool resp_gate_found =
false;
881 <<
" on event " << a_currentEventIndex << endl
889 resp_gate_has_changed =
true;
892 resp_gate_found =
true;
910 if (frame_has_changed || resp_gate_has_changed)
916 bool card_gate_found =
false;
930 <<
" on event " << a_currentEventIndex << endl
940 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
int ** mp_MotionTriggersIndexInFrame
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
uint16_t * mp_frameNbPMotionIndexes
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
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 VERBOSE_DEBUG_NORMAL
#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.