Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Custom attribute to mark sources as using our C++/C code style.
[attr]our-c-style whitespace=tab-in-indent,no-lf-at-eof hooks.style=KWStyle,clangformat
*.c our-c-style
*.h our-c-style
*.cxx our-c-style
*.hxx our-c-style
*.txx our-c-style

# Custom attribute to mark sources as using our CMake code style.
[attr]our-cmake-style whitespace=tab-in-indent,no-lf-at-eof hooks.style=cmakeformat
*.txt our-cmake-style
*.cmake our-cmake-style
*.wrap our-cmake-style
CMakeLists.txt our-cmake-style

# ExternalData content links must have LF newlines
*.md5 crlf=input
*.sha512 crlf=input
*.cid crlf=input

# ghostflow-director GitHub automatic check for maximum repository file size
* hooks-max-size=100000
4 changes: 2 additions & 2 deletions .github/workflows/build-test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ on: [push,pull_request]

jobs:
cxx-build-workflow:
uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-cxx.yml@v5.4.0
uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-cxx.yml@v5.4.7

python-build-workflow:
uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-package-python.yml@v5.4.0
uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-package-python.yml@v5.4.7
secrets:
pypi_password: ${{ secrets.pypi_password }}
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
cmake_minimum_required(VERSION 3.10.2)
cmake_minimum_required(VERSION 3.16.3)
project(ThinShellDemons)

#set(ThinShellDemons_LIBRARIES ThinShellDemons)

if(NOT ITK_SOURCE_DIR)
find_package(ITK REQUIRED)
find_package(ITK 5.2 REQUIRED)
list(APPEND CMAKE_MODULE_PATH ${ITK_CMAKE_DIR})
include(ITKModuleExternal)
else()
Expand Down
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ This module implements the Thin Shell Demons regularization proposed in
> MIUA 2015



> :warning: **This module requires to be compiled against an ITK version with**
> - [PointSetToPointSetMetricWithIndexv4](https://github.com/InsightSoftwareConsortium/ITK/pull/2385)
>

<p align="center">
<img src="https://user-images.githubusercontent.com/1044135/158479969-7313ed94-c5fb-4803-ae8d-2c0631893664.png" width="400" height="300">
</p>
Expand Down
113 changes: 64 additions & 49 deletions include/itkThinShellDemonsMetricv4.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,19 @@ namespace itk
*
* \ingroup ThinShellDemons
*/
template< typename TFixedMesh, typename TMovingMesh = TFixedMesh,
class TInternalComputationValueType = double >
class ITK_TEMPLATE_EXPORT ThinShellDemonsMetricv4:
public PointSetToPointSetMetricWithIndexv4< TFixedMesh, TMovingMesh, TInternalComputationValueType>
template <typename TFixedMesh, typename TMovingMesh = TFixedMesh, class TInternalComputationValueType = double>
class ITK_TEMPLATE_EXPORT ThinShellDemonsMetricv4
: public PointSetToPointSetMetricWithIndexv4<TFixedMesh, TMovingMesh, TInternalComputationValueType>
{
public:
ITK_DISALLOW_COPY_AND_MOVE(ThinShellDemonsMetricv4);

/** Standard class typedefs. */
typedef ThinShellDemonsMetricv4 Self;
typedef PointSetToPointSetMetricWithIndexv4< TFixedMesh, TMovingMesh > Superclass;
typedef ThinShellDemonsMetricv4 Self;
typedef PointSetToPointSetMetricWithIndexv4<TFixedMesh, TMovingMesh> Superclass;

typedef SmartPointer< Self > Pointer;
typedef SmartPointer< const Self > ConstPointer;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;

/** Method for creation through the object factory. */
itkNewMacro(Self);
Expand All @@ -77,8 +76,8 @@ class ITK_TEMPLATE_EXPORT ThinShellDemonsMetricv4:
itkTypeMacro(ThinShellDemonsMetricv4, PointSetToPointSetMetricWithIndexv4);

/** Types transferred from the base class. */
typedef typename Superclass::FixedPointSetType FixedPointSetType;
typedef typename Superclass::MovingPointSetType MovingPointSetType;
typedef typename Superclass::FixedPointSetType FixedPointSetType;
typedef typename Superclass::MovingPointSetType MovingPointSetType;

/** Types transferred from the base class */
using MeasureType = typename Superclass::MeasureType;
Expand Down Expand Up @@ -108,16 +107,20 @@ class ITK_TEMPLATE_EXPORT ThinShellDemonsMetricv4:

using PointSetPointer = typename Superclass::FixedPointSetType::ConstPointer;

void Initialize(void) override;
void
Initialize(void) override;

MeasureType
GetLocalNeighborhoodValueWithIndex(const PointIdentifier &, const PointType &,
const PixelType & pixel = 0) const override;
GetLocalNeighborhoodValueWithIndex(const PointIdentifier &,
const PointType &,
const PixelType & pixel = 0) const override;

void
GetLocalNeighborhoodValueAndDerivativeWithIndex(const PointIdentifier &, const PointType &,
MeasureType &, LocalDerivativeType &,
const PixelType & pixel = 0) const override;
GetLocalNeighborhoodValueAndDerivativeWithIndex(const PointIdentifier &,
const PointType &,
MeasureType &,
LocalDerivativeType &,
const PixelType & pixel = 0) const override;

/**
* Stretching penalty weight
Expand All @@ -139,7 +142,7 @@ class ITK_TEMPLATE_EXPORT ThinShellDemonsMetricv4:
itkSetMacro(GeometricFeatureWeight, double);
itkGetConstReferenceMacro(GeometricFeatureWeight, double);

/**
/**
* Update feature match at each iteration.
*
* When used in conjunction with UseConfidenceWeighting and
Expand Down Expand Up @@ -188,8 +191,8 @@ class ITK_TEMPLATE_EXPORT ThinShellDemonsMetricv4:
ThinShellDemonsMetricv4();
virtual ~ThinShellDemonsMetricv4() override = default;

//Create a points locator for feature matching
using FeaturePointSetType = PointSet< double, FixedPointDimension+1>;
// Create a points locator for feature matching
using FeaturePointSetType = PointSet<double, FixedPointDimension + 1>;
using FeaturePointSetPointer = typename FeaturePointSetType::Pointer;
using FeaturePointType = typename FeaturePointSetType::PointType;
using FeaturePointsContainer = typename FeaturePointSetType::PointsContainer;
Expand All @@ -204,67 +207,79 @@ class ITK_TEMPLATE_EXPORT ThinShellDemonsMetricv4:
*
* Override to use geometric features
*/
virtual void InitializePointSets() const override;
void InitializeFeaturePointsLocators() const;
virtual void
InitializePointSets() const override;
void
InitializeFeaturePointsLocators() const;

/**
* This class uses it's own Points locators to
* accomodate feature matching
*/
bool RequiresMovingPointsLocator() const override
bool
RequiresMovingPointsLocator() const override
{
return false;
};

bool RequiresFixedPointsLocator() const override
bool
RequiresFixedPointsLocator() const override
{
return false;
};

void PrintSelf(std::ostream & os, Indent indent) const override;
void
PrintSelf(std::ostream & os, Indent indent) const override;

private:
typedef std::vector<std::vector<PointIdentifier>> NeighborhoodMap;
NeighborhoodMap neighborMap;
NeighborhoodMap neighborMap;

typedef std::vector< std::vector<double> > EdgeLengthMap;
EdgeLengthMap edgeLengthMap;
typedef std::vector<std::vector<double>> EdgeLengthMap;
EdgeLengthMap edgeLengthMap;

mutable MeshTypePointer fixedITKMesh;
mutable MeshTypePointer movingITKMesh;
mutable MeshTypePointer fixedCurvature;

CurvatureFilterTypePointer curvature_filter;

double m_StretchWeight;
double m_BendWeight;
double m_GeometricFeatureWeight;
double m_StretchWeight;
double m_BendWeight;
double m_GeometricFeatureWeight;
mutable double m_ConfidenceSigma;
bool m_UseConfidenceWeighting;
bool m_UpdateFeatureMatchingAtEachIteration;
bool m_UseMaximalDistanceConfidenceSigma;

void FillPointAndCell(PointSetPointer &pointset, MeshTypePointer &currentITKMesh);
double ComputeConfidenceValueAndDerivative(const VectorType &v,
VectorType &derivative) const;
void ComputeStretchAndBend(const PointIdentifier &index,
double &stretchEnergy,
double &bendEnergy,
VectorType &stretch,
VectorType &bend) const;
void ComputeNeighbors();
void ComputeMaximalDistanceSigma() const;
FeaturePointType GetFeaturePoint(const double *v, const double &c) const;
FeaturePointType GetFeaturePoint(const PointType &v, const double &c) const;
VectorType GetMovingDirection(const PointIdentifier &identifier) const;
FeaturePointSetPointer GenerateFeaturePointSets(bool fixed) const;
bool m_UseConfidenceWeighting;
bool m_UpdateFeatureMatchingAtEachIteration;
bool m_UseMaximalDistanceConfidenceSigma;

void
FillPointAndCell(PointSetPointer & pointset, MeshTypePointer & currentITKMesh);
double
ComputeConfidenceValueAndDerivative(const VectorType & v, VectorType & derivative) const;
void
ComputeStretchAndBend(const PointIdentifier & index,
double & stretchEnergy,
double & bendEnergy,
VectorType & stretch,
VectorType & bend) const;
void
ComputeNeighbors();
void
ComputeMaximalDistanceSigma() const;
FeaturePointType
GetFeaturePoint(const double * v, const double & c) const;
FeaturePointType
GetFeaturePoint(const PointType & v, const double & c) const;
VectorType
GetMovingDirection(const PointIdentifier & identifier) const;
FeaturePointSetPointer
GenerateFeaturePointSets(bool fixed) const;
};

} // end namespace itk

#ifndef ITK_MANUAL_INSTANTIATION
#include "itkThinShellDemonsMetricv4.hxx"
# include "itkThinShellDemonsMetricv4.hxx"
#endif

#endif
Loading
Loading