go home Home | Main Page | Topics | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
Loading...
Searching...
No Matches
itkElastixRegistrationMethod.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
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 *
20 * Copyright UMC Utrecht and contributors
21 *
22 * Licensed under the Apache License, Version 2.0 (the "License");
23 * you may not use this file except in compliance with the License.
24 * You may obtain a copy of the License at
25 *
26 * http://www.apache.org/licenses/LICENSE-2.0.txt
27 *
28 * Unless required by applicable law or agreed to in writing, software
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
33 *
34 *=========================================================================*/
35#ifndef itkElastixRegistrationMethod_h
36#define itkElastixRegistrationMethod_h
37
38#include "itkImageSource.h"
40#include "itkElastixLogLevel.h"
41
42#include "elxElastixMain.h"
43#include "elxElastixTemplate.h"
44#include "elxElastixBase.h"
45#include "elxTransformBase.h"
46#include "elxParameterObject.h"
47
54
55namespace itk
56{
57
58template <typename TFixedImage, typename TMovingImage>
59class ITK_TEMPLATE_EXPORT ElastixRegistrationMethod : public itk::ImageSource<TFixedImage>
60{
61public:
63
66 using Superclass = ImageSource<TFixedImage>;
67 using Pointer = SmartPointer<Self>;
68 using ConstPointer = SmartPointer<const Self>;
69
71 itkNewMacro(Self);
72
75
79 using ElastixMainVectorType = std::vector<ElastixMainPointer>;
82 using ArgumentMapEntryType = ArgumentMapType::value_type;
84
87 using DataObjectContainerIterator = DataObjectContainerType::Iterator;
88 using DataObjectIdentifierType = ProcessObject::DataObjectIdentifierType;
89 using DataObjectPointerArraySizeType = ProcessObject::DataObjectPointerArraySizeType;
90 using NameArrayType = ProcessObject::NameArray;
91
98
99 static constexpr unsigned int FixedImageDimension = TFixedImage::ImageDimension;
100 static constexpr unsigned int MovingImageDimension = TMovingImage::ImageDimension;
101
103 "ElastixRegistrationMethod assumes that fixed and moving image have the same number of dimensions.");
104 static constexpr unsigned int ImageDimension = TFixedImage::ImageDimension;
105
106 template <typename TCoordinate>
107 using PointContainerType = VectorContainer<IdentifierType, Point<TCoordinate, ImageDimension>>;
108
109 using FixedMaskType = Image<unsigned char, FixedImageDimension>;
110 using MovingMaskType = Image<unsigned char, MovingImageDimension>;
111 using TransformType = Transform<double, FixedImageDimension, MovingImageDimension>;
112
113 using FixedImageType = TFixedImage;
114 using MovingImageType = TMovingImage;
116
118 virtual void
119 SetFixedImage(TFixedImage * fixedImage);
120 virtual void
121 AddFixedImage(TFixedImage * fixedImage);
122 const FixedImageType *
124 const FixedImageType *
125 GetFixedImage(const unsigned int index) const;
126 unsigned int
128
130 virtual void
131 SetMovingImage(TMovingImage * movingImages);
132 virtual void
133 AddMovingImage(TMovingImage * movingImage);
134 const MovingImageType *
136 const MovingImageType *
137 GetMovingImage(const unsigned int index) const;
138 unsigned int
140
142 virtual void
144 virtual void
146 const FixedMaskType *
148 const FixedMaskType *
149 GetFixedMask(const unsigned int index) const;
150 void
152 unsigned int
154
156 virtual void
158 virtual void
160 const MovingMaskType *
162 const MovingMaskType *
163 GetMovingMask(const unsigned int index) const;
164 virtual void
166 unsigned int
168
169 itkSetConstObjectMacro(FixedPoints, PointContainerType<double>);
170 itkSetConstObjectMacro(MovingPoints, PointContainerType<double>);
171
172 void
177
178 void
183
185 virtual void
189 const ParameterObjectType *
191
195 const ParameterObjectType *
197 using Superclass::GetOutput;
198 DataObject *
199 GetOutput(unsigned int idx);
200 const DataObject *
201 GetOutput(unsigned int idx) const;
204
205 /* \note When "WriteResultImage" is false, the output image will be empty. */
206 const ResultImageType *
207 GetOutput() const;
208
209 /* Standard filter indexed input / output methods */
210 void
212 const FixedImageType *
213 GetInput() const;
214 void
215 SetInput(DataObjectPointerArraySizeType index, DataObject * input);
216 const DataObject *
218
221
222 itkGetConstMacro(InitialTransformParameterFileName, std::string);
223 virtual void
228
230 void
232
234 const TransformType *
236 {
237 return m_InitialTransform;
238 }
239
241 void
243
252
254 void
256
258 itkSetMacro(FixedPointSetFileName, std::string);
259 itkGetConstMacro(FixedPointSetFileName, std::string);
260 void
265
267 itkSetMacro(MovingPointSetFileName, std::string);
268 itkGetConstMacro(MovingPointSetFileName, std::string);
269 void
274
276 itkSetMacro(OutputDirectory, std::string);
277 itkGetConstMacro(OutputDirectory, std::string);
278 void
280 {
281 this->SetOutputDirectory("");
282 }
283
285 void
286 SetLogFileName(const std::string logFileName);
287
288 itkGetConstMacro(LogFileName, std::string);
289 void
291
293 itkSetMacro(LogToConsole, bool);
294 itkGetConstReferenceMacro(LogToConsole, bool);
295 itkBooleanMacro(LogToConsole);
296
298 itkSetMacro(LogToFile, bool);
299 itkGetConstReferenceMacro(LogToFile, bool);
300 itkBooleanMacro(LogToFile);
301
303 void
305 {
306 m_EnableOutput = false;
307 }
308
309 itkSetMacro(LogLevel, ElastixLogLevel);
310 itkGetConstMacro(LogLevel, ElastixLogLevel);
311
312 itkSetMacro(NumberOfThreads, int);
313 itkGetConstMacro(NumberOfThreads, int);
314
316 unsigned int
318
321 GetNthTransform(const unsigned int n) const;
322
326
329 static SmartPointer<TransformType>
331
332protected:
334
335 void
336 GenerateData() override;
337
338 using DataObjectPointer = ProcessObject::DataObjectPointer;
339 using Superclass::MakeOutput;
342
343private:
344 static SmartPointer<PointContainerType<double>>
346 {
347 if (floatPointContainer)
348 {
349 const auto result = PointContainerType<double>::New();
350 result->assign(floatPointContainer->cbegin(), floatPointContainer->cend());
351 return result;
352 }
353 else
354 {
355 return nullptr;
356 }
357 }
358
360 std::string
362
364 bool
365 IsInputOfType(const DataObjectIdentifierType & InputOfType, const DataObjectIdentifierType & inputName) const;
366
368 unsigned int
370
372 void
374
375
377 template <typename TImage>
378 std::vector<TImage *>
379 GetInputImages(const char * const inputTypeString)
380 {
381 std::vector<TImage *> images;
382 for (const auto & inputName : this->GetInputNames())
383 {
384 if (this->IsInputOfType(inputTypeString, inputName))
385 {
386 images.push_back(itkDynamicCastInDebugMode<TImage *>(this->ProcessObject::GetInput(inputName)));
387 }
388 }
389 return images;
390 }
391
392 void
400
401 void
411
413 using Superclass::SetInput;
414
417
420
421 SmartPointer<const elx::ElastixMain> m_ElastixMain{};
422
424 SmartPointer<const elx::ParameterObject> m_InitialTransformParameterObject{};
425 SmartPointer<const TransformType> m_InitialTransform{};
426 SmartPointer<TransformType> m_ExternalInitialTransform{};
427
430
431 SmartPointer<const PointContainerType<double>> m_FixedPoints{};
432 SmartPointer<const PointContainerType<double>> m_MovingPoints{};
433
434 std::string m_OutputDirectory{};
435 std::string m_LogFileName{};
436
437 bool m_EnableOutput{ true };
438 bool m_LogToConsole{ false };
439 bool m_LogToFile{ false };
440
442
444
445 unsigned int m_InputUID{ 0 };
446};
447
448} // namespace itk
449
450#ifndef ITK_MANUAL_INSTANTIATION
451# include "itkElastixRegistrationMethod.hxx"
452#endif
453
454#endif // itkElastixRegistrationMethod_h
A class with all functionality to configure elastix.
itk::SmartPointer< Self > Pointer
ElastixBase::FlatDirectionCosinesType FlatDirectionCosinesType
Definition elxMainBase.h:70
ElastixBase::DataObjectContainerType DataObjectContainerType
Definition elxMainBase.h:67
ElastixBase::DataObjectContainerPointer DataObjectContainerPointer
Definition elxMainBase.h:69
itk::Object::Pointer ObjectPointer
Definition elxMainBase.h:61
Configuration::CommandLineArgumentMapType ArgumentMapType
Definition elxMainBase.h:65
itk::SmartPointer< Self > Pointer
std::map< ParameterKeyType, ParameterValueVectorType > ParameterMapType
itk::SmartPointer< const Self > ConstPointer
std::vector< ParameterValueType > ParameterValueVectorType
std::vector< ParameterMapType > ParameterMapVectorType
This class combines two transforms: an 'initial transform' with a 'current transform'.
virtual void AddFixedImage(TFixedImage *fixedImage)
SmartPointer< const PointContainerType< double > > m_FixedPoints
static constexpr unsigned int MovingImageDimension
void SetExternalInitialTransform(TransformType *)
unsigned int GetNumberOfFixedImages() const
Image< unsigned char, FixedImageDimension > FixedMaskType
unsigned int GetNumberOfMovingImages() const
Transform< double, FixedImageDimension, MovingImageDimension > TransformType
const ResultImageType * GetOutput() const
std::vector< ElastixMainPointer > ElastixMainVectorType
const FixedImageType * GetFixedImage() const
unsigned int GetNumberOfMovingMasks() const
std::vector< TImage * > GetInputImages(const char *const inputTypeString)
ParameterObjectType::ParameterMapType ParameterMapType
void SetLogFileName(const std::string logFileName)
void SetInput(DataObjectPointerArraySizeType index, DataObject *input)
SmartPointer< const PointContainerType< double > > m_MovingPoints
SmartPointer< const elx::ParameterObject > m_InitialTransformParameterObject
TransformType * GetExternalInitialTransform() const
ParameterObjectType::ConstPointer ParameterObjectConstPointer
const MovingMaskType * GetMovingMask() const
virtual void SetOutputDirectory(std::string _arg)
void SetInitialTransformParameterObject(const elx::ParameterObject *)
virtual void SetFixedMask(FixedMaskType *fixedMask)
void RemoveInputsOfType(const DataObjectIdentifierType &inputName)
AdvancedCombinationTransformType * GetAdvancedCombinationTransform() const
DataObjectContainerType::Iterator DataObjectContainerIterator
DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override
ParameterObjectType::Pointer ParameterObjectPointer
ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
TransformType * GetNthTransform(const unsigned int n) const
ParameterObjectType::ParameterMapVectorType ParameterMapVectorType
virtual void SetMovingPoints(const PointContainerType< double > *_arg)
ArgumentMapType::value_type ArgumentMapEntryType
static constexpr unsigned int FixedImageDimension
ResultImageType * GetOutput()
ParameterObjectType::ParameterValueVectorType ParameterValueVectorType
const FixedMaskType * GetFixedMask() const
Image< unsigned char, MovingImageDimension > MovingMaskType
ElastixMainType::DataObjectContainerType DataObjectContainerType
unsigned int GetNumberOfFixedMasks() const
unsigned int GetNumberOfTransforms() const
virtual void AddMovingMask(MovingMaskType *movingMask)
itkOverrideGetNameOfClassMacro(ElastixRegistrationMethod)
ProcessObject::DataObjectIdentifierType DataObjectIdentifierType
virtual void SetParameterObject(ParameterObjectType *parameterObject)
virtual void SetMovingMask(MovingMaskType *movingMask)
const ParameterObjectType * GetTransformParameterObject() const
SmartPointer< const elx::ElastixMain > m_ElastixMain
const MovingImageType * GetMovingImage() const
SmartPointer< const TransformType > m_InitialTransform
virtual void SetFixedImage(TFixedImage *fixedImage)
virtual void SetFixedPoints(const PointContainerType< double > *_arg)
static SmartPointer< TransformType > ConvertToItkTransform(const TransformType &)
virtual void AddFixedMask(FixedMaskType *fixedMask)
void SetInitialTransform(const TransformType *)
SmartPointer< TransformType > m_ExternalInitialTransform
void SetInput(FixedImageType *fixedImage)
std::string MakeUniqueName(const DataObjectIdentifierType &key)
virtual void AddMovingImage(TMovingImage *movingImage)
const DataObject * GetInput(DataObjectPointerArraySizeType index) const
const FixedImageType * GetFixedImage(const unsigned int index) const
bool IsInputOfType(const DataObjectIdentifierType &InputOfType, const DataObjectIdentifierType &inputName) const
const DataObject * GetOutput(unsigned int idx) const
AdvancedCombinationTransform< elx::ElastixBase::CoordinateType, FixedImageDimension > AdvancedCombinationTransformType
const TransformType * GetInitialTransform() const
TransformType * GetCombinationTransform() const
virtual void SetMovingImage(TMovingImage *movingImages)
const MovingMaskType * GetMovingMask(const unsigned int index) const
static constexpr unsigned int ImageDimension
void SetMovingPoints(const PointContainerType< float > *const points)
static SmartPointer< PointContainerType< double > > ConvertToPointContainerOfDoubleCoordinates(const PointContainerType< float > *const floatPointContainer)
const FixedImageType * GetInput() const
virtual void SetMovingPointSetFileName(std::string _arg)
ProcessObject::DataObjectPointer DataObjectPointer
virtual void SetFixedPointSetFileName(std::string _arg)
const FixedMaskType * GetFixedMask(const unsigned int index) const
ParameterObjectType * GetTransformParameterObject()
VectorContainer< IdentifierType, Point< TCoordinate, ImageDimension > > PointContainerType
const ParameterObjectType * GetParameterObject() const
ElastixMainType::ObjectPointer ElastixMainObjectPointer
ElastixMainType::FlatDirectionCosinesType FlatDirectionCosinesType
void SetFixedPoints(const PointContainerType< float > *const points)
ElastixMainType::DataObjectContainerPointer DataObjectContainerPointer
DataObject * GetOutput(unsigned int idx)
ParameterObjectType * GetParameterObject()
ElastixMainType::ArgumentMapType ArgumentMapType
const MovingImageType * GetMovingImage(const unsigned int index) const
ITK_DISALLOW_COPY_AND_MOVE(ElastixRegistrationMethod)
unsigned int GetNumberOfInputsOfType(const DataObjectIdentifierType &intputType) const
void SetInitialTransformParameterFileName(std::string)


Generated on 1774142652 for elastix by doxygen 1.15.0 elastix logo