Skip to content

Commit

Permalink
ADD: Addition of point to surface metric to Elastix.
Browse files Browse the repository at this point in the history
In this commit addition of point to surface metric is done.
This metric essentially considers how surface of an masked organ
is aligned with the points provided from the surface of the organ.
Therefore, it is used to improve alignment of the organ under interest.
  • Loading branch information
gokhangg authored and gokhangunay01 committed Feb 5, 2021
1 parent 7ceea14 commit 25529b5
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 114 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
/*======================================================================
This file is part of the elastix software.
Copyright (c) University Medical Center Utrecht. All rights reserved.
See src/CopyrightElastix.txt or http://elastix.isi.uu.nl/legal.php for
details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
======================================================================*/
/*=========================================================================
*
* Copyright UMC Utrecht and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/

#include "elxPointToSurfaceDistanceMetric.h"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
/*======================================================================
This file is part of the elastix software.
Copyright (c) University Medical Center Utrecht. All rights reserved.
See src/CopyrightElastix.txt or http://elastix.isi.uu.nl/legal.php for
details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
======================================================================*/
/*=========================================================================
*
* Copyright UMC Utrecht and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#ifndef __elxPointToSurfaceDistanceMetric_H__
#define __elxPointToSurfaceDistanceMetric_H__

Expand All @@ -21,8 +25,6 @@ namespace elastix
{

/**
* \class TransformRigidityPenalty
* \brief A penalty term based on non-rigidity.
*
* For more information check the paper:\n
* Gunay, G. , Luu, M. H., Moelker, A. , Walsum, T. and Klein, S. (2017),
Expand Down Expand Up @@ -61,17 +63,14 @@ class PointToSurfaceDistanceMetric :
public:

using Self = PointToSurfaceDistanceMetric;
/** The private constructor. */
PointToSurfaceDistanceMetric(const Self &) = delete;
/** The private copy constructor. */
void operator=(const Self &) = delete;

/** Standard ITK-stuff. */
using Superclass1 = itk::PointToSurfaceDistanceMetric<typename MetricBase< TElastix >::FixedPointSetType, typename MetricBase< TElastix >::MovingPointSetType >;
using Superclass2 = MetricBase< TElastix >;
using Pointer = itk::SmartPointer< Self >;
using ConstPointer = itk::SmartPointer< const Self >;

ITK_DISALLOW_COPY_AND_ASSIGN(PointToSurfaceDistanceMetric);
/** Method for creation through the object factory. */
itkNewMacro( Self );

Expand Down Expand Up @@ -143,8 +142,6 @@ class PointToSurfaceDistanceMetric :
*/
virtual void BeforeRegistration();

/** Function to read the corresponding points. */
/** Function to read the corresponding points. */
using ImageConstPointer = typename Superclass1::ImageType::ConstPointer;

unsigned int ReadLandmarks( const std::string & landmarkFileName, typename PointSetType::Pointer & pointSet, typename FixedImageType::ConstPointer image );
Expand All @@ -155,9 +152,9 @@ class PointToSurfaceDistanceMetric :
protected:

/** The constructor. */
PointToSurfaceDistanceMetric(){}
PointToSurfaceDistanceMetric() = default;
/** The destructor. */
virtual ~PointToSurfaceDistanceMetric() {}
virtual ~PointToSurfaceDistanceMetric() = default;

};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
/*======================================================================
This file is part of the elastix software.
Copyright (c) University Medical Center Utrecht. All rights reserved.
See src/CopyrightElastix.txt or http://elastix.isi.uu.nl/legal.php for
details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
======================================================================*/
/*=========================================================================
*
* Copyright UMC Utrecht and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/

#ifndef __elxPointToSurfaceDistanceMetric_HXX__
#define __elxPointToSurfaceDistanceMetric_HXX__
Expand Down Expand Up @@ -57,15 +61,15 @@ PointToSurfaceDistanceMetric< TElastix >

/** Check for appearance of parameter "PointToSurfaceDistanceAverage". */
std::string PointToSurfaceDistanceAverageStr = "true";
this->m_AvPointWeigh=true;
if (this->m_Configuration->CountNumberOfParameterEntries( "PointToSurfaceDistanceAverage" )==1)
this->m_AvPointWeigh = true;
if (this->m_Configuration->CountNumberOfParameterEntries( "PointToSurfaceDistanceAverage" ) == 1)
{
this->m_Configuration->ReadParameter( PointToSurfaceDistanceAverageStr, "PointToSurfaceDistanceAverage", 0 );
if (PointToSurfaceDistanceAverageStr=="false") this->m_AvPointWeigh=false;
if (PointToSurfaceDistanceAverageStr == "false") this->m_AvPointWeigh = false;
}

elxout << "\nAverage of points in annotation set : "
<< PointToSurfaceDistanceAverageStr<<"\n"
<< PointToSurfaceDistanceAverageStr <<"\n"
<< std::endl;

/** Check for appearance of "-fp". */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
/*======================================================================
This file is part of the elastix software.
Copyright (c) University Medical Center Utrecht. All rights reserved.
See src/CopyrightElastix.txt or http://elastix.isi.uu.nl/legal.php for
details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
======================================================================*/
/*=========================================================================
*
* Copyright UMC Utrecht and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#ifndef __itkPointToSurfaceDistanceMetric_h
#define __itkPointToSurfaceDistanceMetric_h

Expand Down Expand Up @@ -79,16 +83,16 @@ class PointToSurfaceDistanceMetric :
/** Run-time type information (and related methods). */
itkTypeMacro( PointToSurfaceDistanceMetric, SingleValuedPointSetToPointSetMetric );//OK
/** Initialize. */
virtual void Initialize() noexcept(false);
virtual void Initialize();

/** Get the value for single valued optimizers. */
MeasureType GetValue( const TransformParametersType & parameters ) const noexcept(false);
MeasureType GetValue( const TransformParametersType & parameters ) const;

/** Get the derivatives of the match measure. */
void GetDerivative( const TransformParametersType & parameters, DerivativeType & Derivative ) const noexcept(false);
void GetDerivative( const TransformParametersType & parameters, DerivativeType & Derivative ) const;

/** Get value and derivatives for multiple valued optimizers. */
void GetValueAndDerivative( const TransformParametersType & parameters, MeasureType & Value, DerivativeType & Derivative ) const noexcept(false);
void GetValueAndDerivative( const TransformParametersType & parameters, MeasureType & Value, DerivativeType & Derivative ) const;

/** Set input Segmented Image File **/
void SetSegImageIn( const std::string str ) ;
Expand All @@ -105,15 +109,15 @@ class PointToSurfaceDistanceMetric :
protected:

PointToSurfaceDistanceMetric();
virtual ~PointToSurfaceDistanceMetric() {}
bool m_AvPointWeigh;
virtual ~PointToSurfaceDistanceMetric() = default;
bool m_AvPointWeigh{true};

private:

PointToSurfaceDistanceMetric( const Self & );
std::string m_SegFileIn,m_DTFileIn,m_DTFileOut;
typename ImageType::Pointer m_ADTimage;
typename InterpolatorType::Pointer m_interpolator;
std::string m_segmentationFileIn, m_distanceTransformFileIn, m_distanceTransformFileOut;
typename ImageType::Pointer m_internalDistanceTransformImage;
typename InterpolatorType::Pointer m_interpolator;

};

Expand Down
Loading

0 comments on commit 25529b5

Please sign in to comment.