SuPReMo  0.1.1
Loading...
Searching...
No Matches
Supremo.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 <memory>
22#include <iostream>
23#include "nifti1_io.h"
24#include "ImagePyramid.h"
25#include "ImageSimilarity.h"
26#include "SSDImageSimilarity.h"
27#include "CorrespondenceModel.h"
28#include "Transformation.h"
29#include "BSplineTransformation.h"
30#include "SlidingTransformation.h"
31#include "MoCoRecon.h"
32#include "ObjectiveFunction.h"
33#include "Optimiser.h"
34#include "ConjugateGradientOptimiser.h"
35#include "ImageAcquisition.h"
36#include "NoImageAcquisition.h"
37#include "LowResolutionImageAcquisition.h"
38
39
40// Forward declaration
42
43inline void supremo_exit(int Val, const char* fileName, int lineNumber)
44{
45 fprintf(stderr, "[Supremo] Exit here. File: %s:%i\n", fileName, lineNumber);
46 exit(Val);
47};
48
49inline void supremo_print_debug(const char* message){ printf("[Supremo DEBUG] Message: %s\n", message); };
50inline void supremo_print_warning(const char* message){ printf("[Supremo WARNING] Message: %s\n", message); };
51inline void supremo_print_error(const char* message){ fprintf(stderr, "[Supremo ERROR] Message: %s\n", message); };
52
53
54
59{
60public:
61 typedef float VoxelType;
62
64 Supremo();
65
67 ~Supremo();
68
71
72
78 void SetDynamicImages(nifti_image** dynamicImagesIn, int numberOfDynamicImagesIn);
79
80
84 void SetReferenceStateImage(nifti_image* referenceStateImageIn);
85
86
92 void SetSurrogateSignals( float* surrogateSignalsIn, int numberOfSurrogateSignalsIn );
93
94
101 void SetDefSpaceImage( nifti_image* defSpaceImageIn );
102
103
106 void SetImageAcquisition( std::shared_ptr<ImageAcquisition> imageAcquisitionIn );
107
108
113 void SetMotionCompensatedReconstruction( std::shared_ptr<MoCoRecon> mocoReconstructionIn );
114
118 void SetInterMCROutputFolder( const std::string& outputFolder );
119
123 void SetInterGradOutputFolder( const std::string& outputFolder );
124
128 void SetTransformationType( t_transformationType transformationTypeIn );
129
133 void SetSlidingTrafoDistanceMap( nifti_image* slidingTrafoDistanceMapIn );
134
135
140 void SetSlidingGapOverlapConstraintWeight( float gapOverlapConstraintWeightIn );
141
142
148 void SetBSplineCPGSpacing( float sx, float sy, float sz );
149
153 void SetBSplineBendingEnergy( float be );
154
158 void SetBSplineLinearEnergy( float le );
159
163 inline void SetNumberOfPyramidLevels( unsigned int numberOfLevelsIn )
164 {
165 this->numberOfLevels = numberOfLevelsIn;
166 }
167
171 inline void SetNumberOfPyramidLevelsToPerform( unsigned int numberOfLevelsToPerformIn )
172 {
173 this->numberOfLevelsToPerform = numberOfLevelsToPerformIn;
174 }
175
179 inline void SetMaxModelFittingIterationNumber( unsigned int maxModelFittingIterations )
180 {
181 this->maxModelFitIterationNumber = maxModelFittingIterations;
182 }
183
184
189 inline void SetMaxSwitchIterationNumber( unsigned int maxSwitchIterations )
190 {
191 this->maxSwitchIterationNumber = maxSwitchIterations;
192 }
193
199 inline void SetInputRCMImages(const std::vector<nifti_image*>& inputRCMImgs)
200 {
201 this->inputRCMImages = inputRCMImgs;
202 };
203
204
205
210 std::vector<nifti_image*> GetCorrespondenceModelAsImage();
211
212
217
218
222 std::vector<nifti_image*> SimulateDynamicImages();
223
224
229 std::vector<nifti_image*> GenerateDVFsFromCorrespondenceModel();
230
231
232private:
237 void Initialise();
238
239
242 void CheckParameters();
243
247 void DisplayCurrentLevelParameters( unsigned int level );
248
249
253 void SaveInterMCRToImage(nifti_image* mcrImage);
254
257
258 nifti_image ** allDynamicImages;
259 nifti_image * referenceStateImage;
260 nifti_image * finalMoCoReconImage;
261
262 std::vector<std::vector<float> > surrogateSignals;
263
264 nifti_image* defSpaceImage;
265
266 std::vector<nifti_image*> inputRCMImages;
267
270
271 unsigned int numberOfLevels;
273 unsigned int currentLevel;
274
275 t_transformationType transformationType;
276
280
283
286
288
289 // Image pyramids
290 std::shared_ptr<ImagePyramid<VoxelType> > referenceStatePyramid;
291 std::vector<std::shared_ptr<ImagePyramid<VoxelType> > > allDynamicPyramids;
292
293 // Temporary image pointers
295
296 std::shared_ptr<Transformation> transform;
297 std::shared_ptr<CorrespondenceModel> correspondenceModel;
298 std::shared_ptr<ImageSimilarity> similarityMeasure;
299 std::shared_ptr<ImageAcquisition> imageAcquisition;
300 std::shared_ptr<MoCoRecon> mocoReconstructor;
301
302 std::string levelID;
303};
Definition: CorrespondenceModel.h:31
Definition: Supremo.h:59
nifti_image ** allDynamicImages
Pointer to all dynamic nifti images available.
Definition: Supremo.h:258
std::vector< nifti_image * > GenerateDVFsFromCorrespondenceModel()
Definition: Supremo.cpp:538
unsigned int currentLevel
The current level that is being processed.
Definition: Supremo.h:273
void SetMaxModelFittingIterationNumber(unsigned int maxModelFittingIterations)
Definition: Supremo.h:179
std::shared_ptr< MoCoRecon > mocoReconstructor
The motion-compensated image reconstruction object.
Definition: Supremo.h:300
std::shared_ptr< ImageSimilarity > similarityMeasure
Pointer to the image similarity measure used.
Definition: Supremo.h:298
Supremo()
Definition: Supremo.cpp:37
std::string outputInterGradientFolder
Folder to which intermediate objective function gradients will be saved.
Definition: Supremo.h:285
void SetInputRCMImages(const std::vector< nifti_image * > &inputRCMImgs)
Definition: Supremo.h:199
float slidingGapOverlapConstraintWeight
The weight with which the gaps and overlaps will be constrained.
Definition: Supremo.h:282
void SetBSplineCPGSpacing(float sx, float sy, float sz)
Definition: Supremo.cpp:213
void SetMaxSwitchIterationNumber(unsigned int maxSwitchIterations)
Definition: Supremo.h:189
float bSplineBendingEnergyWeight
Bending energy weight to constrain a b-spline transformation.
Definition: Supremo.h:278
void SetNumberOfPyramidLevels(unsigned int numberOfLevelsIn)
Definition: Supremo.h:163
float VoxelType
Definition: Supremo.h:61
float bSplineLinearEnergyWeight
Linear energy weight to constrain a b-spline transformation.
Definition: Supremo.h:279
std::vector< nifti_image * > inputRCMImages
The vector holding the pointer to the respiratory correspondence model images. Will be used as a star...
Definition: Supremo.h:266
nifti_image * referenceStateImage
Pointer to the reference state image .
Definition: Supremo.h:259
void SaveInterMCRToImage(nifti_image *mcrImage)
Definition: Supremo.cpp:849
std::vector< nifti_image * > GetCorrespondenceModelAsImage()
Definition: Supremo.cpp:443
void Initialise()
Definition: Supremo.cpp:588
nifti_image * finalMoCoReconImage
Pointer holding the final motion-compensated reconstruction image after fit and reconstruct.
Definition: Supremo.h:260
void SetInterMCROutputFolder(const std::string &outputFolder)
Definition: Supremo.cpp:179
void SetDynamicImages(nifti_image **dynamicImagesIn, int numberOfDynamicImagesIn)
Definition: Supremo.cpp:89
void SetInterGradOutputFolder(const std::string &outputFolder)
Definition: Supremo.cpp:190
nifti_image * currentReferenceStateImage
Definition: Supremo.h:294
nifti_image * GetMotionCompensatedReconstructedImage()
Definition: Supremo.h:216
std::string levelID
String holding an ID to differentiate file output from various multi-resolution levels and MCR iterat...
Definition: Supremo.h:302
t_transformationType transformationType
The transformation type used to deform the reference-state image.
Definition: Supremo.h:275
std::vector< std::shared_ptr< ImagePyramid< VoxelType > > > allDynamicPyramids
Vector of pointers holding all the dynamic image pyramids.
Definition: Supremo.h:291
void DisplayCurrentLevelParameters(unsigned int level)
Definition: Supremo.cpp:789
std::vector< std::vector< float > > surrogateSignals
Vector of vector containing the the surrogate signals. First index for time point,...
Definition: Supremo.h:262
nifti_image * slidingSignedDistanceMapImage
Image required by the sliding transformation to determine the regions involved.
Definition: Supremo.h:281
void SetBSplineBendingEnergy(float be)
Definition: Supremo.cpp:226
std::shared_ptr< Transformation > transform
Pointer to the transformation used (e.g. b-spline)
Definition: Supremo.h:296
void FitMotionModelAndReconstruct()
Definition: Supremo.cpp:273
void SetReferenceStateImage(nifti_image *referenceStateImageIn)
Definition: Supremo.cpp:102
void SetMotionCompensatedReconstruction(std::shared_ptr< MoCoRecon > mocoReconstructionIn)
Definition: Supremo.cpp:167
void CheckParameters()
Definition: Supremo.cpp:695
std::string outputInterMCRFolder
Folder to which intermediate MCRs will be saved.
Definition: Supremo.h:284
std::vector< nifti_image * > SimulateDynamicImages()
Definition: Supremo.cpp:471
unsigned int maxModelFitIterationNumber
Maximum number of respiratory correspondence model fitting iterations.
Definition: Supremo.h:269
float bSplineCPGSpacing[3]
B-spline control point spacing (used if b-spline transformation is used)
Definition: Supremo.h:277
void SetSlidingGapOverlapConstraintWeight(float gapOverlapConstraintWeightIn)
Definition: Supremo.cpp:250
std::shared_ptr< ImagePyramid< VoxelType > > referenceStatePyramid
Pointer holding the reference state image pyramid.
Definition: Supremo.h:290
void SetSurrogateSignals(float *surrogateSignalsIn, int numberOfSurrogateSignalsIn)
Definition: Supremo.cpp:125
void SetBSplineLinearEnergy(float le)
Definition: Supremo.cpp:238
void SetDefSpaceImage(nifti_image *defSpaceImageIn)
Definition: Supremo.cpp:114
unsigned int numberOfLevels
The total number of levels.
Definition: Supremo.h:271
~Supremo()
Definition: Supremo.cpp:77
bool initialised
Control parameter indicating if the fit-and-reconstruct method was initialised.
Definition: Supremo.h:287
unsigned int numberOfSurrogateSignals
Number of surrogate signals (per dynamic image)
Definition: Supremo.h:255
void SetSlidingTrafoDistanceMap(nifti_image *slidingTrafoDistanceMapIn)
Definition: Supremo.cpp:262
void SetImageAcquisition(std::shared_ptr< ImageAcquisition > imageAcquisitionIn)
Definition: Supremo.cpp:156
std::shared_ptr< ImageAcquisition > imageAcquisition
Pointer to the image acquisition used.
Definition: Supremo.h:299
void SetNumberOfPyramidLevelsToPerform(unsigned int numberOfLevelsToPerformIn)
Definition: Supremo.h:171
std::shared_ptr< CorrespondenceModel > correspondenceModel
Pointer to the correspondence model.
Definition: Supremo.h:297
nifti_image * defSpaceImage
Pointer to image that defines the space of the deformed images.
Definition: Supremo.h:264
unsigned int numberOfDynamicImages
Total number of dynamic images.
Definition: Supremo.h:256
unsigned int numberOfLevelsToPerform
The number of levels that are used in the fitting/reconstruction process.
Definition: Supremo.h:272
void SetTransformationType(t_transformationType transformationTypeIn)
Definition: Supremo.cpp:202
unsigned int maxSwitchIterationNumber
Maximum number of times to iterate between motion compensated reconstruction and fitting the respirat...
Definition: Supremo.h:268