|
| 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 __elxPointToSurfaceDistanceMetric_H__ |
| 19 | +#define __elxPointToSurfaceDistanceMetric_H__ |
| 20 | + |
| 21 | +#include "elxIncludes.h" // include first to avoid MSVS warning |
| 22 | +#include "itkPointToSurfaceDistanceMetric.h" |
| 23 | + |
| 24 | +namespace elastix |
| 25 | +{ |
| 26 | + |
| 27 | +/** |
| 28 | + * |
| 29 | + * For more information check the paper:\n |
| 30 | + * Gunay, G. , Luu, M. H., Moelker, A. , Walsum, T. and Klein, S. (2017), |
| 31 | + * "Semiautomated registration of pre‐ and intraoperative CT for image‐guided percutaneous |
| 32 | + * liver tumor ablation interventions," Med. Phys., 44: 3718-3725. |
| 33 | + * |
| 34 | + * The parameters used in this class are:\n |
| 35 | + * \parameter Metric: Select this metric as follows: |
| 36 | + * </tt>(Metric "PointToSurfaceDistance")</tt> |
| 37 | + * |
| 38 | + * \parameter PointToSurfaceDistanceAverage: A parameter to get average of the points by dividing the weight of the penalty with the number of the points included. |
| 39 | + * example: </tt>(PointToSurfaceDistanceAverage "true")</tt> \n |
| 40 | + * Default is "true". |
| 41 | + * |
| 42 | + * \Command line parameters |
| 43 | + * \parameter -fp "file" : Elastix pointset file. |
| 44 | + * example: |
| 45 | +
|
| 46 | + * \parameter -dt "file" : Distance transform (file) of segmentation of the organ under interest in the moving image. |
| 47 | + * \parameter -seg "file" : Segmentation (file) of the organ under interest in the moving image. With this parameter the algorithm internally computes the distance transform. |
| 48 | + * \parameter -dtout "file" : If the user wants to get the distance transform from organ segmentation, this parameter is called with the name of the distance transform image file to write . |
| 49 | + * |
| 50 | + * |
| 51 | + * \ingroup Metrics |
| 52 | + * |
| 53 | + */ |
| 54 | + |
| 55 | +template< class TElastix > |
| 56 | +class PointToSurfaceDistanceMetric : |
| 57 | + public |
| 58 | + itk::PointToSurfaceDistanceMetric < |
| 59 | + typename MetricBase< TElastix >::FixedPointSetType, |
| 60 | + typename MetricBase< TElastix >::MovingPointSetType >, |
| 61 | + public MetricBase< TElastix > |
| 62 | +{ |
| 63 | +public: |
| 64 | + |
| 65 | + using Self = PointToSurfaceDistanceMetric; |
| 66 | + |
| 67 | + /** Standard ITK-stuff. */ |
| 68 | + using Superclass1 = itk::PointToSurfaceDistanceMetric<typename MetricBase< TElastix >::FixedPointSetType, typename MetricBase< TElastix >::MovingPointSetType >; |
| 69 | + using Superclass2 = MetricBase< TElastix >; |
| 70 | + using Pointer = itk::SmartPointer< Self >; |
| 71 | + using ConstPointer = itk::SmartPointer< const Self >; |
| 72 | + |
| 73 | + ITK_DISALLOW_COPY_AND_ASSIGN(PointToSurfaceDistanceMetric); |
| 74 | + /** Method for creation through the object factory. */ |
| 75 | + itkNewMacro( Self ); |
| 76 | + |
| 77 | + /** Run-time type information (and related methods). */ |
| 78 | + itkTypeMacro( PointToSurfaceDistanceMetric, itk::PointToSurfaceDistanceMetric ); |
| 79 | + |
| 80 | + /** Name of this class. |
| 81 | + * Use this name in the parameter file to select this specific metric. \n |
| 82 | + * example: <tt>(Metric "PointToSurfaceDistance")</tt>\n |
| 83 | + */ |
| 84 | + elxClassNameMacro( "PointToSurfaceDistance" ); |
| 85 | + |
| 86 | + /** Typedefs from the superclass. */ |
| 87 | + using CoordinateRepresentationType = typename Superclass1::CoordinateRepresentationType; |
| 88 | + using FixedPointSetType = typename Superclass1::FixedPointSetType; |
| 89 | + using FixedPointSetConstPointer = typename Superclass1::FixedPointSetConstPointer; |
| 90 | + using MovingPointSetType = typename Superclass1::MovingPointSetType; |
| 91 | + using MovingPointSetConstPointer = typename Superclass1::MovingPointSetConstPointer; |
| 92 | + using TransformType = typename Superclass1::TransformType; |
| 93 | + using TransformPointer = typename Superclass1::TransformPointer; |
| 94 | + using InputPointType = typename Superclass1::InputPointType; |
| 95 | + using OutputPointType = typename Superclass1::OutputPointType; |
| 96 | + using TransformParametersType = typename Superclass1::TransformParametersType; |
| 97 | + using TransformJacobianType = typename Superclass1::TransformJacobianType; |
| 98 | + using FixedImageMaskType = typename Superclass1::FixedImageMaskType; |
| 99 | + using FixedImageMaskPointer = typename Superclass1::FixedImageMaskPointer; |
| 100 | + using MovingImageMaskType = typename Superclass1::MovingImageMaskType; |
| 101 | + using MovingImageMaskPointer = typename Superclass1::MovingImageMaskPointer; |
| 102 | + using MeasureType = typename Superclass1::MeasureType; |
| 103 | + using DerivativeType = typename Superclass1::DerivativeType; |
| 104 | + using ParametersType = typename Superclass1::ParametersType; |
| 105 | + |
| 106 | + /** Typedefs inherited from elastix. */ |
| 107 | + using ElastixType = typename Superclass2::ElastixType; |
| 108 | + using ElastixPointer = typename Superclass2::ElastixPointer; |
| 109 | + using ConfigurationType = typename Superclass2::ConfigurationType; |
| 110 | + using ConfigurationPointer = typename Superclass2::ConfigurationPointer; |
| 111 | + using RegistrationType = typename Superclass2::RegistrationType; |
| 112 | + using RegistrationPointer = typename Superclass2::RegistrationPointer; |
| 113 | + using ITKBaseType = typename Superclass2::ITKBaseType; |
| 114 | + using FixedImageType = typename Superclass2::FixedImageType; |
| 115 | + using MovingImageType = typename Superclass2::MovingImageType; |
| 116 | + |
| 117 | + /** The fixed image dimension. */ |
| 118 | + itkStaticConstMacro( FixedImageDimension, unsigned int, FixedImageType::ImageDimension ); |
| 119 | + |
| 120 | + /** The moving image dimension. */ |
| 121 | + itkStaticConstMacro( MovingImageDimension, unsigned int, MovingImageType::ImageDimension ); |
| 122 | + |
| 123 | + using PointSetType = FixedPointSetType; |
| 124 | + using ImageType = typename Superclass1::ImageType; |
| 125 | + |
| 126 | + |
| 127 | + /** Sets up a timer to measure the initialisation time and |
| 128 | + * calls the Superclass' implementation. |
| 129 | + */ |
| 130 | + virtual void Initialize(); |
| 131 | + |
| 132 | + /** |
| 133 | + * Do some things before all: |
| 134 | + * \li Check and print the command line arguments fp and mp. |
| 135 | + * This should be done in BeforeAllBase and not BeforeAll. |
| 136 | + */ |
| 137 | + virtual int BeforeAllBase(); |
| 138 | + |
| 139 | + /** |
| 140 | + * Do some things before registration: |
| 141 | + * \li Load and set the pointsets. |
| 142 | + */ |
| 143 | + virtual void BeforeRegistration(); |
| 144 | + |
| 145 | + using ImageConstPointer = typename Superclass1::ImageType::ConstPointer; |
| 146 | + |
| 147 | + unsigned int ReadLandmarks( const std::string & landmarkFileName, typename PointSetType::Pointer & pointSet, typename FixedImageType::ConstPointer image ); |
| 148 | + |
| 149 | + /** Overwrite to silence warning. */ |
| 150 | + virtual void SelectNewSamples( void ){} |
| 151 | + |
| 152 | +protected: |
| 153 | + |
| 154 | + /** The constructor. */ |
| 155 | + PointToSurfaceDistanceMetric() = default; |
| 156 | + /** The destructor. */ |
| 157 | + virtual ~PointToSurfaceDistanceMetric() = default; |
| 158 | + |
| 159 | +}; |
| 160 | + |
| 161 | + |
| 162 | + |
| 163 | +} // end namespace elastix |
| 164 | + |
| 165 | +#ifndef ITK_MANUAL_INSTANTIATION |
| 166 | +#include "elxPointToSurfaceDistanceMetric.hxx" |
| 167 | +#endif |
| 168 | + |
| 169 | +#endif |
0 commit comments