go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
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
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
74 itkTypeMacro(ElastixRegistrationMethod, ImageSource);
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
104 using TransformType = Transform<double, FixedImageDimension, MovingImageDimension>;
105
106 using FixedImageType = TFixedImage;
107 using MovingImageType = TMovingImage;
109
111 virtual void
112 SetFixedImage(TFixedImage * fixedImage);
113 virtual void
114 AddFixedImage(TFixedImage * fixedImage);
115 const FixedImageType *
117 const FixedImageType *
118 GetFixedImage(const unsigned int index) const;
119 unsigned int
121
123 virtual void
124 SetMovingImage(TMovingImage * movingImages);
125 virtual void
126 AddMovingImage(TMovingImage * movingImage);
127 const MovingImageType *
129 const MovingImageType *
130 GetMovingImage(const unsigned int index) const;
131 unsigned int
133
135 virtual void
137 virtual void
139 const FixedMaskType *
141 const FixedMaskType *
142 GetFixedMask(const unsigned int index) const;
143 void
145 unsigned int
147
149 virtual void
151 virtual void
153 const MovingMaskType *
155 const MovingMaskType *
156 GetMovingMask(const unsigned int index) const;
157 virtual void
159 unsigned int
161
163 virtual void
167 const ParameterObjectType *
169
173 const ParameterObjectType *
175 using Superclass::GetOutput;
176 DataObject *
177 GetOutput(unsigned int idx);
178 const DataObject *
179 GetOutput(unsigned int idx) const;
182
183 /* \note When "WriteResultImage" is false, the output image will be empty. */
184 const ResultImageType *
185 GetOutput() const;
186
187 /* Standard filter indexed input / output methods */
188 void
190 const FixedImageType *
191 GetInput() const;
192 void
193 SetInput(DataObjectPointerArraySizeType index, DataObject * input);
194 const DataObject *
196
199
200 itkGetConstMacro(InitialTransformParameterFileName, std::string);
201 virtual void
203 {
204 this->SetInitialTransformParameterFileName("");
205 }
206
208 void
210
212 const TransformType *
214 {
215 return m_InitialTransform;
216 }
217
219 void
221
227 {
228 return m_ExternalInitialTransform;
229 }
230
232 void
234
236 itkSetMacro(FixedPointSetFileName, std::string);
237 itkGetConstMacro(FixedPointSetFileName, std::string);
238 void
240 {
241 this->SetFixedPointSetFileName("");
242 }
243
245 itkSetMacro(MovingPointSetFileName, std::string);
246 itkGetConstMacro(MovingPointSetFileName, std::string);
247 void
249 {
250 this->SetMovingPointSetFileName("");
251 }
252
254 itkSetMacro(OutputDirectory, std::string);
255 itkGetConstMacro(OutputDirectory, std::string);
256 void
258 {
259 this->SetOutputDirectory("");
260 }
261
263 void
264 SetLogFileName(const std::string logFileName);
265
266 itkGetConstMacro(LogFileName, std::string);
267 void
269
271 itkSetMacro(LogToConsole, bool);
272 itkGetConstReferenceMacro(LogToConsole, bool);
273 itkBooleanMacro(LogToConsole);
274
276 itkSetMacro(LogToFile, bool);
277 itkGetConstReferenceMacro(LogToFile, bool);
278 itkBooleanMacro(LogToFile);
279
281 void
283 {
284 m_EnableOutput = false;
285 }
286
287 itkSetMacro(LogLevel, ElastixLogLevel);
288 itkGetConstMacro(LogLevel, ElastixLogLevel);
289
290 itkSetMacro(NumberOfThreads, int);
291 itkGetConstMacro(NumberOfThreads, int);
292
294 unsigned int
296
299 GetNthTransform(const unsigned int n) const;
300
304
307 static SmartPointer<TransformType>
309
310protected:
312
313 void
314 GenerateData() override;
315
316 using DataObjectPointer = ProcessObject::DataObjectPointer;
317 using Superclass::MakeOutput;
320
321private:
323 std::string
325
327 bool
328 IsInputOfType(const DataObjectIdentifierType & InputOfType, const DataObjectIdentifierType & inputName) const;
329
331 unsigned int
333
335 void
337
338
340 template <typename TImage>
341 std::vector<TImage *>
342 GetInputImages(const char * const inputTypeString)
343 {
344 std::vector<TImage *> images;
345 for (const auto & inputName : this->GetInputNames())
346 {
347 if (this->IsInputOfType(inputTypeString, inputName))
348 {
349 images.push_back(itkDynamicCastInDebugMode<TImage *>(this->ProcessObject::GetInput(inputName)));
350 }
351 }
352 return images;
353 }
354
355 void
357 {
358 m_InitialTransform = nullptr;
359 m_InitialTransformParameterFileName.clear();
360 m_InitialTransformParameterObject = nullptr;
361 m_ExternalInitialTransform = nullptr;
362 }
363
364 void
366 {
367 if (m_InitialTransform || m_InitialTransformParameterObject || m_ExternalInitialTransform ||
368 !m_InitialTransformParameterFileName.empty())
369 {
370 ResetInitialTransformWithoutModified();
371 this->Modified();
372 }
373 }
374
376 using Superclass::SetInput;
377
380
383
384 SmartPointer<const elx::ElastixMain> m_ElastixMain{};
385
386 std::string m_InitialTransformParameterFileName{};
387 SmartPointer<const elx::ParameterObject> m_InitialTransformParameterObject{};
388 SmartPointer<const TransformType> m_InitialTransform{};
389 SmartPointer<TransformType> m_ExternalInitialTransform{};
390
391 std::string m_FixedPointSetFileName{};
392 std::string m_MovingPointSetFileName{};
393
394 std::string m_OutputDirectory{};
395 std::string m_LogFileName{};
396
397 bool m_EnableOutput{ true };
398 bool m_LogToConsole{ false };
399 bool m_LogToFile{ false };
400
401 ElastixLogLevel m_LogLevel{};
402
403 int m_NumberOfThreads{ 0 };
404
405 unsigned int m_InputUID{ 0 };
406};
407
408} // namespace itk
409
410#ifndef ITK_MANUAL_INSTANTIATION
411# include "itkElastixRegistrationMethod.hxx"
412#endif
413
414#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)
void SetExternalInitialTransform(TransformType *)
unsigned int GetNumberOfFixedImages() const
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)
TransformType * GetExternalInitialTransform() const
ParameterObjectType::ConstPointer ParameterObjectConstPointer
const MovingMaskType * GetMovingMask() const
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
ArgumentMapType::value_type ArgumentMapEntryType
ResultImageType * GetOutput()
ParameterObjectType::ParameterValueVectorType ParameterValueVectorType
const FixedMaskType * GetFixedMask() const
ElastixMainType::DataObjectContainerType DataObjectContainerType
unsigned int GetNumberOfFixedMasks() const
unsigned int GetNumberOfTransforms() const
virtual void AddMovingMask(MovingMaskType *movingMask)
ProcessObject::DataObjectIdentifierType DataObjectIdentifierType
virtual void SetParameterObject(ParameterObjectType *parameterObject)
virtual void SetMovingMask(MovingMaskType *movingMask)
const ParameterObjectType * GetTransformParameterObject() const
const MovingImageType * GetMovingImage() const
virtual void SetFixedImage(TFixedImage *fixedImage)
static SmartPointer< TransformType > ConvertToItkTransform(const TransformType &)
virtual void AddFixedMask(FixedMaskType *fixedMask)
void SetInitialTransform(const TransformType *)
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
const TransformType * GetInitialTransform() const
TransformType * GetCombinationTransform() const
virtual void SetMovingImage(TMovingImage *movingImages)
const MovingMaskType * GetMovingMask(const unsigned int index) const
const FixedImageType * GetInput() const
ProcessObject::DataObjectPointer DataObjectPointer
const FixedMaskType * GetFixedMask(const unsigned int index) const
ParameterObjectType * GetTransformParameterObject()
const ParameterObjectType * GetParameterObject() const
ElastixMainType::ObjectPointer ElastixMainObjectPointer
ElastixMainType::FlatDirectionCosinesType FlatDirectionCosinesType
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 2024-07-17 for elastix by doxygen 1.11.0 (9b424b03c9833626cd435af22a444888fbbb192d) elastix logo