SuPReMo  0.1.1
Loading...
Searching...
No Matches
BSplineTransformation.h
1// ====================================================================================================
2//
3// SuPReMo: Surrogate Parameterised Respiratory Motion Model
4// An implementation of the generalised motion modelling and image registration framework
5//
6// Copyright (c) University College London (UCL). All rights reserved.
7//
8// This software is distributed WITHOUT ANY WARRANTY; without even
9// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10// PURPOSE.
11//
12// See LICENSE.txt in the top level directory for details.
13//
14// ====================================================================================================
15
16
17
18
19#pragma once
20
21#include "Supremo.h"
22#include "_reg_localTrans.h"
23#include "_reg_resampling.h"
24#include "nifti1_io.h"
25#include "Transformation.h"
26
27
28
29template<class DTYPE>
30inline void get_BSplineBasisValues( DTYPE basis, DTYPE *values )
31{
32 DTYPE FF = basis*basis;
33 DTYPE FFF = FF*basis;
34 DTYPE MF = static_cast<DTYPE>(1.0 - basis);
35 values[0] = static_cast<DTYPE>((MF) *(MF) *(MF) / (6.0));
36 values[1] = static_cast<DTYPE>((3.0*FFF - 6.0*FF + 4.0) / 6.0);
37 values[2] = static_cast<DTYPE>((-3.0*FFF + 3.0*FF + 3.0*basis + 1.0) / 6.0);
38 values[3] = static_cast<DTYPE>(FFF / 6.0);
39}
40
41
45{
46public:
48
57 BSplineTransformation( nifti_image* referenceImageIn,
58 unsigned int numberOfLevelsToPerform,
59 float* finalControlPointGridSpacing );
60
64 BSplineTransformation( const BSplineTransformation& transformToCopy );
65
66
70
76 virtual void InitialiseLevel( unsigned int level );
77
82 void SetParameters( PrecisionType* parametersIn, bool parametersAreDisplacements);
83
87 virtual nifti_image* GetDeformationVectorField( nifti_image* targetImageIn );
88
93
97
100 double GetConstraintValue();
101
106
110 void SetLinearEnergyWeight( double linearEnergyWeightIn );
111
115 void SetBendingEnergyWeight( double bendingEnergyWeightIn );
116
119 std::shared_ptr<Transformation> DeepCopy();
120
124
130
134
135
138 std::vector<nifti_image*> GetTransformationAsImage();
139
140protected:
141
146 void CPGToDVF2D( nifti_image *denseVectorFieldImage );
147
152 void CPGToDVF3D( nifti_image *denseVectorFieldImage );
153
161 void DVFToCPG2D( nifti_image *controlPointGridImage,
162 nifti_image *denseVectorFieldImage,
163 bool normaliseKernel );
164
172 void DVFToCPG3D( nifti_image *controlPointGridImage,
173 nifti_image *denseVectorFieldImage,
174 bool normaliseKernel );
175
176
178 // * Vectors which are stored along the 5th (u) dimension will be reoriented
179 // * \param vectorFieldToReorientate Vector image to be reorientated
180 // * \param reorientationMatrix 4 x 4 Matrix used to reorientate vectors
181 // */
182 //void ReorientateVectorImage( nifti_image* vectorFieldToReorientate, mat44 reorientationMatrix );
183
187
188private:
191};
192
Definition: BSplineTransformation.h:45
virtual PrecisionType GetSumOfPenaltyWeights()
Definition: BSplineTransformation.cpp:1408
void SetParameters(PrecisionType *parametersIn, bool parametersAreDisplacements)
Definition: BSplineTransformation.cpp:1358
std::shared_ptr< Transformation > DeepCopy()
Definition: BSplineTransformation.cpp:1492
void CPGToDVF3D(nifti_image *denseVectorFieldImage)
Definition: BSplineTransformation.cpp:462
double bendingEnergyWeight
The bending-energy weight.
Definition: BSplineTransformation.h:185
std::vector< nifti_image * > GetTransformationAsImage()
Definition: BSplineTransformation.cpp:1477
void DVFToCPG3D(nifti_image *controlPointGridImage, nifti_image *denseVectorFieldImage, bool normaliseKernel)
Definition: BSplineTransformation.cpp:900
virtual BSplineTransformation::PrecisionType * GetDVFGradientWRTTransformationParameters(nifti_image *denseDVFIn)
Definition: BSplineTransformation.cpp:1288
virtual void InitialiseLevel(unsigned int level)
Definition: BSplineTransformation.cpp:181
Transformation::PrecisionType PrecisionType
Definition: BSplineTransformation.h:47
void SetLinearEnergyWeight(double linearEnergyWeightIn)
Definition: BSplineTransformation.cpp:1334
int lastInitialisedLevel
The level taht was last requested to be initialised.
Definition: BSplineTransformation.h:189
void DisplayTransformationParameters()
Definition: BSplineTransformation.cpp:1508
void SetBendingEnergyWeight(double bendingEnergyWeightIn)
Definition: BSplineTransformation.cpp:1384
nifti_image * controlPointGridImage
‍** Function to reorientate vectors in 5D nifti image.
Definition: BSplineTransformation.h:184
virtual PrecisionType GetMaxTransformationParameterLength(PrecisionType *parametersIn)
Definition: BSplineTransformation.cpp:1434
virtual BSplineTransformation::PrecisionType * GetConstraintGradientWRTTransformationParameters()
Definition: BSplineTransformation.cpp:1229
unsigned int numberOfLevelsToPerform
The total number of levels that are used to fit the model. Parameter needed to correctly scale constr...
Definition: BSplineTransformation.h:190
void DVFToCPG2D(nifti_image *controlPointGridImage, nifti_image *denseVectorFieldImage, bool normaliseKernel)
Definition: BSplineTransformation.cpp:687
~BSplineTransformation()
Definition: BSplineTransformation.cpp:135
void CPGToDVF2D(nifti_image *denseVectorFieldImage)
Definition: BSplineTransformation.cpp:320
virtual nifti_image * GetDeformationVectorField(nifti_image *targetImageIn)
Definition: BSplineTransformation.cpp:230
double GetConstraintValue()
Definition: BSplineTransformation.cpp:1263
double linearEnergyWeight
The linear energy weight.
Definition: BSplineTransformation.h:186
virtual PrecisionType * GetCopyOfParameters()
Definition: BSplineTransformation.cpp:164
Definition: Transformation.h:55
float PrecisionType
Definition: Transformation.h:57