RTK  1.4.0
Reconstruction Toolkit
rtkImagXGeometryReader.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright RTK Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 
19 #ifndef rtkImagXGeometryReader_h
20 #define rtkImagXGeometryReader_h
21 
22 #include <itkLightProcessObject.h>
24 
25 #include <vector>
26 
27 namespace rtk
28 {
29 
40 template< typename TInputImage >
42 {
43 public:
48 
51 
54 
56  itkNewMacro(Self);
57 
59  itkGetMacro(Geometry, GeometryType::Pointer);
60 
62  typedef TInputImage InputImageType;
63  typedef typename InputImageType::Pointer InputImagePointer;
64  typedef typename InputImageType::RegionType InputImageRegionType;
65  typedef typename InputImageType::PixelType InputImagePixelType;
66  typedef std::vector<std::string> FileNamesContainer;
67 
70  itkGetMacro(CalibrationXMLFileName, std::string);
71  itkSetMacro(CalibrationXMLFileName, std::string);
73 
75  itkGetMacro(RoomXMLFileName, std::string);
76  itkSetMacro(RoomXMLFileName, std::string);
78 
81  void SetProjectionsFileNames (const FileNamesContainer &name)
82  {
83  if ( m_ProjectionsFileNames != name)
84  {
86  this->Modified();
87  }
88  }
89  const FileNamesContainer & GetProjectionsFileNames() const
90  {
92  }
94 
95 protected:
97  : m_Geometry(ITK_NULLPTR), m_CalibrationXMLFileName(""), m_RoomXMLFileName("") {};
98 
99  virtual ~ImagXGeometryReader() ITK_OVERRIDE {}
100 
101 
102 private:
103  //purposely not implemented
104  ImagXGeometryReader(const Self&);
105  void operator=(const Self&);
106 
107  void GenerateData() ITK_OVERRIDE;
108 
109  // DICOM tag for AI versions
110  static const std::string m_AI_VERSION_1p2;
111  static const std::string m_AI_VERSION_1p5;
112  static const std::string m_AI_VERSION_2pX;
113 
114  // DICOM tags depend on AI version
115  std::string getAIversion();
116 
117  // Structure containing the flexmap (for AI versions >= 2.0)
118  struct FlexmapType {
119  bool isValid;
120  std::string activeArcName;
121  std::string activeGeocalUID;
124  bool isCW;
125  std::vector<float> anglesDeg; // Gantry angles [deg]
126  std::vector<float> Px, Py, Pz, // Detector translations
127  Rx, Ry, Rz, // Detector rotations
128  Tx, Ty, Tz; // Source translations
129  };
130 
132 
134  int id0, id1; // indices of angles just below and above the target angle
135  float a0, a1; // weights (1/distance) to angles below and above
136  };
137 
138  InterpResultType interpolate(const std::vector<float>& flexAngles, bool isCW, float angleDegree);
139 
140  // Structure containing the calibration models (for AI versions < 2.0)
142  bool isValid;
144  std::vector<float> Px, Py, Pz, // Detector translations model
145  Rx, Ry, Rz, // Detector rotations model
146  Tx, Ty, Tz; // Source translations model
147 
149  sourceToNozzleOffsetAngle = -90.f;
150  Px = std::vector<float>(5, 0.f);
151  Py = std::vector<float>(5, 0.f);
152  Pz = std::vector<float>(5, 0.f);
153  Rx = std::vector<float>(5, 0.f);
154  Ry = std::vector<float>(5, 0.f);
155  Rz = std::vector<float>(5, 0.f);
156  Tx = std::vector<float>(5, 0.f);
157  Ty = std::vector<float>(5, 0.f);
158  Tz = std::vector<float>(5, 0.f);
159  }
160  };
161 
163 
165 
166  bool isCW(const std::vector<float>& angles);
167 
168  std::vector<float> getInterpolatedValue(const InterpResultType& ires, const std::vector<float>& Dx, const std::vector<float>& Dy, const std::vector<float>& Dz);
169 
170  // Evaluate the calibration models for a given angle
171  std::vector<float> getDeformations(float gantryAngle, const std::vector<float>& Dx, const std::vector<float>& Dy, const std::vector<float>& Dz);
172 
173  void addEntryToGeometry(float gantryAngleDegree, float nozzleToRadAngleOffset, float sid, float sdd,
174  std::vector<float>& P, std::vector<float>& R, std::vector<float>& T);
175 
176  void addEntryToGeometry(const FlexmapType& flex, float gantryAngleDegree);
177 
178  void addEntryToGeometry(const CalibrationModelType& calibModel, float gantryAngleDegree);
179 
182  std::string m_RoomXMLFileName;
183  FileNamesContainer m_ProjectionsFileNames;
184 };
185 
186 }
187 #ifndef ITK_MANUAL_INSTANTIATION
188 #include "rtkImagXGeometryReader.hxx"
189 #endif
190 
191 #endif // rtkImagXGeometryReader_h
GeometryType::Pointer m_Geometry
InputImageType::RegionType InputImageRegionType
std::vector< float > getDeformations(float gantryAngle, const std::vector< float > &Dx, const std::vector< float > &Dy, const std::vector< float > &Dz)
itk::LightProcessObject Superclass
InputImageType::PixelType InputImagePixelType
void addEntryToGeometry(float gantryAngleDegree, float nozzleToRadAngleOffset, float sid, float sdd, std::vector< float > &P, std::vector< float > &R, std::vector< float > &T)
static const std::string m_AI_VERSION_1p5
itk::SmartPointer< Self > Pointer
FlexmapType GetGeometryForAI2p1()
FileNamesContainer m_ProjectionsFileNames
Projection geometry for a source and a 2-D flat panel.
void SetProjectionsFileNames(const FileNamesContainer &name)
void operator=(const Self &)
CalibrationModelType GetGeometryForAI1p5FromXMLFiles()
std::vector< std::string > FileNamesContainer
std::vector< float > getInterpolatedValue(const InterpResultType &ires, const std::vector< float > &Dx, const std::vector< float > &Dy, const std::vector< float > &Dz)
InterpResultType interpolate(const std::vector< float > &flexAngles, bool isCW, float angleDegree)
InputImageType::Pointer InputImagePointer
std::string getAIversion()
virtual ~ImagXGeometryReader() override
static const std::string m_AI_VERSION_2pX
static const std::string m_AI_VERSION_1p2
void GenerateData() override
const FileNamesContainer & GetProjectionsFileNames() const
CalibrationModelType GetGeometryForAI1p5()
#define itkSetMacro(name, type)
ThreeDCircularProjectionGeometry GeometryType