CASToR  3.2
Tomographic Reconstruction (PET/SPECT/CT)
src/projector/oProjectorManager.cc
Go to the documentation of this file.
1 
8 #include "oProjectorManager.hh"
9 #include "sOutputManager.hh"
10 #include "sAddonManager.hh"
11 #include "iDataFilePET.hh"
12 #include "iProjectorClassicSiddon.hh"
13 
14 // =====================================================================
15 // ---------------------------------------------------------------------
16 // ---------------------------------------------------------------------
17 // =====================================================================
18 
20 {
21  // Scanner and image dimensions
22  mp_Scanner = NULL;
24  // Data file (used to get some info about TOF bins and POI)
25  mp_DataFile = NULL;
26  // TOF and POI options
27  m_TOFMethod = -1;
28  m_applyPOI = false;
29  m_nbTOFBins = -1;
30  // Computation strategy for projection lines
32  // Forward and backward options for projectors
33  m_optionsForward = "";
34  m_optionsBackward = "";
35  // Common options
36  m_optionsCommon = "";
37  // Forward and backward projectors
42  mp_ProjectorForward = NULL;
43  mp_ProjectorBackward = NULL;
46  m_useProjectorForward = false;
47  m_useProjectorBackward = false;
48  m_useMatchedProjectors = false;
49  // Forward and backward projection lines (as many as threads)
50  m2p_ProjectionLines = NULL;
51  // Verbosity
52  m_verbose = 0;
53  // Not checked yet
54  m_checked = false;
55  // Not initialized yet
56  m_initialized = false;
57  m_applyMask = false;
58  mp_mask = NULL;
59  m_TOFBinSizeInMm = -1.;
60  m_TOFResolutionInMm = -1.;
63 }
64 
65 // =====================================================================
66 // ---------------------------------------------------------------------
67 // ---------------------------------------------------------------------
68 // =====================================================================
69 
71 {
72  // Go through the destructor only if the object was initialized
73  if (m_initialized)
74  {
75  // Delete projection lines
77  {
79  if (m2p_ProjectionLines[th]) delete m2p_ProjectionLines[th];
80  delete[] m2p_ProjectionLines;
81  }
82  // Delete projectors
85  if (m_applyMask) delete[] mp_mask;
87  {
90  }
91 
92  }
93 }
94 
95 // =====================================================================
96 // ---------------------------------------------------------------------
97 // ---------------------------------------------------------------------
98 // =====================================================================
99 
101 {
102  // Case for a vProjector
104  // Case for a system matrix
106 }
107 
108 // =====================================================================
109 // ---------------------------------------------------------------------
110 // ---------------------------------------------------------------------
111 // =====================================================================
112 
114 {
115  // Case for a vProjector
117  // Case for a system matrix
119 }
120 
121 // =====================================================================
122 // ---------------------------------------------------------------------
123 // ---------------------------------------------------------------------
124 // =====================================================================
125 
127 {
128  // Check scanner
129  if (mp_Scanner==NULL)
130  {
131  Cerr("***** oProjectorManager::CheckParameters() -> No scanner provided !" << endl);
132  return 1;
133  }
134  // Check image dimensions
136  {
137  Cerr("***** oProjectorManager::CheckParameters() -> No image dimensions provided !" << endl);
138  return 1;
139  }
140  // Check data file
141  if (mp_DataFile==NULL)
142  {
143  Cerr("***** oProjectorManager::CheckParameters() -> No data file provided !" << endl);
144  return 1;
145  }
146  // Check computation strategy
150  {
151  Cerr("***** oProjectorManager::CheckParameters() -> Unknown computation strategy provided !" << endl);
152  return 1;
153  }
154  // Check forward projector options
155  if (m_optionsForward=="")
156  {
157  Cerr("***** oProjectorManager::CheckParameters() -> No forward projector options provided !" << endl);
158  return 1;
159  }
160  // Check backward projector options
161  if (m_optionsBackward=="")
162  {
163  Cerr("***** oProjectorManager::CheckParameters() -> No backward projector options provided !" << endl);
164  return 1;
165  }
166  // Check verbosity
167  if (m_verbose<0)
168  {
169  Cerr("***** oProjectorManager::CheckParameters() -> Wrong verbosity level provided !" << endl);
170  return 1;
171  }
172  // Normal end
173  m_checked = true;
174  return 0;
175 }
176 
177 // =====================================================================
178 // ---------------------------------------------------------------------
179 // ---------------------------------------------------------------------
180 // =====================================================================
181 
182 int oProjectorManager::CheckSPECTAttenuationCompatibility(const string& a_pathToAttenuationImage)
183 {
184  // In SPECT with attenuation correction, there are some requirements with the projection method
185  if (a_pathToAttenuationImage!="" && mp_DataFile->GetDataType()==TYPE_SPECT)
186  {
187  // Check that the projection line strategy is not IMAGE_COMPUTATION_STRATEGY (this is not compatible)
188  // Note that we cannot do this check in the oProjectionLine directly, because we cannot now in advance
189  // that the projection method including attenuation will be used...
191  {
192  Cerr("***** oProjectorManager::CheckSPECTAttenuationCompatibility() -> The image-computation strategy of the oProjectionLine is not compatible with SPECT attenuation correction !");
193  return 1;
194  }
195  // Check that the forward projector is compatible with SPECT with attenuation correction
197  {
198  Cerr("***** oProjectorManager::CheckSPECTAttenuationCompatibility() -> The forward projector is not compatible with SPECT attenuation correction !" << endl);
199  return 1;
200  }
201  // Check that the backward projector is compatible with SPECT with attenuation correction
203  {
204  Cerr("***** oProjectorManager::CheckSPECTAttenuationCompatibility() -> The backward projector is not compatible with SPECT attenuation correction !" << endl);
205  return 1;
206  }
207  }
208  // End
209  return 0;
210 }
211 
212 // =====================================================================
213 // ---------------------------------------------------------------------
214 // ---------------------------------------------------------------------
215 // =====================================================================
216 
218 {
219  // Forbid initialization without check
220  if (!m_checked)
221  {
222  Cerr("***** oProjectorManager::Initialize() -> Must call CheckParameters() before Initialize() !" << endl);
223  return 1;
224  }
225 
226  // Verbose
227  if (m_verbose>=1) Cout("oProjectorManager::Initialize() -> Initialize projectors and projection lines" << endl);
228 
229  // -------------------------------------------------------------------
230  // Manage TOF
231  // -------------------------------------------------------------------
232 
233  // TOF is only for PET data
235  {
236  // Cast the datafile pointer
237  iDataFilePET* p_pet_datafile = (dynamic_cast<iDataFilePET*>(mp_DataFile));
238  // Case of TOF information in the datafile
239  if (p_pet_datafile->GetTOFInfoFlag())
240  {
241  // Case where it is asked to ignore TOF info
242  if (p_pet_datafile->GetIgnoreTOFFlag())
243  {
245  m_nbTOFBins = 1;
246  }
247  // Otherwise, we use TOF
248  else
249  {
250  // Get the TOF resolution (FWHM in ps) from the data file, and convert it to mm
252 
253  // For list-mode data
255  {
256  m_nbTOFBins = 1;
258  // Get the TOF quantization bin size in ps and convert it to mm
261 
263  }
264  // For histogram data
265  else
266  {
268  // Get the number of TOF bins from the data file
269  m_nbTOFBins = p_pet_datafile->GetNbTOFBins();
270  // Get the TOF bin size in ps
273  }
274  }
275  // Verbose
277  {
278  if (m_TOFMethod==USE_NOTOF) Cout(" --> Do not use the TOF projections" << endl);
279  else if (m_TOFMethod==USE_TOFHISTO) Cout(" --> Use TOF projector for histogram data" << endl);
280  else if (m_TOFMethod==USE_TOFLIST) Cout(" --> Use TOF projector for listmode data" << endl);
281  }
282  }
283  // Case no TOF
284  else
285  {
287  m_nbTOFBins = 1;
288  }
289  }
290  // Not PET data
291  else
292  {
293  m_nbTOFBins = 1;
295  }
296 
297  // -------------------------------------------------------------------
298  // Manage POI
299  // -------------------------------------------------------------------
300 
301  // Case we have POI and it is not asked to ignore the information
303  {
304  // Cannot use POI with histogram mode
306  {
307  Cerr("***** oProjectorManager::Initialize() -> POI information has no sense with histogram data !" << endl);
308  return 1;
309  }
310  // Apply POI
311  m_applyPOI = true;
312  }
313  // Case we do not use POI
314  else m_applyPOI = false;
315  // Get POI resolution from the data file
316  FLTNB* poi_resolution = mp_DataFile->GetPOIResolution();
317 
318  // -------------------------------------------------------------------
319  // Initialize projectors and or system matrix
320  // -------------------------------------------------------------------
321 
322  // Compare projector options to know if we use matched ones for forward and backward operations
324  else m_useMatchedProjectors = false;
325 
326  // Parse projector options and initialize them
328  {
329  Cerr("***** oProjectorManager::Initialize() -> A problem occurred while parsing projector options and initializing it !" << endl);
330  return 1;
331  }
332 
333  // -------------------------------------------------------------------
334  // If compression, loaded SM and some projectors are not compatible
335  // -------------------------------------------------------------------
336 
337  // Compression can currently occur only in PET
339  {
340  // Check if there is some compression
341  if ( (dynamic_cast<iDataFilePET*>(mp_DataFile))->GetMaxNumberOfLinesPerEvent() > 1 )
342  {
343  // It is not compatible with loaded forward system matrices
345  {
346  Cerr("***** oProjectorManager::Initialize() -> Cannot use a loaded forward system matrix with compression in the datafile !" << endl);
347  return 1;
348  }
349  // It is not compatible with forward projectors declared as not compatible !
351  {
352  Cerr("***** oProjectorManager::Initialize() -> Selected forward projector '" << m_forwardProjectorName << "' is not compatible with compression in the datafile !" << endl);
353  return 1;
354  }
355  // It is not compatible with loaded backward system matrices
357  {
358  Cerr("***** oProjectorManager::Initialize() -> Cannot use a loaded backward system matrix with compression in the datafile !" << endl);
359  return 1;
360  }
361  // It is not compatible with backward projectors declared as not compatible !
363  {
364  Cerr("***** oProjectorManager::Initialize() -> Selected backward projector '" << m_backwardProjectorName << "' is not compatible with compression in the datafile !" << endl);
365  return 1;
366  }
367  }
368  }
369 
370  // -------------------------------------------------------------------
371  // Transfer the mask to projectors
372  // -------------------------------------------------------------------
373 
374  if (m_applyMask)
375  {
378  }
379 
380 
381  // -------------------------------------------------------------------
382  // Initialize projection lines
383  // -------------------------------------------------------------------
384 
385  // Initialize as many projection lines as threads
388  {
393  m2p_ProjectionLines[th]->SetPOIResolution(poi_resolution);
400  {
401  Cerr("***** oProjectorManager::Initialize() -> An error occurred while checking parameters of an oProjectionLine !" << endl);
402  return 1;
403  }
404  if (m2p_ProjectionLines[th]->Initialize())
405  {
406  Cerr("***** oProjectorManager::Initialize() -> An error occurred while initializing an oProjectionLine !" << endl);
407  return 1;
408  }
409  }
410 
411  // Normal end
412  m_initialized = true;
413  return 0;
414 }
415 
416 // =====================================================================
417 // ---------------------------------------------------------------------
418 // ---------------------------------------------------------------------
419 // =====================================================================
420 
422 {
423  string list_options = "";
424  string file_options = "";
425 
426  // This is for the automatic initialization of the projectors
427  typedef vProjector *(*maker_projector) ();
428 
429  // ---------------------------------------------------------------------------------------------------
430  // Manage forward projector
431  // ---------------------------------------------------------------------------------------------------
432 
433  // ______________________________________________________________________________
434  // Get the projector name in the options and isolate the real projector's options
435 
436  // Search for a colon ":", this indicates that a configuration file is provided after the projector name
437  size_t colon = m_optionsForward.find_first_of(":");
438  size_t comma = m_optionsForward.find_first_of(",");
439 
440  // Case 1: we have a colon
441  if (colon!=string::npos)
442  {
443  // Get the projector name before the colon
444  m_forwardProjectorName = m_optionsForward.substr(0,colon);
445  // Get the configuration file after the colon
446  file_options = m_optionsForward.substr(colon+1);
447  // List of options is empty
448  list_options = "";
449  }
450  // Case 2: we have a comma
451  else if (comma!=string::npos)
452  {
453  // Get the projector name before the first comma
454  m_forwardProjectorName = m_optionsForward.substr(0,comma);
455  // Get the list of options after the first comma
456  list_options = m_optionsForward.substr(comma+1);
457  // Configuration file is empty
458  file_options = "";
459  }
460  // Case 3: no colon and no comma (a single projector name)
461  else
462  {
463  // Get the projector name
465  // List of options is empty
466  list_options = "";
467  // Build the default configuration file
468  file_options = sOutputManager::GetInstance()->GetPathToConfigDir() + "/projector/" + m_forwardProjectorName + ".conf";
469  }
470 
471  // ______________________________________________________________________________
472  // Case 1: projector is equal to keyword 'matrix', then use a system matrix
474  {
475  mp_ProjectorForward = NULL;
476  m_useProjectorForward = false;
478  // TODO: put all these limitations into a dedicated function from oSystemMatrix
479  // TODO: forbid TOF in PET with system matrix
480  // TODO: forbid simultaneous bed reconstruction with system matrix
481  // TODO: forbid image offset with system matrix
482  Cerr("***** oProjectorManager::ParseOptionsAndInitializeProjectors() -> Loading of custom system matrices is not yet implemented !" << endl);
483  return 1;
484  }
485  // ______________________________________________________________________________
486  // Case 2: on-the-fly projector
487  else
488  {
489  // Unset system matrix
490  mp_SystemMatrixForward = NULL;
491  m_useSystemMatrixForward = false;
492  // Set projector on
493  m_useProjectorForward = true;
494  // Get projector's listfrom addon manager
495  std::map <string,maker_projector> list = sAddonManager::GetInstance()->mp_listOfProjectors;
496  // Create the projector
498  else
499  {
500  Cerr("***** oProjectorManager::ParseOptionsAndInitializeProjectors() -> Projector '" << m_forwardProjectorName << "' does not exist !" << endl);
501  return 1;
502  }
503  // Set parameters
506  {
507  Cerr("***** oProjectorManager::ParseOptionsAndInitializeProjectors() -> A problem occurred while setting the image dimensions of the forward projector !" << endl);
508  return 1;
509  }
517 
518  // Provide common options list
520  {
521  Cerr("***** oProjectorManager::ParseOptionsAndInitializeProjectors() -> A problem occurred while parsing and reading forward projector's common options !" << endl);
522  return 1;
523  }
524  // Provide configuration file if any
525  if (file_options!="" && mp_ProjectorForward->ReadConfigurationFile(file_options))
526  {
527  Cerr("***** oProjectorManager::ParseOptionsAndInitializeProjectors() -> A problem occurred while parsing and reading forward projector's configuration file !" << endl);
528  return 1;
529  }
530  // Provide options if any
531  if (list_options!="" && mp_ProjectorForward->ReadOptionsList(list_options))
532  {
533  Cerr("***** oProjectorManager::ParseOptionsAndInitializeProjectors() -> A problem occurred while parsing and reading forward projector's options !" << endl);
534  return 1;
535  }
536  // Check parameters
538  {
539  Cerr("***** oProjectorManager::ParseOptionsAndInitializeProjectors() -> A problem occurred while checking forward projector parameters !" << endl);
540  return 1;
541  }
542  // Initialize the projector
544  {
545  Cerr("***** oProjectorManager::ParseOptionsAndInitializeProjectors() -> A problem occurred while initializing the forward projector !" << endl);
546  return 1;
547  }
548  }
549 
550  // ---------------------------------------------------------------------------------------------------
551  // Manage backward projector
552  // ---------------------------------------------------------------------------------------------------
553 
554  // If options are the same, then forward and backward are the same
556  {
557  // In this case, matched projectors
562  }
563  // Else, unmatched projectors
564  else
565  {
566  // ______________________________________________________________________________
567  // Get the projector name in the options and isolate the real projector's options
568 
569  // Search for a colon ":", this indicates that a configuration file is provided after the projector name
570  colon = m_optionsBackward.find_first_of(":");
571  comma = m_optionsBackward.find_first_of(",");
572 
573  // Case 1: we have a colon
574  if (colon!=string::npos)
575  {
576  // Get the projector name before the colon
577  m_backwardProjectorName = m_optionsBackward.substr(0,colon);
578  // Get the configuration file after the colon
579  file_options = m_optionsBackward.substr(colon+1);
580  // List of options is empty
581  list_options = "";
582  }
583  // Case 2: we have a comma
584  else if (comma!=string::npos)
585  {
586  // Get the projector name before the first comma
587  m_backwardProjectorName = m_optionsBackward.substr(0,comma);
588  // Get the list of options after the first comma
589  list_options = m_optionsBackward.substr(comma+1);
590  // Configuration file is empty
591  file_options = "";
592  }
593  // Case 3: no colon and no comma (a single projector name)
594  else
595  {
596  // Get the projector name
598  // List of options is empty
599  list_options = "";
600  // Build the default configuration file
601  file_options = sOutputManager::GetInstance()->GetPathToConfigDir() + "/projector/" + m_backwardProjectorName + ".conf";
602  }
603 
604  // ______________________________________________________________________________
605  // Case 1: projector is equal to keyword 'matrix', then use a system matrix
607  {
608  mp_ProjectorBackward = NULL;
609  m_useProjectorBackward = false;
611  // TODO: put all these limitations into a dedicated function from oSystemMatrix
612  // TODO: forbid TOF in PET with system matrix
613  // TODO: forbid simultaneous bed reconstruction with system matrix
614  // TODO: forbid image offset with system matrix
615  Cerr("***** oProjectorManager::ParseOptionsAndInitializeProjectors() -> Loading of custom system matrices is not yet implemented !" << endl);
616  return 1;
617  }
618  // ______________________________________________________________________________
619  // Case 2: on-the-fly projector
620  else
621  {
622  // Unset system matrix
625  // Set projector on
626  m_useProjectorBackward = true;
627  // Get projector's listfrom addon manager
628  std::map <string,maker_projector> list = sAddonManager::GetInstance()->mp_listOfProjectors;
629  // Create the projector
631  else
632  {
633  Cerr("***** oProjectorManager::ParseOptionsAndInitializeProjectors() -> Projector '" << m_backwardProjectorName << "' does not exist !" << endl);
634  return 1;
635  }
636  // Set parameters
639  {
640  Cerr("***** oProjectorManager::ParseOptionsAndInitializeProjectors() -> A problem occurred while setting the image dimensions of the backward projector !" << endl);
641  return 1;
642  }
650 
651  // Provide common options list
653  {
654  Cerr("***** oProjectorManager::ParseOptionsAndInitializeProjectors() -> A problem occurred while parsing and reading backward projector's common options !" << endl);
655  return 1;
656  }
657  // Provide configuration file if any
658  if (file_options!="" && mp_ProjectorBackward->ReadConfigurationFile(file_options))
659  {
660  Cerr("***** oProjectorManager::ParseOptionsAndInitializeProjectors() -> A problem occurred while parsing and reading backward projector's configuration file !" << endl);
661  return 1;
662  }
663  // Provide options if any
664  if (list_options!="" && mp_ProjectorBackward->ReadOptionsList(list_options))
665  {
666  Cerr("***** oProjectorManager::ParseOptionsAndInitializeProjectors() -> A problem occurred while parsing and reading backward projector's options !" << endl);
667  return 1;
668  }
669  // Check parameters
671  {
672  Cerr("***** oProjectorManager::ParseOptionsAndInitializeProjectors() -> A problem occurred while checking backward projector parameters !" << endl);
673  return 1;
674  }
675  // Initialize the projector
677  {
678  Cerr("***** oProjectorManager::ParseOptionsAndInitializeProjectors() -> A problem occurred while initializing backward projector !" << endl);
679  return 1;
680  }
681  }
682  }
683 
684  // Normal end
685  return 0;
686 }
687 
688 // =====================================================================
689 // ---------------------------------------------------------------------
690 // ---------------------------------------------------------------------
691 // =====================================================================
692 
694 {
695  // Set the sensitivity ON in the projectors, if used
698  // If the data file is a list-mode, then deactivate the TOF usage in the projector
700  {
703  }
704 }
705 
706 // =====================================================================
707 // ---------------------------------------------------------------------
708 // ---------------------------------------------------------------------
709 // =====================================================================
710 
712 {
713  // Set the sensitivity OFF in the projectors, if used
716  // Reset TOF and POI parameters to original values
718  {
721  }
723  {
726  }
727 }
728 
729 // =====================================================================
730 // ---------------------------------------------------------------------
731 // ---------------------------------------------------------------------
732 // =====================================================================
733 
734 void oProjectorManager::ApplyBedOffset(int a_bed)
735 {
736  // Apply it to all projection lines (only if more than one bed position)
740 }
741 
742 // =====================================================================
743 // ---------------------------------------------------------------------
744 // ---------------------------------------------------------------------
745 // =====================================================================
746 
748 {
749  #ifdef CASTOR_DEBUG
750  if (!m_initialized)
751  {
752  Cerr("***** oProjectorManager::ComputeProjectionLine() -> Called while not initialized !" << endl);
753  return NULL;
754  }
755  #endif
756 
758 
759  // Get the list of indices
760  uint32_t *index1 = ap_Event->GetEventID1();
761  uint32_t *index2 = ap_Event->GetEventID2();
762  int nb_indices = ap_Event->GetNbLines();
763 
764  // Clean the projection line
765  m2p_ProjectionLines[a_th]->Reset();
766 
767  // Set the current index associated to the event
768  m2p_ProjectionLines[a_th]->SetEventIndex(ap_Event->GetEventIndex());
769 
770  // With list-mode data, we may need POI and/or TOF measurements
771  if (ap_Event->GetDataMode()==MODE_LIST)
772  {
773  // Set POI measurement
774  if (m_applyPOI)
775  {
776  // For PET
777  if (ap_Event->GetDataType()==TYPE_PET)
778  {
779  // Have to dynamic_cast the event into a iEventPETList to access the GetPOI functions
780  m2p_ProjectionLines[a_th]->SetPOI1((dynamic_cast<iEventListPET*>(ap_Event))->GetPOI1());
781  m2p_ProjectionLines[a_th]->SetPOI2((dynamic_cast<iEventListPET*>(ap_Event))->GetPOI2());
782  }
783  // For SPECT
784  else if (ap_Event->GetDataType()==TYPE_SPECT)
785  {
786  // By convention in SPECT, the second end point is in the camera (the first one being outside)
787  //m2p_ProjectionLines[a_th]->SetPOI2((dynamic_cast<iEventListModeSPECT*>(ap_Event))->GetPOI());
788  }
789  // For CT
790  else if (ap_Event->GetDataType()==TYPE_CT)
791  {
792  ;
793  }
794  }
795  // Set TOF measurement (only for PET obviously)
796  if (m_TOFMethod!=USE_NOTOF && ap_Event->GetDataType()==TYPE_PET)
797  {
798  // Have to dynamic_cast the event into a iEventPETList to access the GetTOF function
799  m2p_ProjectionLines[a_th]->SetTOFMeasurementInPs((dynamic_cast<iEventListPET*>(ap_Event))->GetTOFMeasurementInPs());
801  {
802  m2p_ProjectionLines[a_th]->SetTOFSigmaInPs((dynamic_cast<iEventListPET*>(ap_Event))->GetTOFEventResolutionInPs());
803  }
804  }
805  }
806 
807  // Transfer optional custom data from the Event to the ProjectionLine
812 
813  // Project forward (and also compute line length)
814  int return_value = 0;
816  return_value = mp_ProjectorForward->Project( FORWARD, m2p_ProjectionLines[a_th], index1, index2, nb_indices );
817  else if (m_useSystemMatrixForward)
818  return_value = mp_SystemMatrixForward->Project( FORWARD, m2p_ProjectionLines[a_th], index1, index2, nb_indices );
819  if (return_value)
820  {
821  Cerr("***** oProjectorManager::ComputeProjectionLine() -> A problem occurred while forward projecting an event !" << endl);
822  return NULL;
823  }
824 
825  // Project backward
827  {
828  // Then project
830  return_value = mp_ProjectorBackward->Project( BACKWARD, m2p_ProjectionLines[a_th], index1, index2, nb_indices );
831  else if (m_useSystemMatrixBackward)
832  return_value = mp_SystemMatrixBackward->Project( BACKWARD, m2p_ProjectionLines[a_th], index1, index2, nb_indices );
833  if (return_value)
834  {
835  Cerr("***** oProjectorManager::ComputeProjectionLine() -> A problem occurred while backward projecting an event !" << endl);
836  return NULL;
837  }
838  }
839 
840  // Return the line
841  return m2p_ProjectionLines[a_th];
842 }
843 
844 // =====================================================================
845 // ---------------------------------------------------------------------
846 // ---------------------------------------------------------------------
847 // =====================================================================
849 {
850  // Check that the mask has not already been set
851  if (mp_mask!=NULL)
852  {
853  Cerr("***** oProjectorManager::ProcessAndSetMask() -> Mask already initialized !" << endl);
854  return 1;
855  }
856  // Allocate
858  // Fill the mask
860  {
861  // Currently, values not greater than 0 are regarded as background
862  // As the mask has a real number type, to avoid issues with zeros potentially written
863  // as extremely tiny floating point values, the values are first rounded to an integer type
864  // and then checked for greater than zero, improve this in the future (implicit behaviour)
865  mp_mask[v] = ((INTNB)std::round(ap_maskImage[v]))>0;
866  }
867  // Mask on
868  m_applyMask = true;
869  // End
870  return 0;
871 }
virtual EVTFLTDATA * GetCustomFLTData()
void SetEventIndex(int a_eventIndex)
Set current index associated to the event.
#define MODE_HISTOGRAM
#define Cerr(MESSAGE)
virtual int ReadOptionsList(const string &a_optionsList)=0
int Initialize()
A function used to initialize the manager and the projectors or system matrices it manages...
uint32_t * GetEventID2()
This class is designed to generically described any on-the-fly projector.
virtual int ReadConfigurationFile(const string &a_configurationFile)=0
#define SPEED_OF_LIGHT_IN_MM_PER_PS
int Initialize()
A public function used to initialize the projector.
int Project(int a_direction, oProjectionLine *ap_ProjectionLine, uint32_t *ap_index1, uint32_t *ap_index2, int a_nbIndices)
void SetVerbose(int a_verbose)
oProjectorManager()
The constructor of oProjectorManager.
void SetSensitivityModeOff()
Say that the projector will no longer be used to compute the global sensitivity.
#define ADAPTATIVE_LIST_COMPUTATION_STRATEGY
void SetScanner(vScanner *ap_Scanner)
void SetTOFSigmaInPs(FLTNB a_TOFSigmaInPs)
This function is used to set the TOF standard deviation associated with the line. ...
static sOutputManager * GetInstance()
Instanciate the singleton object and Initialize member variables if not already done, return a pointer to this object otherwise.
void SetMatchedProjectors(bool a_UseMatchedProjectors)
oImageDimensionsAndQuantification * mp_ImageDimensionsAndQuantification
void SetTOFResolutionInMm(FLTNB *ap_TOFResolutionInMm)
virtual int GetNbCustomFLTData()
static sAddonManager * GetInstance()
int ReadCommonOptionsList(const string &a_optionsList)
#define FIXED_LIST_COMPUTATION_STRATEGY
int64_t GetEventIndex()
Get current index associated to the event.
void SetApplyTOF(int a_applyTOF)
~oProjectorManager()
The destructor of oProjectorManager.
void SetPOIResolution(FLTNB *ap_POIResolution)
bool GetPerEventTOFResolutionFlag() const
Simply return m_perEventTOFResolutionFlag.
int ParseOptionsAndInitializeProjectors()
Parse forward and backward projection options contained in the previously provided strings...
#define DEBUG_VERBOSE(IGNORED1, IGNORED2)
const string & GetPathToConfigDir()
Return the path to the CASTOR config directory.
void SetTOFBinSizeInMm(FLTNB a_TOFBinSizeInMm)
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
void SetCustomINTData(EVTINTDATA *ap_pointer)
int CheckParameters()
A public function used to check the parameters settings.
void SetReadPerEventTOFResolution(bool a_readPerEventTOFResolution)
This function is used to set flag informing that TOF resolution should be read per event from datafil...
oProjectionLine * ComputeProjectionLine(vEvent *ap_Event, int a_th)
void SetTOFMeasurementRangeInMm(FLTNB a_TOFMeasurementRangeInMm)
void Reset()
Reset length and all the voxel indices and weights tabs.
void SetThreadNumber(int a_threadNumber)
void SetTOFMeasurementInPs(FLTNB a_TOFMeasurementInPs)
std::map< string, maker_projector > mp_listOfProjectors
int CheckParameters()
A function used to check the parameters settings.
void SetSensitivityModeOn()
Say that the projector will be used to compute the global sensitivity.
int ProcessAndSetMask(FLTNB *ap_maskImage)
virtual int GetNbCustomINTData()
This class is designed to manage and store system matrix elements associated to a vEvent...
Mother class for the Event objects.
void SetForwardProjector(vProjector *ap_Projector)
FLTNB GetTOFResolutionInPs(int a_reso)
void SetApplyPOI(bool a_applyPOI)
void SetBackwardProjector(vProjector *ap_Projector)
int GetNbThreadsForProjection()
Get the number of threads used for projections.
uint32_t * GetEventID1()
int Project(int a_direction, oProjectionLine *ap_ProjectionLine, uint32_t *ap_index1, uint32_t *ap_index2, int a_nbIndices)
int CheckSPECTAttenuationCompatibility(const string &a_pathToAttenuationImage)
void SetComputationStrategy(int a_computationStrategy)
void SetCustomFLTData(EVTFLTDATA *ap_pointer)
virtual EVTINTDATA * GetCustomINTData()
int SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
Inherit from vDataFile. Class that manages the reading of a PET input file (header + data)...
void SetSensitivityMode(bool a_sensitivityMode)
#define Cout(MESSAGE)