CASToR  2.0
Tomographic Reconstruction (PET/SPECT/CT)
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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-2018 all CASToR contributors listed below:
18 
19  --> current contributors: Thibaut MERLIN, Simon STUTE, Didier BENOIT, Claude COMTAT, Marina FILIPOVIC, Mael MILLARDET
20  --> past contributors: Valentin VIELZEUF
21 
22 This is CASToR version 2.0.
23 */
24 
31 #ifndef OPROJECTIONLINE_HH
32 #define OPROJECTIONLINE_HH 1
33 
34 #include "gVariables.hh"
36 
53 #define IMAGE_COMPUTATION_STRATEGY 1
54 
60 #define FIXED_LIST_COMPUTATION_STRATEGY 2
61 
65 #define ADAPTATIVE_LIST_COMPUTATION_STRATEGY 3
66 
77 #define FORWARD 0
78 
79 #define BACKWARD 1
80 
82 class vProjector;
83 
84 
93 {
94  // -------------------------------------------------------------------
95  // Constructor & Destructor
96  public:
103  oProjectionLine();
111 
112  // -------------------------------------------------------------------
113  // Public member functions
114  public:
122  int CheckParameters();
129  int Initialize();
134  void ComputeLineLength();
140  bool NotEmptyLine();
145  void Reset();
150  void ApplyOffset();
155  void ApplyBedOffset();
164  INTNB GetVoxelIndex(int a_direction, int a_TOFBin, INTNB a_voxelInLine);
173  void AddVoxelInTOFBin(int a_direction, int a_TOFBin, INTNB a_voxelIndice, FLTNB a_voxelWeight);
184  void AddVoxelAllTOFBins(int a_direction, INTNB a_voxelIndex, FLTNB a_voxelWeight, HPFLTNB* a_tofWeights, INTNB a_tofBinFirst, INTNB a_tofBinLast);
192  void AddVoxel(int a_direction, INTNB a_voxelIndice, FLTNB a_voxelWeight);
201  FLTNB ForwardProject(FLTNB* ap_image = NULL);
213  FLTNB ForwardProjectWithSPECTAttenuation(FLTNB* ap_attenuation, FLTNB* ap_image = NULL);
222  void BackwardProject(FLTNB* ap_image, FLTNB a_value);
234  void BackwardProjectWithSPECTAttenuation(FLTNB* ap_attenuation, FLTNB* ap_image, FLTNB a_value);
241  FLTNB ComputeLineIntegral(int a_direction);
242 
243 
244  // -------------------------------------------------------------------
245  // Get functions
246  public:
255  inline FLTNB GetVoxelWeights(int a_direction, int a_TOFBin, INTNB a_voxelInLine)
256  {return m3p_voxelWeights[a_direction][a_TOFBin][a_voxelInLine];}
264  inline INTNB GetCurrentNbVoxels (int a_direction, int a_TOFBin)
265  {return m2p_currentNbVoxels[a_direction][a_TOFBin];}
271  inline int GetNbTOFBins()
272  {return m_nbTOFBins;}
278  inline FLTNB GetLength()
279  {return m_length;}
286  {return m_computationStrategy;}
292  inline FLTNB* GetPosition1()
293  {return mp_position1;}
299  inline FLTNB* GetPosition2()
300  {return mp_position2;}
307  {return mp_bufferPosition1;}
314  {return mp_bufferPosition2;}
321  {return mp_orientation1;}
328  {return mp_orientation2;}
335  {return mp_bufferOrientation1;}
342  {return mp_bufferOrientation2;}
348  inline FLTNB* GetPOI1()
349  {return mp_POI1;}
355  inline FLTNB* GetPOI2()
356  {return mp_POI2;}
363  {return m_TOFResolution;}
370  {return m_TOFMeasurement;}
377  {return m_TOFBinSize;}
383  inline int GetIndex1()
384  {return m_index1;}
390  inline int GetIndex2()
391  {return m_index2;}
397  inline int GetThreadNumber()
398  {return m_threadNumber;}
405  {return m_bedOffset;}
406 
407 
408  // -------------------------------------------------------------------
409  // Set functions
410  public:
416  inline void SetLength(FLTNB a_length)
417  {m_length = a_length;}
423  inline void SetPOI1(FLTNB* ap_POI1)
424  {mp_POI1 = ap_POI1;}
430  inline void SetPOI2(FLTNB* ap_POI2)
431  {mp_POI2 = ap_POI2;}
437  inline void SetTOFMeasurement(FLTNB a_TOFMeasurement)
438  {m_TOFMeasurement = a_TOFMeasurement;}
444  inline void SetTOFBinSize(FLTNB a_TOFBinSize)
445  {m_TOFBinSize = a_TOFBinSize;}
451  inline void SetIndex1(int a_index1)
452  {m_index1 = a_index1;}
458  inline void SetIndex2(int a_index2)
459  {m_index2 = a_index2;}
465  inline void SetNbTOFBins(int a_nbTOFBins)
466  {m_nbTOFBins = a_nbTOFBins;}
472  inline void SetCurrentTOFBin(int a_TOFBin)
473  {m_currentTOFBin = a_TOFBin;}
479  inline void SetMatchedProjectors(bool a_UseMatchedProjectors)
480  {m_useMatchedProjectors = a_UseMatchedProjectors;}
486  inline void SetTOFResolution(FLTNB a_TOFResolution)
487  {m_TOFResolution = a_TOFResolution;}
493  inline void SetPOIResolution(FLTNB* ap_POIResolution)
494  {mp_POIResolution = ap_POIResolution;}
500  inline void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification* ap_ImageDimensionsAndQuantification)
501  {mp_ImageDimensionsAndQuantification = ap_ImageDimensionsAndQuantification;}
507  inline void SetComputationStrategy(int a_computationStrategy)
508  {m_computationStrategy = a_computationStrategy;}
514  inline void SetForwardProjector(vProjector* ap_Projector)
515  {mp_ForwardProjector = ap_Projector;}
521  inline void SetBackwardProjector(vProjector* ap_Projector)
522  {mp_BackwardProjector = ap_Projector;}
528  inline void SetThreadNumber(int a_threadNumber)
529  {m_threadNumber = a_threadNumber;}
535  inline void SetMultiplicativeCorrection(FLTNB a_multiplicativeCorrection)
536  {m_multiplicativeCorrection = a_multiplicativeCorrection;}
542  inline void SetVerbose(int a_verbose)
543  {m_verbose = a_verbose;}
549  inline void SetBedOffset(FLTNB a_bedOffset)
550  {m_bedOffset = a_bedOffset;}
551 
552 
553  // -------------------------------------------------------------------
554  // Data members
555  private:
556 
557  // Verbose level
558  int m_verbose;
559  // Has been checked ?
560  bool m_checked;
561  // Has been initialized ?
564  // ---------------------------------------------------------------------------------------------------
565  // Common stuff
566  // ---------------------------------------------------------------------------------------------------
567 
568  // The thread number associated to this projection line
570  // The current multiplicative correction factor (that will be applied during forward and backward projections)
572  // Image dimensions
575  // The computation strategy for multiple lines (see comments above)
577  // The bed offset (when multiple bed positions are reconstructed simultaneously
579  // The number of TOF bins, TOF resolution and measurement
585  // The POI and its resolution along the 3 axis
589  // This is the length of the line
591  // These are the positions and orientations of the two end points (the buffer ones are used only as buffer when compression)
600  // These are the indices associated to the two end points (in case of compression, set to -1)
601  int m_index1;
602  int m_index2;
603  // The rest of the data members can be different for forward and backward operations.
604  // However only one operation can be used for simple forward or backward needs.
605  // This is managed by this boolean flag that said if we use matched projectors or not.
610  // ------------------------------------------------------------------------------------------------------
611  // For the rest below, the first pointer is used to discriminate between forward and backward projectors,
612  // while the second pointer discriminates between TOF bins
613  // ------------------------------------------------------------------------------------------------------
614 
615  // The allocated number of voxels corresponds to the maximum number of contributing
616  // voxels a line of the ProjectionLine can handle. Whereas the current number of voxels
617  // is the number of voxels that a line is currently using, when using the LIST_COMPUTATION
618  // strategy.
621  // This contains the voxels indices for each lines, when using the both LIST_COMPUTATION strategies
623  // This contains the voxels weights for both computation strategies
625 };
626 
627 #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
This class is designed to generically described any on-the-fly projector.
Definition: vProjector.hh:76
FLTNB * GetBufferPosition2()
This function is used to get the pointer to the mp_bufferPosition2 (3-values tab).
FLTNB * mp_bufferOrientation1
vProjector * mp_ForwardProjector
FLTNB GetTOFMeasurement()
This function is used to get the TOF measurement.
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.
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.
FLTNB GetTOFResolution()
This function is used to get the TOF resolution.
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 SetTOFBinSize(FLTNB a_TOFBinSize)
This function is used to set the size of a TOF bin in ps.
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
void SetTOFResolution(FLTNB a_TOFResolution)
This function is used to set the TOF resolution in use.
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).
void SetTOFMeasurement(FLTNB a_TOFMeasurement)
This function is used to set the TOF measurement associated to the line.
FLTNB GetTOFBinSize()
This function is used to get the size in ps of a TOF bin.
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.