SimpleITK  
sitkElastixImageFilter.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
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 sitkElastixImageFilter_h
19#define sitkElastixImageFilter_h
20
22#include "sitkCommon.h"
23#include "sitkImage.h"
24
25#include <map>
26#include <memory> // For unique_ptr.
27#include <string>
28#include <vector>
29
30namespace itk::simple
31{
32
37{
38public:
41
44
46
47 typedef std::vector<Image> VectorOfImage;
48
49 typedef std::string ParameterKeyType;
50 typedef std::string ParameterValueType;
51 typedef std::vector<ParameterValueType> ParameterValueVectorType;
52 typedef ParameterValueVectorType::iterator ParameterValueVectorIterator;
53 typedef std::map<ParameterKeyType, ParameterValueVectorType> ParameterMapType;
54 typedef std::vector<ParameterMapType> ParameterMapVectorType;
55 typedef ParameterMapType::iterator ParameterMapIterator;
56 typedef ParameterMapType::const_iterator ParameterMapConstIterator;
57
58 std::string
59 GetName() const;
60
62 void
63 SetFixedImage(const Image & fixedImage);
64
66 void
67 SetFixedImage(const VectorOfImage & fixedImages);
68
70 void
71 AddFixedImage(const Image & fixedImage);
72
74 Image &
75 GetFixedImage(const unsigned long index);
76
80
82 void
83 RemoveFixedImage(const unsigned long index);
84
86 void
88
90 unsigned int
92
94 void
95 SetMovingImage(const Image & movingImages);
96
98 void
99 SetMovingImage(const VectorOfImage & movingImage);
100
102 void
103 AddMovingImage(const Image & movingImage);
104
106 Image &
107 GetMovingImage(const unsigned long index);
108
112
114 void
115 RemoveMovingImage(const unsigned long index);
116
118 void
120
122 unsigned int
124
126 void
127 SetFixedMask(const Image & fixedMask);
128
130 void
131 SetFixedMask(const VectorOfImage & fixedMasks);
132
134 void
135 AddFixedMask(const Image & fixedMask);
136
138 Image &
139 GetFixedMask(const unsigned long index);
140
144
146 void
147 RemoveFixedMask(const unsigned long index);
148
150 void
152
154 unsigned int
156
158 void
159 SetMovingMask(const Image & movingMask);
160
162 void
163 SetMovingMask(const VectorOfImage & movingMasks);
164
166 void
167 AddMovingMask(const Image & movingMask);
168
170 Image &
171 GetMovingMask(const unsigned long index);
172
176
178 void
179 RemoveMovingMask(const unsigned long index);
180
182 void
184
186 unsigned int
188
190 void
191 SetFixedPointSetFileName(const std::string fixedPointSetFileName);
192
194 std::string
196
198 void
200
202 void
203 SetMovingPointSetFileName(const std::string movingPointSetFileName);
204
206 std::string
208
210 void
212
214 void
215 SetOutputDirectory(const std::string outputDirectory);
216
218 std::string
220
222 void
224
226 void
227 SetLogFileName(const std::string logFileName);
228
230 std::string
232
234 void
236
238 void
239 SetLogToFile(const bool logToFile);
240
242 bool
244
246 void
248
250 void
252
254 void
256
258 bool
260
262 void
264
266 void
268
272 void
274
276 int
278
281 void
282 SetParameterMap(const std::string transformName,
283 const unsigned int numberOfResolutions = 4u,
284 const double finalGridSpacingInPhysicalUnits = 10.0);
285
287 void
288 SetParameterMaps(const std::vector<std::map<std::string, std::vector<std::string>>> parameterMapVector);
289
291 void
292 SetParameterMap(const std::map<std::string, std::vector<std::string>> parameterMap);
293
295 void
296 AddParameterMap(const std::map<std::string, std::vector<std::string>> parameterMap);
297
299 std::vector<std::map<std::string, std::vector<std::string>>>
301
304 std::map<std::string, std::vector<std::string>>
305 GetDefaultParameterMap(const std::string transformName,
306 const unsigned int numberOfResolutions = 4,
307 const double finalGridSpacingInPhysicalUnits = 10.0);
308
310 unsigned int
312
314 void
315 SetParameter(const std::string key, const std::string value);
316
318 void
319 SetParameter(const std::string key, const std::vector<std::string> value);
320
323 void
324 SetParameter(const unsigned int index, const std::string key, const std::string value);
325
328 void
329 SetParameter(const unsigned int index, const std::string key, const std::vector<std::string> value);
330
332 void
333 AddParameter(const std::string key, const std::string value);
334
337 void
338 AddParameter(const unsigned int index, const std::string key, const std::string value);
339
341 void
342 AddParameter(const std::string key, const std::vector<std::string> value);
343
346 void
347 AddParameter(const unsigned int index, const std::string key, const std::vector<std::string> value);
348
350 std::vector<std::string>
351 GetParameter(const std::string key);
352
355 std::vector<std::string>
356 GetParameter(const unsigned int index, const std::string key);
357
359 void
360 RemoveParameter(const std::string key);
361
363 void
364 RemoveParameter(const unsigned int index, const std::string key);
365
367 void
368 SetInitialTransformParameterFileName(const std::string initialTransformParmaterFileName);
369
371 std::string
373
375 void
377
379 std::map<std::string, std::vector<std::string>>
380 ReadParameterFile(const std::string filename);
381
383 void
384 WriteParameterFile(const std::map<std::string, std::vector<std::string>> parameterMap, const std::string filename);
385
391 Image
393
395 std::vector<std::map<std::string, std::vector<std::string>>>
397
399 std::map<std::string, std::vector<std::string>>
400 GetTransformParameterMap(const unsigned int index);
401
403 Image
405
407 void
409
411 void
412 PrintParameterMap(const ParameterMapType parameterMapVector);
413
415 void
416 PrintParameterMap(const ParameterMapVectorType parameterMapVector);
417
418private:
420 const std::unique_ptr<ElastixImageFilterImpl> m_Pimple;
421};
422
423// Procedural Interface
424SITKElastix_EXPORT std::map<std::string, std::vector<std::string>>
425 GetDefaultParameterMap(const std::string transform,
426 const unsigned int numberOfResolutions = 4,
427 const double finalGridSpacingInPhysicalUnits = 8.0);
428SITKElastix_EXPORT std::map<std::string, std::vector<std::string>>
429 ReadParameterFile(const std::string filename);
431WriteParameterFile(const std::map<std::string, std::vector<std::string>> parameterMap, const std::string filename);
433PrintParameterMap(const std::map<std::string, std::vector<std::string>> parameterMap);
435PrintParameterMap(const std::vector<std::map<std::string, std::vector<std::string>>> parameterMapVector);
437Elastix(const Image & fixedImage,
438 const Image & movingImage,
439 const bool logToConsole = false,
440 const bool logToFile = false,
441 const std::string outputDirectory = ".");
443Elastix(const Image & fixedImage,
444 const Image & movingImage,
445 const Image & fixedMask,
446 const Image & movingMask,
447 const bool logToConsole = false,
448 const bool logToFile = false,
449 const std::string outputDirectory = ".");
451Elastix(const Image & fixedImage,
452 const Image & movingImage,
453 const std::string defaultParameterMapName,
454 const bool logToConsole = false,
455 const bool logToFile = false,
456 const std::string outputDirectory = ".");
458Elastix(const Image & fixedImage,
459 const Image & movingImage,
460 const std::map<std::string, std::vector<std::string>> parameterMap,
461 const bool logToConsole = false,
462 const bool logToFile = false,
463 const std::string outputDirectory = ".");
465Elastix(const Image & fixedImage,
466 const Image & movingImage,
467 const std::vector<std::map<std::string, std::vector<std::string>>> parameterMapVector,
468 const bool logToConsole = false,
469 const bool logToFile = false,
470 const std::string outputDirectory = ".");
472Elastix(const Image & fixedImage,
473 const Image & movingImage,
474 const std::string defaultParameterMapName,
475 const Image & fixedMask,
476 const Image & movingMask,
477 const bool logToConsole = false,
478 const bool logToFile = false,
479 const std::string outputDirectory = ".");
481Elastix(const Image & fixedImage,
482 const Image & movingImage,
483 const std::map<std::string, std::vector<std::string>>,
484 const Image & fixedMask,
485 const Image & movingMask,
486 const bool logToConsole = false,
487 const bool logToFile = false,
488 const std::string outputDirectory = ".");
490Elastix(const Image & fixedImage,
491 const Image & movingImage,
492 std::vector<std::map<std::string, std::vector<std::string>>> parameterMapVector,
493 const Image & fixedMask,
494 const Image & movingMask,
495 const bool logToConsole = false,
496 const bool logToFile = false,
497 const std::string outputDirectory = ".");
498
499} // namespace itk::simple
500
501#endif // sitkElastixImageFilter_h
void SetFixedMask(const VectorOfImage &fixedMasks)
Sets multiple fixed masks. Stores the images into the container of fixed masks.
void PrintParameterMap(const ParameterMapVectorType parameterMapVector)
Prints the specified parameter maps to standard output.
void LogToConsoleOn()
Switches logging to console on.
void SetOutputDirectory(const std::string outputDirectory)
Sets the output directory.
void SetParameterMap(const std::map< std::string, std::vector< std::string > > parameterMap)
Specifies a single parameter map.
void RemoveParameter(const std::string key)
Removes the parameter specified by key from all parameter maps.
void LogToFileOn()
Switches logging to file on.
void RemoveParameter(const unsigned int index, const std::string key)
Removes the parameter specified by key from the parameter map at the specified (zero-based) index.
Image & GetMovingImage(const unsigned long index)
Retrieves a reference to the moving image at the specified (zero-based) index.
std::string GetOutputDirectory()
Returns the current output directory.
std::vector< std::string > GetParameter(const std::string key)
Retrieves the values of the parameter specified by key, when there is only one parameter map.
bool GetLogToConsole()
Returns whether logging to console is switched on.
void RemoveMovingMask(const unsigned long index)
Removes an image at the specified (zero-based) index from the container of moving masks.
std::string GetLogFileName()
Returns the name of the current log file.
void AddMovingMask(const Image &movingMask)
Adds an image to the end of the container of moving masks.
void SetMovingMask(const Image &movingMask)
Sets a moving mask. Stores the image into the container of moving masks.
void LogToFileOff()
Switches logging to file off.
void RemoveFixedImage(const unsigned long index)
Removes an image at the specified (zero-based) index from the container of fixed images.
Image & GetMovingMask(const unsigned long index)
Retrieves a reference to the moving mask at the specified (zero-based) index.
void RemoveFixedMask()
Removes all fixed masks.
unsigned int GetNumberOfParameterMaps()
Returns the number of parameter maps.
std::string GetFixedPointSetFileName()
Returns the name of the current point set file of points from the fixed image.
void PrintParameterMap()
Prints all parameter maps to standard output.
void SetFixedPointSetFileName(const std::string fixedPointSetFileName)
Specifies a set of points from the fixed image by a point set file, fixedPointSetFileName.
unsigned int GetNumberOfFixedMasks()
Returns the number of fixed masks.
void RemoveMovingMask()
Removes all moving masks.
ParameterMapType::const_iterator ParameterMapConstIterator
std::vector< std::string > GetParameter(const unsigned int index, const std::string key)
Retrieves the values of the parameter specified by key, from the parameter map at the specified (zero...
void RemoveMovingImage(const unsigned long index)
Removes an image at the specified (zero-based) index from the container of moving images.
bool GetLogToFile()
Returns whether logging to file is switched on.
void SetMovingPointSetFileName(const std::string movingPointSetFileName)
Specifies a set of points from the moving image by a point set file, movingPointSetFileName.
Image & GetFixedMask(const unsigned long index)
Retrieves a reference to the fixed mask at the specified (zero-based) index.
void AddMovingImage(const Image &movingImage)
Adds an image to the end of the container of moving images.
Image & GetFixedImage(const unsigned long index)
Retrieves a reference to the fixed image at the specified (zero-based) index.
void AddParameter(const unsigned int index, const std::string key, const std::vector< std::string > value)
Adds a parameter specified by key, with the specified values to the parameter map at the specified (z...
VectorOfImage & GetMovingImage()
Retrieves a reference to the moving image at the specified (zero-based) index.
VectorOfImage & GetMovingMask()
Retrieves a reference to the container of moving masks.
void RemoveFixedImage()
Removes all fixed images.
void SetNumberOfThreads(int n)
Sets the maximum number of threads to the specified number n.
void SetParameterMap(const std::string transformName, const unsigned int numberOfResolutions=4u, const double finalGridSpacingInPhysicalUnits=10.0)
Specifies the parameter map by a transformName ("translation", "rigid" , "affine",...
void SetMovingImage(const VectorOfImage &movingImage)
Sets multiple moving images. Stores the images into the container of moving images.
void RemoveMovingPointSetFileName()
Clears the current point set file name of points from the moving image.
void AddParameter(const unsigned int index, const std::string key, const std::string value)
Adds a parameter specified by key, with the specified value to the parameter map at the specified (ze...
std::map< std::string, std::vector< std::string > > ReadParameterFile(const std::string filename)
Reads the parameter file specified by filename, and returns its content as a parameter map.
int GetNumberOfThreads()
Returns the current maximum number of threads.
std::vector< ParameterMapType > ParameterMapVectorType
std::map< std::string, std::vector< std::string > > GetTransformParameterMap(const unsigned int index)
Returns the transform parameter map at the specified (zero-based) index.
void PrintParameterMap(const ParameterMapType parameterMapVector)
Prints the specified parameter map to standard output.
void WriteParameterFile(const std::map< std::string, std::vector< std::string > > parameterMap, const std::string filename)
Writes a parameter map to the file, specified by filename.
void SetLogToConsole(bool)
Switches logging to console on (true) or off (false), as specified by its function argument.
std::map< ParameterKeyType, ParameterValueVectorType > ParameterMapType
void SetParameterMaps(const std::vector< std::map< std::string, std::vector< std::string > > > parameterMapVector)
Specifies multiple parameter maps.
void AddParameterMap(const std::map< std::string, std::vector< std::string > > parameterMap)
Adds a parameter map to the container of parameter maps.
void RemoveFixedPointSetFileName()
Clears the current point set file name of points from the fixed image.
void SetParameter(const std::string key, const std::string value)
Sets the value of the parameter specified by key, in all parameter maps.
std::string GetMovingPointSetFileName()
Returns the name of the current point set file of points from the moving image.
unsigned int GetNumberOfMovingImages()
Returns the number of moving images.
void SetFixedMask(const Image &fixedMask)
Sets a fixed mask. Stores the image into the container of fixed masks.
void SetFixedImage(const Image &fixedImage)
Sets a fixed image. Stores the image into the container of fixed images.
void SetMovingMask(const VectorOfImage &movingMasks)
Sets multiple moving masks. Stores the images into the container of moving masks.
ParameterValueVectorType::iterator ParameterValueVectorIterator
void SetFixedImage(const VectorOfImage &fixedImages)
Sets multiple fixed images. Stores the images into the container of fixed images.
VectorOfImage & GetFixedImage()
Retrieves a reference to the container of fixed images.
void SetMovingImage(const Image &movingImages)
Sets a moving image. Stores the image into the container of moving images.
void SetParameter(const unsigned int index, const std::string key, const std::vector< std::string > value)
Sets the values of the parameter specified by key, in the parameter map at the specified (zero-based)...
void RemoveLogFileName()
Clears the name of the current log file.
void SetParameter(const std::string key, const std::vector< std::string > value)
Sets the values of the parameter specified by key, in all parameter maps.
unsigned int GetNumberOfMovingMasks()
Returns the number of moving masks.
void RemoveMovingImage()
Removes all moving images.
VectorOfImage & GetFixedMask()
Retrieves a reference to the container of fixed masks.
void LogToConsoleOff()
Switches logging to console off.
void SetLogFileName(const std::string logFileName)
Sets the name of the current log file.
std::vector< ParameterValueType > ParameterValueVectorType
std::map< std::string, std::vector< std::string > > GetDefaultParameterMap(const std::string transformName, const unsigned int numberOfResolutions=4, const double finalGridSpacingInPhysicalUnits=10.0)
Returns the default parameter map for the specified function arguments (transformName may be "transla...
void AddFixedImage(const Image &fixedImage)
Adds an image to the end of the container of fixed images.
std::string GetName() const
void SetParameter(const unsigned int index, const std::string key, const std::string value)
Sets the value of the parameter specified by key, in the parameter map at the specified (zero-based) ...
std::string GetInitialTransformParameterFileName()
Returns the initial transform parameter file name.
unsigned int GetNumberOfFixedImages()
Returns the number of fixed images.
void RemoveFixedMask(const unsigned long index)
Removes an image at the specified (zero-based) index from the container of fixed masks.
void SetInitialTransformParameterFileName(const std::string initialTransformParmaterFileName)
Specifies the initial transformation by the specified transform parameter file name.
void SetLogToFile(const bool logToFile)
Switches logging to file on (true) or off (false), as specified by its function argument.
const std::unique_ptr< ElastixImageFilterImpl > m_Pimple
void AddParameter(const std::string key, const std::vector< std::string > value)
Adds a parameter specified by key, with the specified values to all parameter maps.
std::vector< std::map< std::string, std::vector< std::string > > > GetTransformParameterMaps()
Returns all transform parameter maps.
Image GetResultImage()
Returns the result image.
void AddFixedMask(const Image &fixedMask)
Adds an image to the end of the container of fixed masks.
std::vector< std::map< std::string, std::vector< std::string > > > GetParameterMaps()
Returns a copy of the parameter maps.
ElastixImageFilter()
Default-constructor.
ParameterMapType::iterator ParameterMapIterator
void RemoveInitialTransformParameterFileName()
Clears the initial transform parameter file name.
Image Execute()
Executes the registration, and returns the result image.
void AddParameter(const std::string key, const std::string value)
Adds a parameter specified by key, with the specified value to all parameter maps.
void RemoveOutputDirectory()
Clears the name of the current output directory. (Does not remove the actual directory....
The Image class for SimpleITK.
Definition sitkImage.h:77
SITKElastix_EXPORT Image Elastix(const Image &fixedImage, const Image &movingImage, const bool logToConsole=false, const bool logToFile=false, const std::string outputDirectory=".")
SITKElastix_EXPORT std::map< std::string, std::vector< std::string > > GetDefaultParameterMap(const std::string transform, const unsigned int numberOfResolutions=4, const double finalGridSpacingInPhysicalUnits=8.0)
SITKElastix_EXPORT void PrintParameterMap(const std::map< std::string, std::vector< std::string > > parameterMap)
SITKElastix_EXPORT std::map< std::string, std::vector< std::string > > ReadParameterFile(const std::string filename)
SITKElastix_EXPORT void WriteParameterFile(const std::map< std::string, std::vector< std::string > > parameterMap, const std::string filename)
#define SITKElastix_EXPORT