CASToR  2.0
Tomographic Reconstruction (PET/SPECT/CT)
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
vScanner.cc
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 #include "sScannerManager.hh"
32 #include "vScanner.hh"
33 
34 // =====================================================================
35 // ---------------------------------------------------------------------
36 // ---------------------------------------------------------------------
37 // =====================================================================
38 
40 {
41  // Initialize all members to default values
43  m_verbose = -1;
44  mp_ID = NULL;
45  m_allParametersChecked = false;
46  mp_rotationMatrix = NULL;
47  mp_positionMatrix_ref = NULL;
48  mp_positionMatrix_out = NULL;
51 }
52 
53 // =====================================================================
54 // ---------------------------------------------------------------------
55 // ---------------------------------------------------------------------
56 // =====================================================================
57 
59 {
63 }
64 
65 
66 
67 
68 // =====================================================================
69 // ---------------------------------------------------------------------
70 // ---------------------------------------------------------------------
71 // =====================================================================
72 /*
73  \fn int vScanner::Describe()
74  \brief A function used to describe the generic parts of the datafile
75 */
77 {
79  if (m_verbose==0) return;
80 
81  // Describe the datafile
82  Cout("vScanner::Describe() -> Here is some generic content of the scanner" << endl);
83  if (m_scannerType == 0)
84  Cout(" --> Scanner type: " << GetScannerTypeString() << endl);
85 
86  // Call the specific function of the scanner
88 }
89 
90 
91 
92 // =====================================================================
93 // ---------------------------------------------------------------------
94 // ---------------------------------------------------------------------
95 // =====================================================================
102 {
103  if (m_scannerType == SCANNER_PET)
104  return "SCANNER PET";
106  return "SCANNER SPECT PINHOLE";
108  return "SCANNER SPECT CONVERGENT";
109  else if (m_scannerType == SCANNER_CT)
110  return "SCANNER CT";
111  else if (m_scannerType == SCANNER_SINOGRAM)
112  return "SCANNER SINOGRAM";
113 
114  // Default
115  return "Unknown";
116 }
117 
118 
119 
120 
121 // =====================================================================
122 // ---------------------------------------------------------------------
123 // ---------------------------------------------------------------------
124 // =====================================================================
125 /*
126  \fn ComputeLUT
127  \brief Virtual function which should be implemented by the child classes.
128  It computes the LUT of the scanner from a generic (.geom) file.
129  The vScanner implementation throws error by default as it should be implemented by the child class
130  \todo Make the mother function virtual pure ? (should iScannerSinogram also implement this function ?)
131  \todo iScannerCT implementation will probably consists in computing one projection, then computing
132  the others on-the-fly during reconstruction (Often too much data to keep in memory for CT)
133  Have to check if we offer the precomputation of the entire LUT in some situation, as for PET/SPECT
134  \return 1 (error) if not surcharged by a daughter class
135 */
137 {
138  Cerr("***** vScanner::ComputeLUT() -> Call to ComputeLUT() which is not implemented by the scanner child class !" << endl);
139  return 1;
140 }
141 
142 
143 
144 // =====================================================================
145 // ---------------------------------------------------------------------
146 // ---------------------------------------------------------------------
147 // =====================================================================
148 /*
149  \fn LoadLUT
150  \brief Virtual function which should be implemented by the child classes.
151  Load a precomputed scanner LUT.
152  The vScanner implementation throws error by default as it should be implemented by the child class
153  \todo Make the mother function virtual pure ? (should iScannerSinogram also implement this function ?)
154  \todo iScannerCT implementation will probably consists in computing one projection, then computing
155  the others on-the-fly during reconstruction (Often too much data to keep in memory for CT)
156  Have to check if we offer the precomputation of the entire LUT in some situation, as for PET/SPECT
157  \return 1 (error) if not surcharged by a daughter class
158 */
160 {
161  Cerr("***** vScanner::ComputeLUT() -> Call to ComputeLUT() which is not implemented by the scanner child class !" << endl);
162  return 1;
163 }
164 
165 
166 
167 // =====================================================================
168 // ---------------------------------------------------------------------
169 // ---------------------------------------------------------------------
170 // =====================================================================
171 // ----- PET Specific Functions --- //
172 /*
173  \fn IsAvailableLOR
174  \param a_elt1 : index of the 1st scanner element
175  \param a_elt2 : index of the 2nd scanner element
176  \brief This function is implemented in child classes.
177  Check if the LOR is available according to the scanner restrictions
178  \details This function is related to analytic projection and list-mode sensitivity image generation
179  \return 1 if the LOR is available, 0 otherwise (vScanner implementation returns 1 by default)
180 */
181 int vScanner::IsAvailableLOR(int a_elt1, int a_elt2)
182 {
183  Cerr("***** vScanner::IsAvailableLOR() -> This function is not implemented by the Instantiated scanner class !!" << endl);
184  Cerr(" This function only works with PET scanner objects !!" << endl);
185  return 1;
186 }
187 
188 
189 
190 
191 // =====================================================================
192 // ---------------------------------------------------------------------
193 // ---------------------------------------------------------------------
194 // =====================================================================
195 /*
196  \fn SetPETMaxRingDiff
197  \param a_maxAxialDiffmm
198  \brief Set the maximal axial difference in mm between 2 crystals forming a lor
199  \details This function is surcharged by the PET scanner daughter class
200  Returns an error by default.
201  \return 1 (error) if not surcharged by a daughter class
202 */
204 {
205  Cerr("***** vScanner::SetPETMaxAxialDiffmm() -> This function is not implemented by the Instantiated scanner class !!" << endl);
206  Cerr(" This function only works with PET scanner objects !!" << endl);
207  return 1;
208 }
209 
210 
211 
212 // =====================================================================
213 // ---------------------------------------------------------------------
214 // ---------------------------------------------------------------------
215 // =====================================================================
216 /*
217  \fn PROJ_GetPETSpecificParameters
218  \param ap_maxRingDiff
219  \brief Get geometric PET specific parameters to initialize the datafile
220  \details This function is surcharged by the PET scanner daughter classes
221  Returns an error by default.
222  \return 1 (error) if not surcharged by a daughter class
223 */
225 {
226  Cerr("***** vScanner::PROJ_GetPETSpecificParameters() -> This function is not implemented by the Instantiated scanner class !!" << endl);
227  Cerr(" This function only works with PET scanner objects !!" << endl);
228  return 1;
229 }
230 
231 
232 
233 // =====================================================================
234 // ---------------------------------------------------------------------
235 // ---------------------------------------------------------------------
236 // =====================================================================
237 
238 int vScanner::GetSPECTSpecificParameters(uint16_t* ap_nbOfProjections,
239  uint16_t* ap_nbHeads,
240  FLTNB* ap_acquisitionZoom,
241  uint16_t* ap_nbOfBins,
242  FLTNB* ap_pixSizeXY,
243  FLTNB*& ap_angles,
244  FLTNB*& ap_CORtoDetectorDistance,
245  int* ap_headRotDirection)
246 {
247  Cerr("***** vScanner::GetSPECTSpecificParameters() -> This function is not implemented by the Instantiated scanner class !!" << endl);
248  Cerr(" This function only works with SPECT scanner objects !!" << endl);
249  return 1;
250 }
251 
252 
253 // =====================================================================
254 // ---------------------------------------------------------------------
255 // ---------------------------------------------------------------------
256 // =====================================================================
257 // ----- CT Specific Functions --- //
258 /*
259  \fn GetCTSpecificParameters
260  \param ap_nbOfProjections
261  \param ap_angles
262  \param ap_detectorRotDirection
263  \brief Recover geometric CT specific parameters from the scanner to initialize the datafile
264  \details This function is surcharged by the CT scanner daughter classes
265  Returns an error by default.
266  \return 1 (error) if not surcharged by a daughter class
267 */
268 int vScanner::GetCTSpecificParameters(uint16_t* ap_nbOfProjections,
269  FLTNB*& ap_angles,
270  int* ap_detectorRotDirection)
271 {
272  Cerr("***** vScanner::GetCTSpecificParameters() -> This function is not implemented by the Instantiated scanner class !!" << endl);
273  Cerr(" This function only works with CT scanner objects !!" << endl);
274  return 1;
275 }
276 
277 
278 // =====================================================================
279 // ---------------------------------------------------------------------
280 // ---------------------------------------------------------------------
281 // =====================================================================
282 /*
283  \fn SetRotDirection
284  \param a_rotDirection
285  \brief Set rotation direction of the system
286  \details Set rotation direction of the scanner elements (head for SPECT, rsector/modules for PET)
287  for the generation of the geometry
288  \return 0 if success, positive value otherwise (unknown key)
289 */
290 int vScanner::SetRotDirection( string a_rotDirection )
291 {
292  if( a_rotDirection == "CCW" ||
293  a_rotDirection == "Ccw" ||
294  a_rotDirection == "ccw" )
296 
297  else if(a_rotDirection == "" || // Default
298  a_rotDirection == "CW" ||
299  a_rotDirection == "Cw" ||
300  a_rotDirection == "cw" )
302 
303  else
304  {
305  Cerr("***** vScanner::SetRotDirection -> Error while initializing rotation direction !" << endl);
306  Cerr(" "<< a_rotDirection <<"' is unknown. Direction must be 'CW' (clockwise) or 'CCW' (counter-clockwise).");
307  return 1;
308  }
309 
310  return 0;
311 }
312 
313 
314 // =====================================================================
315 // ---------------------------------------------------------------------
316 // ---------------------------------------------------------------------
317 // =====================================================================
318 /*
319  \fn PROJ_SetSPECTNbBins
320  \param ap_nbOfBins
321  \brief Set SPECT number of Bins
322  \details This function is surcharged by the SPECT scanner daughter classes
323  Returns an error by default.
324  \return 1 (error) if not surcharged by a daughter class
325 */
326 int vScanner::PROJ_SetSPECTNbBins(uint16_t* ap_nbOfBins)
327 {
328  Cerr("***** vScanner::PROJ_SetSPECTNbBins() -> This function is not implemented by the Instantiated scanner class !!" << endl);
329  Cerr(" This function only works with SPECT scanner objects !!" << endl);
330  return 1;
331 }
332 
333 
334 
335 // =====================================================================
336 // ---------------------------------------------------------------------
337 // ---------------------------------------------------------------------
338 // =====================================================================
339 /*
340  \fn PROJ_SetSPECTNbProjections
341  \param a_nbOfProjections
342  \brief Set SPECT number of views
343  \details This function is surcharged by the SPECT scanner daughter classes
344  Returns an error by default.
345  \return 1 (error) if not surcharged by a daughter class
346 */
347 int vScanner::PROJ_SetSPECTNbProjections(uint32_t a_nbOfProjections)
348 {
349  Cerr("***** vScanner::PROJ_SetSPECTNbProjections() -> This function is not implemented by the Instantiated scanner class !!" << endl);
350  Cerr(" This function only works with SPECT scanner objects !!" << endl);
351  return 1;
352 }
353 
354 
355 
356 
357 
358 
359 // =====================================================================
360 // ---------------------------------------------------------------------
361 // ---------------------------------------------------------------------
362 // =====================================================================
363 /*
364  \fn PROJ_SetSPECTAngles
365  \param ap_projectionAngles
366  \brief Set SPECT projection angles
367  \details This function is surcharged by the SPECT scanner daughter classes
368  Returns an error by default.
369  \return 1 (error) if not surcharged by a daughter class
370 */
371 int vScanner::PROJ_SetSPECTAngles(FLTNB* a2p_projectionAngles)
372 {
373  Cerr("***** vScanner::SetSPECTAngles() -> This function is not implemented by the Instantiated scanner class !!" << endl);
374  Cerr(" This function only works with SPECT scanner objects !!" << endl);
375  return 1;
376 }
377 
378 
379 
380 // =====================================================================
381 // ---------------------------------------------------------------------
382 // ---------------------------------------------------------------------
383 // =====================================================================
384 /*
385  \fn PROJ_SetSPECTCORtoDetectorDistance
386  \param a_CORtoDetectorDistance
387  \brief Set distance between center of rotation and SPECT detectors
388  \details This function is surcharged by the SPECT scanner daughter classes
389  Returns an error by default.
390  \return 1 (error) if not surcharged by a daughter class
391 */
393 {
394  Cerr("***** vScanner::SetSPECTCORtoDetectorDistance() -> This function is not implemented by the Instantiated scanner class !!" << endl);
395  Cerr(" This function only works with SPECT scanner objects !!" << endl);
396  return 1;
397 }
398 
399 
400 
401 // =====================================================================
402 // ---------------------------------------------------------------------
403 // ---------------------------------------------------------------------
404 // =====================================================================
405 /*
406  \fn PROJ_GetSPECTNbProjections
407  \brief return the total number of projections for a SPECT acquisition
408  \details This function is surcharged by the SPECT scanner daughter classes
409  Returns an error by default.
410  \return 1 (error) if not surcharged by a daughter class
411 */
413 {
414  Cerr("***** vScanner::GetSPECTNbProjections() -> This function is not implemented by the Instantiated scanner class !!" << endl);
415  Cerr(" This function only works with SPECT scanner objects !!" << endl);
416  return 1;
417 }
418 
419 
420 
421 // =====================================================================
422 // ---------------------------------------------------------------------
423 // ---------------------------------------------------------------------
424 // =====================================================================
425 /*
426  \fn PROJ_GetSPECTNbPixels
427  \brief return the total number of pixels for a SPECT reconstruction
428  \details This function is surcharged by the SPECT scanner daughter classes
429  Returns an error by default.
430  \return 1 (error) if not surcharged by a daughter class
431 */
433 {
434  Cerr("***** vScanner::GetSPECTNbPixels() -> This function is not implemented by the Instantiated scanner class !!" << endl);
435  Cerr(" This function only works with SPECT scanner objects !!" << endl);
436  return 1;
437 }
438 
virtual int PROJ_SetSPECTNbBins(uint16_t *ap_nbOfBins)
Set SPECT number of Bins.
Definition: vScanner.cc:326
virtual int PROJ_SetSPECTNbProjections(uint32_t a_nbOfProjections)
Set SPECT number of views.
Definition: vScanner.cc:347
#define FLTNB
Definition: gVariables.hh:81
virtual int PROJ_GetPETSpecificParameters(FLTNB *ap_maxRingDiff)
Get geometric PET specific parameters to initialize the datafile.
Definition: vScanner.cc:224
virtual int SetPETMaxAxialDiffmm(FLTNB a_maxAxialDiffmm)
Set the maximal axial difference in mm between 2 crystals forming a lor.
Definition: vScanner.cc:203
virtual int PROJ_SetSPECTAngles(FLTNB *ap_projectionAngles)
Set SPECT projection angles.
Definition: vScanner.cc:371
oMatrix * mp_positionMatrix_out
Definition: vScanner.hh:443
#define GEO_ROT_CCW
Definition: vScanner.hh:49
#define SCANNER_UNKNOWN
vScanner()
vScanner constructor. Initialize the member variables to their default values.
Definition: vScanner.cc:39
FLTNB m_defaultBedDisplacementInMm
Definition: vScanner.hh:445
virtual uint16_t PROJ_GetSPECTNbProjections()
return the total number of projections for a SPECT acquisition
Definition: vScanner.cc:412
#define SCANNER_PET
virtual uint16_t PROJ_GetSPECTNbPixels()
return the total number of pixels for a SPECT reconstruction
Definition: vScanner.cc:432
oImageDimensionsAndQuantification * mp_ID
Definition: vScanner.hh:439
virtual void DescribeSpecific()=0
A pure virtual function used to describe the specific parts of the scanner.
oMatrix * mp_rotationMatrix
Definition: vScanner.hh:441
#define Cerr(MESSAGE)
#define SCANNER_SPECT_CONVERGENT
#define VERBOSE_DEBUG_LIGHT
virtual int SetRotDirection(string a_rotDirection)
Set rotation direction of the system.
Definition: vScanner.cc:290
Declaration of class vScanner.
#define SCANNER_SINOGRAM
virtual ~vScanner()
vScanner destructor.
Definition: vScanner.cc:58
void Describe()
A function used to describe the generic parts of the datafile.
Definition: vScanner.cc:76
Declaration of class sScannerManager.
int m_verbose
Definition: vScanner.hh:438
virtual int ComputeLUT()
Virtual function which should be implemented by the child classes. It computes the LUT of the scann...
Definition: vScanner.cc:136
string GetScannerTypeString()
Definition: vScanner.cc:101
bool m_allParametersChecked
Definition: vScanner.hh:440
virtual int GetSPECTSpecificParameters(uint16_t *ap_nbOfProjections, uint16_t *ap_nbHeads, FLTNB *ap_acquisitionZoom, uint16_t *ap_nbOfBins, FLTNB *ap_pixSizeXY, FLTNB *&ap_angles, FLTNB *&ap_CORtoDetectorDistance, int *ap_headRotDirection)
Recover geometric SPECT specific parameters from the scanner to initialize the datafile.
Definition: vScanner.cc:238
#define SCANNER_SPECT_PINHOLE
virtual int PROJ_SetSPECTCORtoDetectorDistance(FLTNB a_CORtoDetectorDistance)
Set distance between center of rotation and SPECT detectors.
Definition: vScanner.cc:392
int m_scannerType
Definition: vScanner.hh:437
oMatrix * mp_positionMatrix_ref
Definition: vScanner.hh:442
#define DEBUG_VERBOSE(IGNORED1, IGNORED2)
virtual int LoadLUT()
Virtual function which should be implemented by the child classes. Load a precomputed scanner LUT...
Definition: vScanner.cc:159
#define Cout(MESSAGE)
#define SCANNER_CT
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...
Definition: vScanner.cc:181
int m_rotDirection
Definition: vScanner.hh:444
virtual int GetCTSpecificParameters(uint16_t *ap_nbOfProjections, FLTNB *&ap_angles, int *ap_detectorRotDirection)
Recover geometric CT specific parameters from the scanner to initialize the datafile.
Definition: vScanner.cc:268
#define GEO_ROT_CW
Definition: vScanner.hh:47