86 int oAnalyticProjection::LaunchGPU()
88 Cerr(
"***** oAnalyticProjection::LaunchGPU() -> The GPU specific function is not implemented !" << endl);
111 if (
m_verbose>=1)
Cout(
"oAnalyticProjection::LaunchCPU() -> Start analytic projection" << endl);
127 Cerr(
"***** oAnalyticProjection::LaunchCPU()-> Error during image initialization !" << endl);
133 Cerr(
"***** oAnalyticProjection::LaunchCPU()-> Error during attenuation image initialization !" << endl);
142 Cerr(
"***** oAnalyticProjection::LaunchCPU() -> A problem occured while applying image convolver to forward image !" << endl);
148 clock_t clock_start = clock();
149 time_t time_start = time(NULL);
154 for(
int bed=0 ; bed<
m_nbBeds ; bed++)
157 unsigned int main_loop_start_index = 0 ;
158 unsigned int main_loop_stop_index = 0;
166 Cerr(
"***** oAnalyticProjection::LaunchCPU()-> An error occured when trying to initialize main loop stop index !" << endl);
172 Cerr(
"***** oAnalyticProjection::LaunchCPU()-> An error occured when trying to initialize inner loop start index !" << endl);
179 int64_t* elements_sum = (int64_t*)malloc(nb_total_elts*
sizeof(int64_t));
182 for (int64_t idx_elt=1 ; idx_elt<nb_total_elts ; idx_elt++)
183 elements_sum[idx_elt] = elements_sum[idx_elt-1] + (uint64_t)(nb_total_elts-idx_elt);
189 uint64_t printing_index = 0;
196 uint32_t timestamp = 0;
222 bool problem =
false;
227 #pragma omp parallel for private(idx_elt1) schedule(static, 1)
228 for (idx_elt1=main_loop_start_index ; idx_elt1<(int)main_loop_stop_index ; idx_elt1++)
233 th = omp_get_thread_num();
241 for (int64_t idx_elt2=inner_loop_start_index ; idx_elt2<inner_loop_stop_index ; idx_elt2++)
246 if (printing_index%10000==0)
253 FLTNB percent = ( (
FLTNB)progression_index_current /((
FLTNB)progression_index_total) ) * ((
FLTNB)100);
254 cout <<
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b "
271 Cerr(
"***** oAnalyticProjection::LaunchCPU() -> A problem occured while computing the projection line !" << endl);
283 Cerr(
"***** oAnalyticProjection::LaunchCPU() -> An error occured during the data update step !" << endl);
289 total_events_in_cgate[th]++;
290 total_events_in_rgate[th]++;
291 total_events_in_frame[th]++;
292 double event_value =
event->GetEventValue(0);
293 total_prompts[th] += event_value;
294 total_prompts_in_cgate[th] += event_value;
295 total_prompts_in_rgate[th] += event_value;
296 total_prompts_in_frame[th] += event_value;
306 Cerr(
"***** oAnalyticProjection::LaunchCPU() -> A problem occured inside the parallel loop over events !" << endl);
313 Cerr(
"***** oAnalyticProjection::LaunchCPU()-> An error occured during the data writing step" << endl);
323 Cout(endl <<
"Total events in cgate #" << cg+1 <<
": " << total_events_in_cgate[0] << endl);
324 Cout(
"Total prompts in cgate #" << cg+1 <<
": " << total_prompts_in_cgate[0] << endl);
327 free(total_prompts_in_cgate);
328 free(total_events_in_cgate);
337 Cout(endl <<
"Total events in rgate #" << rg+1 <<
": " << total_events_in_rgate[0] << endl);
338 Cout(
"Total prompts in rgate #" << rg+1 <<
": " << total_prompts_in_rgate[0] << endl);
340 free(total_prompts_in_rgate);
341 free(total_events_in_rgate);
353 Cout(endl <<
"Total events in frame #" << fr+1 <<
": " << total_events_in_frame[0] << endl);
354 Cout(
"Total prompts in frame #" << fr+1 <<
": " << total_prompts_in_frame[0] << endl);
357 free(total_prompts_in_frame);
358 free(total_events_in_frame);
362 int acquisition_duration = 0;
367 if(acquisition_duration <= 0 ) acquisition_duration = 1;
370 cout <<
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b 100 % " << endl;
378 Cout(
"Total number of projected events:" << endl);
382 if (
m_verbose>=1)
Cout(
"Final total number of events projected: " << total_events[0] << endl);
384 if (
m_verbose>=1)
Cout(
"Final total number of prompts: " << total_prompts[0] << endl);
404 clock_t clock_stop = clock();
405 time_t time_stop = time(NULL);
406 Cout (endl << endl <<
" Total Time spent - Analytic Projection | User: " << time_stop-time_start <<
" sec | CPU: " << (clock_stop-clock_start)/((
FLTNB)CLOCKS_PER_SEC) <<
" sec" << endl);
oImageConvolverManager * mp_ImageConvolverManager
vDataFile ** m2p_DataFile
void LMS_InstantiateImage()
Allocate memory for the main image matrices (for list-mode sensitivity generation) ...
This header file is mainly used to declare some macro definitions and all includes needed from the st...
static sScannerManager * GetInstance()
Instanciate the singleton object and Initialize member variables if not already done, return a pointer to this object otherwise.
oAnalyticProjection()
oAnalyticProjection constructor. Initialize the member variables to their default values...
int64_t PROJ_GetModalityStartValueInnerLoop(int64_t a_elt1)
Get the start value for the inner loop of analytic projection depending on the modality.
int PROJ_InitImage(const string &a_pathToInitialImage)
Load the initial image for the analytical projection.
void LMS_PrepareForwardImage()
Copy current image in forward-image buffer (for list-mode sensitivity generation) ...
int ConvolveForward(oImageSpace *ap_ImageSpace)
A function used to apply convolvers onto the forward image of the oImageSpace.
int64_t PROJ_GetProgressionFinalValue()
Get numerator value according to the modality to compute percent progression during the projection pr...
virtual int PROJ_WriteHeader()=0
This function is implemented in child classes. Generate a header file according to the projection a...
virtual uint16_t PROJ_GetSPECTNbProjections()
return the total number of projections for a SPECT acquisition
int PROJ_SaveProjectionImage()
Save an image of the projected data (for analytic projection)
void SetDuration(FLTNB a_value)
void LMS_InstantiateForwardImage()
Allocate memory for the forward image matrices (for list-mode sensitivity generation) ...
int InitAttenuationImage(const string &a_pathToAtnImage)
Memory allocation and initialisation for the attenuation image using either :
virtual uint16_t PROJ_GetSPECTNbPixels()
return the total number of pixels for a SPECT reconstruction
~oAnalyticProjection()
oAnalyticProjection destructor.
oComputeProjection * mp_ComputeProjection
void PROJ_DeallocateProjectionImage(int a_nbProjs)
Free memory for the projection image for analytical projection.
oImageSpace * mp_ImageSpace
#define SCANNER_SPECT_CONVERGENT
Singleton class that Instantiate and initialize the scanner object.
void LMS_DeallocateImage()
Free memory for the main image matrices (for list-mode sensitivity generation)
oProjectionLine * ComputeProjectionLine(vEvent *ap_Event, int a_th)
This function is used to compute system matrix elements from the associated projector or pre-computed...
oImageDimensionsAndQuantification * mp_ID
int Launch()
Just call either the LaunchCPU or the LaunchGPU function as asked for.
vEvent * PROJ_GenerateEvent(int idx_elt1, int idx_elt2, int a_th)
Generate a standard event and set up its ID Used by the projection, list-mode sensitivity generatio...
int PROJ_DeleteTmpDatafile()
Delete temporary datafile used for multithreaded output writing if needed.
bool NotEmptyLine()
This function is used to know if the line contains any voxel contribution.
void PROJ_InstantiateProjectionImage(int a_nbProjs, int a_nbPixels)
Instanciate and initialize projection image for analytical projection.
string m_pathToInitialImg
int DataUpdateStep(vDataFile *ap_DataFile, oProjectionLine *a2p_Line, oImageSpace *ap_Image, vEvent *ap_Event, int a_fr, int a_rg, int a_cg, int th, uint32_t a_timestamp)
Perform the forward-projection, and send the result to the datafile for writing. Implements random ...
void SetNbEvents(int64_t a_value)
initialize the number of events with a int64_t value
virtual int GetSystemNbElts()=0
This is a pure virtual method that must be implemented by children.
This class is designed to manage and store system matrix elements associated to a vEvent...
void LMS_DeallocateAttenuationImage()
Free memory for the Attenuation image matrices (for analytical projection or list-mode sensitivity ge...
int GetNbCardGates()
Get the number of cardiac gates.
oProjectorManager * mp_ProjectorManager
Mother class for the Event objects.
int GetNbTimeFrames()
Get the number of time frames.
int64_t PROJ_GetCurrentProgression(int64_t a_elt1, int64_t a_elt2, int64_t *ap_nbEltsArray, int a_nbRGates, int a_nbCGates, int a_fr, int a_rg, int a_cg)
Get numerator value according to the modality to compute percent progression during the analytical pr...
int GetNbThreadsForProjection()
Get the number of threads used for projections.
Declaration of class oAnalyticProjection.
uint32_t GetFrameDurationInMs(int a_bed, int a_frame)
Get the frame duration for the given bed, in milliseconds as a uint32_t.
int GetNbRespGates()
Get the number of respiratory gates.
int64_t PROJ_GetModalityStopValueMainLoop()
Get the stop value for the main loop of analytic projection depending on the modality.
virtual int IsAvailableLOR(int a_elt1, int a_elt2)
This function is implemented in child classes. Check if the LOR is available according to the scann...
void SetVerbose(int a_verboseLevel)
set verbosity
void LMS_DeallocateForwardImage()
Free memory for the forward image matrices (for list-mode sensitivity generation) ...