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
elxTransformBase.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright UMC Utrecht and contributors
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#ifndef elxTransformBase_h
19#define elxTransformBase_h
20
22#include "elxMacro.h"
23
24#include "elxBaseComponentSE.h"
25#include "elxDefaultConstruct.h"
26#include <itkDeref.h>
27#include "elxElastixBase.h"
31#include "elxProgressCommand.h"
32
33// ITK header files:
34#include <itkImage.h>
35#include <itkOptimizerParameters.h>
36#include <itkTransformMeshFilter.h>
37
38
39namespace elastix
40{
41// using namespace itk; //Not here, because a TransformBase class was added to ITK...
42
142
143template <typename TElastix>
144class ITK_TEMPLATE_EXPORT TransformBase : public BaseComponentSE<TElastix>
145{
146public:
148
152
155
157 using typename Superclass::RegistrationType;
158
159 using CommandLineArgumentMapType = Configuration ::CommandLineArgumentMapType;
160 using CommandLineEntryType = Configuration ::CommandLineEntryType;
161
164 using FixedImageType = typename TElastix::FixedImageType;
165 using MovingImageType = typename TElastix::MovingImageType;
166
170
172 itkStaticConstMacro(FixedImageDimension, unsigned int, FixedImageType::ImageDimension);
173
175 itkStaticConstMacro(MovingImageDimension, unsigned int, MovingImageType::ImageDimension);
176
181
185
187 using InputPointType = typename ITKBaseType::InputPointType;
188 using OutputPointType = typename ITKBaseType::OutputPointType;
189
191 using VectorPixelType = itk::Vector<float, FixedImageDimension>;
192 using DeformationFieldImageType = itk::Image<VectorPixelType, FixedImageDimension>;
193
195 using ITKRegistrationType = typename RegistrationType::ITKBaseType;
196 using OptimizerType = typename ITKRegistrationType::OptimizerType;
197 using ScalesType = itk::Optimizer::ScalesType;
198
200 using SpatialJacobianDeterminantImageType = itk::Image<float, FixedImageDimension>;
202 itk::Image<itk::Matrix<float, MovingImageDimension, FixedImageDimension>, FixedImageDimension>;
203
204
206 using ParameterMapType = typename TElastix::ParameterMapType;
207
211 {
212 return &(this->GetSelf());
213 }
214
215
217 const ITKBaseType *
219 {
220 return &(this->GetSelf());
221 }
222
226 int
228
230 void
232
234 void
235 SetTransformParameterFileName(const std::string & filename);
236
238 virtual void
240
242 void
244 ParameterMapType & parameterMap,
245 const bool includeDerivedTransformParameters = true) const;
246
248 void
249 WriteToFile(std::ostream & transformationParameterInfo, const ParametersType & param) const;
250
252 void
254
256 void
257 ReadInitialTransformFromFile(const std::string & transformParameterFileName);
258
260 void
262
264 typename SpatialJacobianDeterminantImageType::Pointer
266
268 typename SpatialJacobianMatrixImageType::Pointer
270
272 void
274
276 void
278
282 void
284
287 template <typename TMesh>
288 typename TMesh::Pointer
289 TransformMesh(const TMesh & mesh) const
290 {
292 transformMeshFilter.SetTransform(&const_cast<CombinationTransformType &>(this->GetSelf()));
293 transformMeshFilter.SetInput(&mesh);
294 transformMeshFilter.Update();
295 return transformMeshFilter.GetOutput();
296 }
297
298protected:
300 TransformBase() = default;
302 ~TransformBase() override = default;
303
305 bool
307 {
308 const Configuration & configuration = itk::Deref(Superclass::GetConfiguration());
309 return configuration.HasParameter("ITKTransformParameters");
310 }
311
318 void
320
328 void
329 AutomaticScalesEstimationStackTransform(const unsigned int numSubTransforms, ScalesType & scales) const;
330
331private:
333
335 template <template <typename, typename> class TSource, typename TOutputImage>
336 auto
338 {
339 const auto & resampleImageFilter = *(this->m_Elastix->GetElxResamplerBase()->GetAsITKBaseType());
340
342 const auto jacGenerator = TSource<TOutputImage, CoordinateType>::New();
343
344 jacGenerator->SetTransform(this->GetAsITKBaseType());
345 jacGenerator->SetOutputSize(resampleImageFilter.GetSize());
346 jacGenerator->SetOutputSpacing(resampleImageFilter.GetOutputSpacing());
347 jacGenerator->SetOutputOrigin(resampleImageFilter.GetOutputOrigin());
348 jacGenerator->SetOutputIndex(resampleImageFilter.GetOutputStartIndex());
349 jacGenerator->SetOutputDirection(resampleImageFilter.GetOutputDirection());
350 // NOTE: We can not use the following, since the fixed image does not exist in transformix
351 // jacGenerator->SetOutputParametersFromImage(
352 // this->GetRegistration()->GetAsITKBaseType()->GetFixedImage() );
353
354 return jacGenerator;
355 }
356
357
359 template <typename TImage>
360 auto
362 {
366 const auto infoChanger = itk::ChangeInformationImageFilter<TImage>::New();
367 typename FixedImageType::DirectionType originalDirection;
368 const bool retdc = this->m_Elastix->GetOriginalFixedImageDirection(originalDirection);
369 infoChanger->SetOutputDirection(originalDirection);
370 infoChanger->SetChangeDirection(retdc && !this->m_Elastix->GetUseDirectionCosines());
371 infoChanger->SetInput(image);
372
373 return infoChanger;
374 }
375
376
379 void
381
385 int
386 BeforeAllBase() override;
387
391 void
393
397 void
399
403
405 itkGetStringMacro(TransformParameterFileName);
406
408 void
409 TransformPointsSomePoints(const std::string & filename) const;
410
412 void
413 TransformPointsSomePointsVTK(const std::string & filename) const;
414
421
423 typename DeformationFieldImageType::Pointer
425
426 void WriteDeformationFieldImage(typename DeformationFieldImageType::Pointer) const;
427
429 void
431
432 std::string
434 {
435 const InitialTransformType * const initialTransform = this->GetInitialTransform();
436
437 if (!initialTransform)
438 {
439 return "NoInitialTransform";
440 }
441
442 const auto t0 = dynamic_cast<const Self *>(initialTransform);
443 return t0->GetTransformParameterFileName();
444 }
445
446 virtual ParameterMapType
448
450 virtual void
453
458
461};
462
463} // end namespace elastix
464
465#ifndef ITK_MANUAL_INSTANTIATION
466# include "elxTransformBase.hxx"
467#endif
468
469#endif // end #ifndef elxTransformBase_h
itk::WeakPointer< TElastix > m_Elastix
const Configuration * GetConfiguration() const
typename ElastixType::RegistrationBaseType RegistrationType
virtual const itk::Object & GetSelf() const =0
A class that deals with user given parameters and command line arguments.
itk::SmartPointer< const Self > ConstPointer
bool HasParameter(const std::string &parameterName) const
TMesh::Pointer TransformMesh(const TMesh &mesh) const
const ITKBaseType * GetAsITKBaseType() const
itk::Image< itk::Matrix< float, MovingImageDimension, FixedImageDimension >, FixedImageDimension > SpatialJacobianMatrixImageType
BaseComponentSE< TElastix > Superclass
typename TElastix::FixedImageType FixedImageType
itkOverrideGetNameOfClassMacro(TransformBase)
typename RegistrationType::ITKBaseType ITKRegistrationType
void SetInitialTransform(InitialTransformType *_arg)
ITKBaseType * GetAsITKBaseType()
void TransformPointsSomePointsVTK(const std::string &filename) const
DeformationFieldImageType::Pointer GenerateDeformationFieldImage() const
itk::Image< float, FixedImageDimension > SpatialJacobianDeterminantImageType
std::string GetInitialTransformParameterFileName() const
SpatialJacobianDeterminantImageType::Pointer ComputeSpatialJacobianDeterminantImage() const
void ReadInitialTransformFromConfiguration(const Configuration::ConstPointer)
itk::Image< VectorPixelType, FixedImageDimension > DeformationFieldImageType
void TransformPoints() const
typename ITKBaseType::OutputPointType OutputPointType
void AutomaticScalesEstimation(ScalesType &scales) const
virtual ParameterMapType CreateDerivedTransformParameterMap() const =0
void SetReadWriteTransformParameters(const bool _arg)
ElastixBase::CoordinateType CoordinateType
typename ITKRegistrationType::OptimizerType OptimizerType
typename TElastix::ParameterMapType ParameterMapType
void WriteToFile(std::ostream &transformationParameterInfo, const ParametersType &param) const
void TransformPointsAllPoints() const
ITK_DISALLOW_COPY_AND_MOVE(TransformBase)
typename TElastix::MovingImageType MovingImageType
void ComputeAndWriteSpatialJacobianMatrixImage() const
SpatialJacobianMatrixImageType::Pointer ComputeSpatialJacobianMatrixImage() const
auto CreateChangeInformationImageFilter(TImage *image) const
itk::AdvancedCombinationTransform< CoordinateType, Self::FixedImageDimension > CombinationTransformType
typename ITKBaseType::InputPointType InputPointType
elxDeclarePureVirtualGetSelfMacro(ITKBaseType)
itkStaticConstMacro(FixedImageDimension, unsigned int, FixedImageType::ImageDimension)
typename CombinationTransformType::InitialTransformType InitialTransformType
Configuration ::CommandLineArgumentMapType CommandLineArgumentMapType
void ComputeAndWriteSpatialJacobianDeterminantImage() const
itk::Optimizer::ScalesType ScalesType
virtual void ReadFromFile()
Configuration ::CommandLineEntryType CommandLineEntryType
auto CreateJacobianSource() const
void TransformPointsSomePoints(const std::string &filename) const
virtual void WriteDerivedTransformDataToFile() const
void ReadInitialTransformFromFile(const std::string &transformParameterFileName)
void CreateTransformParameterMap(const ParametersType &param, ParameterMapType &parameterMap, const bool includeDerivedTransformParameters=true) const
void AfterRegistrationBase() override
void WriteDeformationFieldImage(typename DeformationFieldImageType::Pointer) const
itkStaticConstMacro(MovingImageDimension, unsigned int, MovingImageType::ImageDimension)
ComponentDatabase::ComponentDescriptionType ComponentDescriptionType
bool HasITKTransformParameters() const
const InitialTransformType * GetInitialTransform() const
itk::Vector< float, FixedImageDimension > VectorPixelType
void AutomaticScalesEstimationStackTransform(const unsigned int numSubTransforms, ScalesType &scales) const
void SetTransformParameterFileName(const std::string &filename)
CombinationTransformType ITKBaseType
ComponentDatabase::PtrToCreator PtrToCreator
~TransformBase() override=default
itk::OptimizerParameters< ValueType > ParametersType
int BeforeAllBase() override
void BeforeRegistrationBase() override
This class combines two transforms: an 'initial transform' with a 'current transform'.
class ITK_TEMPLATE_EXPORT OptimizerParameters


Generated on 1774142652 for elastix by doxygen 1.15.0 elastix logo