RTK  2.0.1
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:
44  ITK_DISALLOW_COPY_AND_ASSIGN(ImagXGeometryReader);
45 
50 
53 
56 
58  itkNewMacro(Self);
59 
61  itkGetMacro(Geometry, GeometryType::Pointer);
62 
64  using InputImageType = TInputImage;
65  using InputImagePointer = typename InputImageType::Pointer;
66  using InputImageRegionType = typename InputImageType::RegionType;
67  using InputImagePixelType = typename InputImageType::PixelType;
68  using FileNamesContainer = std::vector<std::string>;
69 
72  itkGetMacro(CalibrationXMLFileName, std::string);
73  itkSetMacro(CalibrationXMLFileName, std::string);
75 
77  itkGetMacro(RoomXMLFileName, std::string);
78  itkSetMacro(RoomXMLFileName, std::string);
80 
84  {
85  if ( m_ProjectionsFileNames != name)
86  {
88  this->Modified();
89  }
90  }
92  {
94  }
96 
97 protected:
100 
101  ~ImagXGeometryReader() override = default;
102 
103 
104 private:
105  void GenerateData() override;
106 
107  // DICOM tag for AI versions
108  static const std::string m_AI_VERSION_1p2;
109  static const std::string m_AI_VERSION_1p5;
110  static const std::string m_AI_VERSION_2pX;
111 
112  // DICOM tags depend on AI version
113  std::string getAIversion();
114 
115  // Structure containing the flexmap (for AI versions >= 2.0)
116  struct FlexmapType {
117  bool isValid;
118  std::string activeArcName;
119  std::string activeGeocalUID;
122  bool isCW;
123  std::vector<float> anglesDeg; // Gantry angles [deg]
124  std::vector<float> Px, Py, Pz, // Detector translations
125  Rx, Ry, Rz, // Detector rotations
126  Tx, Ty, Tz; // Source translations
127  };
128 
130 
132  int id0, id1; // indices of angles just below and above the target angle
133  float a0, a1; // weights (1/distance) to angles below and above
134  };
135 
136  InterpResultType interpolate(const std::vector<float>& flexAngles, bool bIsCW, float angleDegree);
137 
138  // Structure containing the calibration models (for AI versions < 2.0)
140  bool isValid;
142  std::vector<float> Px, Py, Pz, // Detector translations model
143  Rx, Ry, Rz, // Detector rotations model
144  Tx, Ty, Tz; // Source translations model
145 
147  sourceToNozzleOffsetAngle = -90.f;
148  Px = std::vector<float>(5, 0.f);
149  Py = std::vector<float>(5, 0.f);
150  Pz = std::vector<float>(5, 0.f);
151  Rx = std::vector<float>(5, 0.f);
152  Ry = std::vector<float>(5, 0.f);
153  Rz = std::vector<float>(5, 0.f);
154  Tx = std::vector<float>(5, 0.f);
155  Ty = std::vector<float>(5, 0.f);
156  Tz = std::vector<float>(5, 0.f);
157  }
158  };
159 
161 
163 
164  bool isCW(const std::vector<float>& angles);
165 
166  std::vector<float> getInterpolatedValue(const InterpResultType& ires, const std::vector<float>& Dx, const std::vector<float>& Dy, const std::vector<float>& Dz);
167 
168  // Evaluate the calibration models for a given angle
169  std::vector<float> getDeformations(float gantryAngle, const std::vector<float>& Dx, const std::vector<float>& Dy, const std::vector<float>& Dz);
170 
171  void addEntryToGeometry(float gantryAngleDegree, float nozzleToRadAngleOffset, float sid, float sdd,
172  std::vector<float>& P, std::vector<float>& R, std::vector<float>& T);
173 
174  void addEntryToGeometry(const FlexmapType& flex, float gantryAngleDegree);
175 
176  void addEntryToGeometry(const CalibrationModelType& calibModel, float gantryAngleDegree);
177 
180  std::string m_RoomXMLFileName;
182 };
183 
184 }
185 #ifndef ITK_MANUAL_INSTANTIATION
186 #include "rtkImagXGeometryReader.hxx"
187 #endif
188 
189 #endif // rtkImagXGeometryReader_h
GeometryType::Pointer m_Geometry
std::vector< float > getDeformations(float gantryAngle, const std::vector< float > &Dx, const std::vector< float > &Dy, const std::vector< float > &Dz)
typename InputImageType::RegionType InputImageRegionType
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
FlexmapType GetGeometryForAI2p1()
FileNamesContainer m_ProjectionsFileNames
~ImagXGeometryReader() override=default
Projection geometry for a source and a 2-D flat panel.
void SetProjectionsFileNames(const FileNamesContainer &name)
typename InputImageType::PixelType InputImagePixelType
InterpResultType interpolate(const std::vector< float > &flexAngles, bool bIsCW, float angleDegree)
CalibrationModelType GetGeometryForAI1p5FromXMLFiles()
std::vector< float > getInterpolatedValue(const InterpResultType &ires, const std::vector< float > &Dx, const std::vector< float > &Dy, const std::vector< float > &Dz)
std::string getAIversion()
static const std::string m_AI_VERSION_2pX
typename InputImageType::Pointer InputImagePointer
static const std::string m_AI_VERSION_1p2
void GenerateData() override
const FileNamesContainer & GetProjectionsFileNames() const
std::vector< std::string > FileNamesContainer
CalibrationModelType GetGeometryForAI1p5()
#define itkSetMacro(name, type)