CASToR  3.0
Tomographic Reconstruction (PET/SPECT/CT)
oProjectionLine.hh
Go to the documentation of this file.
1 /*
2 This file is part of CASToR.
3 
4  CASToR is free software: you can redistribute it and/or modify it under the
5  terms of the GNU General Public License as published by the Free Software
6  Foundation, either version 3 of the License, or (at your option) any later
7  version.
8 
9  CASToR is distributed in the hope that it will be useful, but WITHOUT ANY
10  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12  details.
13 
14  You should have received a copy of the GNU General Public License along with
15  CASToR (in file GNU_GPL.TXT). If not, see <http://www.gnu.org/licenses/>.
16 
17 Copyright 2017-2019 all CASToR contributors listed below:
18 
19  --> Didier BENOIT, Claude COMTAT, Marina FILIPOVIC, Thibaut MERLIN, Mael MILLARDET, Simon STUTE, Valentin VIELZEUF
20 
21 This is CASToR version 3.0.
22 */
23 
30 #ifndef OPROJECTIONLINE_HH
31 #define OPROJECTIONLINE_HH 1
32 
33 #include "gVariables.hh"
35 
52 #define IMAGE_COMPUTATION_STRATEGY 1
53 
59 #define FIXED_LIST_COMPUTATION_STRATEGY 2
60 
64 #define ADAPTATIVE_LIST_COMPUTATION_STRATEGY 3
65 
76 #define FORWARD 0
77 
78 #define BACKWARD 1
79 
81 class vProjector;
82 
83 
92 {
93  // -------------------------------------------------------------------
94  // Constructor & Destructor
95  public:
102  oProjectionLine();
110 
111  // -------------------------------------------------------------------
112  // Public member functions
113  public:
121  int CheckParameters();
128  int Initialize();
133  void ComputeLineLength();
139  bool NotEmptyLine();
144  void Reset();
149  void ApplyOffset();
154  void ApplyBedOffset();
163  INTNB GetVoxelIndex(int a_direction, int a_TOFBin, INTNB a_voxelInLine);
172  void AddVoxelInTOFBin(int a_direction, int a_TOFBin, INTNB a_voxelIndice, FLTNB a_voxelWeight);
183  void AddVoxelAllTOFBins(int a_direction, INTNB a_voxelIndex, FLTNB a_voxelWeight, HPFLTNB* a_tofWeights, INTNB a_tofBinFirst, INTNB a_tofBinLast);
191  void AddVoxel(int a_direction, INTNB a_voxelIndice, FLTNB a_voxelWeight);
200  FLTNB ForwardProject(FLTNB* ap_image = NULL);
212  FLTNB ForwardProjectWithSPECTAttenuation(FLTNB* ap_attenuation, FLTNB* ap_image = NULL);
221  void BackwardProject(FLTNB* ap_image, FLTNB a_value);
233  void BackwardProjectWithSPECTAttenuation(FLTNB* ap_attenuation, FLTNB* ap_image, FLTNB a_value);
240  FLTNB ComputeLineIntegral(int a_direction);
241 
242 
243  // -------------------------------------------------------------------
244  // Get functions
245  public:
254  inline FLTNB GetVoxelWeights(int a_direction, int a_TOFBin, INTNB a_voxelInLine)
255  {return m3p_voxelWeights[a_direction][a_TOFBin][a_voxelInLine];}
263  inline INTNB GetCurrentNbVoxels (int a_direction, int a_TOFBin)
264  {return m2p_currentNbVoxels[a_direction][a_TOFBin];}
270  inline int GetNbTOFBins()
271  {return m_nbTOFBins;}
277  inline FLTNB GetLength()
278  {return m_length;}
285  {return m_computationStrategy;}
291  inline FLTNB* GetPosition1()
292  {return mp_position1;}
298  inline FLTNB* GetPosition2()
299  {return mp_position2;}
306  {return mp_bufferPosition1;}
313  {return mp_bufferPosition2;}
320  {return mp_orientation1;}
327  {return mp_orientation2;}
334  {return mp_bufferOrientation1;}
341  {return mp_bufferOrientation2;}
347  inline FLTNB* GetPOI1()
348  {return mp_POI1;}
354  inline FLTNB* GetPOI2()
355  {return mp_POI2;}
362  {return m_TOFMeasurementInPs;}
363 
369  inline int GetIndex1()
370  {return m_index1;}
376  inline int GetIndex2()
377  {return m_index2;}
383  inline int GetThreadNumber()
384  {return m_threadNumber;}
391  {return m_bedOffset;}
392 
393 
394  // -------------------------------------------------------------------
395  // Set functions
396  public:
402  inline void SetLength(FLTNB a_length)
403  {m_length = a_length;}
409  inline void SetPOI1(FLTNB* ap_POI1)
410  {mp_POI1 = ap_POI1;}
416  inline void SetPOI2(FLTNB* ap_POI2)
417  {mp_POI2 = ap_POI2;}
423  inline void SetTOFMeasurementInPs(FLTNB a_TOFMeasurementInPs)
424  {m_TOFMeasurementInPs = a_TOFMeasurementInPs;}
425 
431  inline void SetIndex1(int a_index1)
432  {m_index1 = a_index1;}
438  inline void SetIndex2(int a_index2)
439  {m_index2 = a_index2;}
445  inline void SetNbTOFBins(int a_nbTOFBins)
446  {m_nbTOFBins = a_nbTOFBins;}
452  inline void SetCurrentTOFBin(int a_TOFBin)
453  {m_currentTOFBin = a_TOFBin;}
459  inline void SetMatchedProjectors(bool a_UseMatchedProjectors)
460  {m_useMatchedProjectors = a_UseMatchedProjectors;}
466  inline void SetPOIResolution(FLTNB* ap_POIResolution)
467  {mp_POIResolution = ap_POIResolution;}
473  inline void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification* ap_ImageDimensionsAndQuantification)
474  {mp_ImageDimensionsAndQuantification = ap_ImageDimensionsAndQuantification;}
480  inline void SetComputationStrategy(int a_computationStrategy)
481  {m_computationStrategy = a_computationStrategy;}
487  inline void SetForwardProjector(vProjector* ap_Projector)
488  {mp_ForwardProjector = ap_Projector;}
494  inline void SetBackwardProjector(vProjector* ap_Projector)
495  {mp_BackwardProjector = ap_Projector;}
501  inline void SetThreadNumber(int a_threadNumber)
502  {m_threadNumber = a_threadNumber;}
508  inline void SetMultiplicativeCorrection(FLTNB a_multiplicativeCorrection)
509  {m_multiplicativeCorrection = a_multiplicativeCorrection;}
515  inline void SetVerbose(int a_verbose)
516  {m_verbose = a_verbose;}
522  inline void SetBedOffset(FLTNB a_bedOffset)
523  {m_bedOffset = a_bedOffset;}
524 
525 
526  // -------------------------------------------------------------------
527  // Data members
528  private:
529 
530  // Verbose level
531  int m_verbose;
532  // Has been checked ?
533  bool m_checked;
534  // Has been initialized ?
537  // ---------------------------------------------------------------------------------------------------
538  // Common stuff
539  // ---------------------------------------------------------------------------------------------------
540 
541  // The thread number associated to this projection line
543  // The current multiplicative correction factor (that will be applied during forward and backward projections)
545  // Image dimensions
548  // The computation strategy for multiple lines (see comments above)
550  // The bed offset (when multiple bed positions are reconstructed simultaneously
552  // The number of TOF bins, TOF resolution and measurement
556  // The POI and its resolution along the 3 axis
560  // This is the length of the line
562  // These are the positions and orientations of the two end points (the buffer ones are used only as buffer when compression)
571  // These are the indices associated to the two end points (in case of compression, set to -1)
572  int m_index1;
573  int m_index2;
574  // The rest of the data members can be different for forward and backward operations.
575  // However only one operation can be used for simple forward or backward needs.
576  // This is managed by this boolean flag that said if we use matched projectors or not.
581  // ------------------------------------------------------------------------------------------------------
582  // For the rest below, the first pointer is used to discriminate between forward and backward projectors,
583  // while the second pointer discriminates between TOF bins
584  // ------------------------------------------------------------------------------------------------------
585 
586  // The allocated number of voxels corresponds to the maximum number of contributing
587  // voxels a line of the ProjectionLine can handle. Whereas the current number of voxels
588  // is the number of voxels that a line is currently using, when using the LIST_COMPUTATION
589  // strategy.
592  // This contains the voxels indices for each lines, when using the both LIST_COMPUTATION strategies
594  // This contains the voxels weights for both computation strategies
596 };
597 
598 #endif
This header file is mainly used to declare some macro definitions and all includes needed from the st...
void SetMultiplicativeCorrection(FLTNB a_multiplicativeCorrection)
This function is used to set the multiplicative correction to be applied during forward and backward ...
~oProjectionLine()
The destructor of oProjectionLine.
Declaration of class oImageDimensionsAndQuantification.
FLTNB * GetOrientation1()
This function is used to get the pointer to the mp_orientation1 (3-values tab).
FLTNB * GetPOI1()
This function is used to get the pointer to POI of point 1 (3-values tab).
FLTNB ForwardProjectWithSPECTAttenuation(FLTNB *ap_attenuation, FLTNB *ap_image=NULL)
Forward projects the provided image for the current TOF bin with an inner loop on the attenuation (fo...
void SetThreadNumber(int a_threadNumber)
This function is used to set the thread number of this particular line.
#define FLTNB
Definition: gVariables.hh:81
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
This function is used to set the pointer to the oImageDimensionsAndQuantification in use...
void SetMatchedProjectors(bool a_UseMatchedProjectors)
This function is used to set the boolean that says if we use matched projectors.
void AddVoxelAllTOFBins(int a_direction, INTNB a_voxelIndex, FLTNB a_voxelWeight, HPFLTNB *a_tofWeights, INTNB a_tofBinFirst, INTNB a_tofBinLast)
Add a voxel contribution to the line for all relevant TOF bins.
#define HPFLTNB
Definition: gVariables.hh:83
FLTNB GetTOFMeasurementInPs()
This function is used to get the TOF measurement in ps.
This class is designed to generically described any on-the-fly projector.
Definition: vProjector.hh:75
FLTNB * GetBufferPosition2()
This function is used to get the pointer to the mp_bufferPosition2 (3-values tab).
FLTNB * mp_bufferOrientation1
vProjector * mp_ForwardProjector
void SetCurrentTOFBin(int a_TOFBin)
This function is used to set the current TOF bin that is used.
void SetLength(FLTNB a_length)
This function is used to set the length of the line.
void SetTOFMeasurementInPs(FLTNB a_TOFMeasurementInPs)
This function is used to set the TOF measurement associated to the line.
FLTNB * GetBufferPosition1()
This function is used to get the pointer to the mp_bufferPosition1 (3-values tab).
FLTNB GetLength()
This function is used to get the length of the line.
FLTNB * GetOrientation2()
This function is used to get the pointer to the mp_orientation2 (3-values tab).
int GetThreadNumber()
This function is used to get the thread number associated to this line.
int GetComputationStrategy()
This function is used to get the computation strategy.
void SetIndex2(int a_index2)
This function is used to set the index m_index1 of point 2.
FLTNB GetBedOffset()
This function is used to get the axial bed offset associated to this line.
oProjectionLine()
The constructor of oProjectionLine.
void ComputeLineLength()
Simply compute and update the m_length using the associated mp_position1 and mp_position2.
INTNB GetVoxelIndex(int a_direction, int a_TOFBin, INTNB a_voxelInLine)
This function is used to get the contributing voxel index of the provided direction, TOF bin and voxel rank.
INTNB *** m3p_voxelIndices
void BackwardProject(FLTNB *ap_image, FLTNB a_value)
Simply backward projects the provided value inside the provided image, for the current TOF bin...
int GetIndex2()
This function is used to get the index associated to point 2.
void ApplyOffset()
Apply the offset of oImageDimensionsAndQuantification to the mp_position1 and mp_position2.
FLTNB * GetPosition1()
This function is used to get the pointer to the mp_position1 (3-values tab).
void SetComputationStrategy(int a_computationStrategy)
This function is used to set the computation strategy in use.
FLTNB *** m3p_voxelWeights
FLTNB * GetBufferOrientation1()
This function is used to get the pointer to the mp_bufferOrientation1 (3-values tab).
void BackwardProjectWithSPECTAttenuation(FLTNB *ap_attenuation, FLTNB *ap_image, FLTNB a_value)
Backward project the provided value inside the provided image with an inner loop on the attenuation (...
void AddVoxel(int a_direction, INTNB a_voxelIndice, FLTNB a_voxelWeight)
This function is used to add a voxel contribution to the line, assuming TOF bin 0 (i...
void SetBedOffset(FLTNB a_bedOffset)
This function is used to set the bed offset.
void SetNbTOFBins(int a_nbTOFBins)
This function is used to set the number of TOF bins in use.
INTNB GetCurrentNbVoxels(int a_direction, int a_TOFBin)
This function is used to get the current number of contributing voxels to the line.
void SetPOI2(FLTNB *ap_POI2)
This function is used to set the POI of point 2.
void Reset()
Reset length and all the voxel indices and weights tabs.
FLTNB * GetBufferOrientation2()
This function is used to get the pointer to the mp_bufferOrientation2 (3-values tab).
void SetVerbose(int a_verbose)
This function is used to set the verbose level.
bool NotEmptyLine()
This function is used to know if the line contains any voxel contribution.
FLTNB m_multiplicativeCorrection
void SetIndex1(int a_index1)
This function is used to set the index m_index1 of point 1.
void SetBackwardProjector(vProjector *ap_Projector)
This function is used to set the pointer to the backward projector.
void SetPOI1(FLTNB *ap_POI1)
This function is used to set the POI of point 1.
#define INTNB
Definition: gVariables.hh:92
This class is designed to manage and store system matrix elements associated to a vEvent...
void SetPOIResolution(FLTNB *ap_POIResolution)
This function is used to set the POI resolution along the 3 axes.
void SetForwardProjector(vProjector *ap_Projector)
This function is used to set the pointer to the forward projector.
FLTNB ForwardProject(FLTNB *ap_image=NULL)
Simply forward projects the provided image if not null, or else 1, for the current TOF bin...
FLTNB * mp_bufferPosition1
int GetNbTOFBins()
This function is used to get the number of TOF bins in use.
This class is designed to manage all dimensions and quantification related stuff. ...
FLTNB GetVoxelWeights(int a_direction, int a_TOFBin, INTNB a_voxelInLine)
This function is used to get the contributing voxel weight of the provided direction, TOF bin and voxel rank.
FLTNB * mp_bufferOrientation2
FLTNB * GetPosition2()
This function is used to get the pointer to the mp_position2 (3-values tab).
oImageDimensionsAndQuantification * mp_ImageDimensionsAndQuantification
INTNB ** m2p_allocatedNbVoxels
FLTNB * GetPOI2()
This function is used to get the pointer to POI of point 2 (3-values tab).
void AddVoxelInTOFBin(int a_direction, int a_TOFBin, INTNB a_voxelIndice, FLTNB a_voxelWeight)
This function is used to add a voxel contribution to the line and provided TOF bin.
int CheckParameters()
A function used to check the parameters settings.
int Initialize()
A function used to initialize a bunch of stuff after parameters have been checked.
FLTNB * mp_bufferPosition2
int GetIndex1()
This function is used to get the index associated to point 1.
void ApplyBedOffset()
Apply the bed offset of m_bedOffset to the mp_position1 and mp_position2.
INTNB ** m2p_currentNbVoxels
vProjector * mp_BackwardProjector
FLTNB ComputeLineIntegral(int a_direction)
It simply computes the sum of all voxels contributions following the provided direction.