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 
30 namespace itk::simple
31 {
32 
37 {
38 public:
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  SITK_RETURN_SELF_TYPE_HEADER
63  SetFixedImage(const Image & fixedImage);
64 
66  SITK_RETURN_SELF_TYPE_HEADER
67  SetFixedImage(const VectorOfImage & fixedImages);
68 
70  SITK_RETURN_SELF_TYPE_HEADER
71  AddFixedImage(const Image & fixedImage);
72 
74  Image &
75  GetFixedImage(const unsigned long index);
76 
79  GetFixedImage();
80 
82  SITK_RETURN_SELF_TYPE_HEADER
83  RemoveFixedImage(const unsigned long index);
84 
86  SITK_RETURN_SELF_TYPE_HEADER
87  RemoveFixedImage();
88 
90  unsigned int
91  GetNumberOfFixedImages();
92 
94  SITK_RETURN_SELF_TYPE_HEADER
95  SetMovingImage(const Image & movingImages);
96 
98  SITK_RETURN_SELF_TYPE_HEADER
99  SetMovingImage(const VectorOfImage & movingImage);
100 
102  SITK_RETURN_SELF_TYPE_HEADER
103  AddMovingImage(const Image & movingImage);
104 
106  Image &
107  GetMovingImage(const unsigned long index);
108 
110  VectorOfImage &
111  GetMovingImage();
112 
114  SITK_RETURN_SELF_TYPE_HEADER
115  RemoveMovingImage(const unsigned long index);
116 
118  SITK_RETURN_SELF_TYPE_HEADER
119  RemoveMovingImage();
120 
122  unsigned int
123  GetNumberOfMovingImages();
124 
126  SITK_RETURN_SELF_TYPE_HEADER
127  SetFixedMask(const Image & fixedMask);
128 
130  SITK_RETURN_SELF_TYPE_HEADER
131  SetFixedMask(const VectorOfImage & fixedMasks);
132 
134  SITK_RETURN_SELF_TYPE_HEADER
135  AddFixedMask(const Image & fixedMask);
136 
138  Image &
139  GetFixedMask(const unsigned long index);
140 
142  VectorOfImage &
143  GetFixedMask();
144 
146  SITK_RETURN_SELF_TYPE_HEADER
147  RemoveFixedMask(const unsigned long index);
148 
150  SITK_RETURN_SELF_TYPE_HEADER
151  RemoveFixedMask();
152 
154  unsigned int
155  GetNumberOfFixedMasks();
156 
158  SITK_RETURN_SELF_TYPE_HEADER
159  SetMovingMask(const Image & movingMask);
160 
162  SITK_RETURN_SELF_TYPE_HEADER
163  SetMovingMask(const VectorOfImage & movingMasks);
164 
166  SITK_RETURN_SELF_TYPE_HEADER
167  AddMovingMask(const Image & movingMask);
168 
170  Image &
171  GetMovingMask(const unsigned long index);
172 
174  VectorOfImage &
175  GetMovingMask();
176 
178  SITK_RETURN_SELF_TYPE_HEADER
179  RemoveMovingMask(const unsigned long index);
180 
182  SITK_RETURN_SELF_TYPE_HEADER
183  RemoveMovingMask();
184 
186  unsigned int
187  GetNumberOfMovingMasks();
188 
190  SITK_RETURN_SELF_TYPE_HEADER
191  SetFixedPointSetFileName(const std::string fixedPointSetFileName);
192 
194  std::string
195  GetFixedPointSetFileName();
196 
198  SITK_RETURN_SELF_TYPE_HEADER
199  RemoveFixedPointSetFileName();
200 
202  SITK_RETURN_SELF_TYPE_HEADER
203  SetMovingPointSetFileName(const std::string movingPointSetFileName);
204 
206  std::string
207  GetMovingPointSetFileName();
208 
210  SITK_RETURN_SELF_TYPE_HEADER
211  RemoveMovingPointSetFileName();
212 
214  SITK_RETURN_SELF_TYPE_HEADER
215  SetOutputDirectory(const std::string outputDirectory);
216 
218  std::string
219  GetOutputDirectory();
220 
222  SITK_RETURN_SELF_TYPE_HEADER
223  RemoveOutputDirectory();
224 
226  SITK_RETURN_SELF_TYPE_HEADER
227  SetLogFileName(const std::string logFileName);
228 
230  std::string
231  GetLogFileName();
232 
234  SITK_RETURN_SELF_TYPE_HEADER
235  RemoveLogFileName();
236 
238  SITK_RETURN_SELF_TYPE_HEADER
239  SetLogToFile(const bool logToFile);
240 
242  bool
243  GetLogToFile();
244 
246  SITK_RETURN_SELF_TYPE_HEADER
247  LogToFileOn();
248 
250  SITK_RETURN_SELF_TYPE_HEADER
251  LogToFileOff();
252 
254  SITK_RETURN_SELF_TYPE_HEADER
255  SetLogToConsole(bool);
256 
258  bool
259  GetLogToConsole();
260 
262  SITK_RETURN_SELF_TYPE_HEADER
263  LogToConsoleOn();
264 
266  SITK_RETURN_SELF_TYPE_HEADER
267  LogToConsoleOff();
268 
272  SITK_RETURN_SELF_TYPE_HEADER
273  SetNumberOfThreads(int n);
274 
276  int
277  GetNumberOfThreads();
278 
281  SITK_RETURN_SELF_TYPE_HEADER
282  SetParameterMap(const std::string transformName,
283  const unsigned int numberOfResolutions = 4u,
284  const double finalGridSpacingInPhysicalUnits = 10.0);
285 
287  SITK_RETURN_SELF_TYPE_HEADER
288  SetParameterMap(const std::vector<std::map<std::string, std::vector<std::string>>> parameterMapVector);
289 
291  SITK_RETURN_SELF_TYPE_HEADER
292  SetParameterMap(const std::map<std::string, std::vector<std::string>> parameterMap);
293 
295  SITK_RETURN_SELF_TYPE_HEADER
296  AddParameterMap(const std::map<std::string, std::vector<std::string>> parameterMap);
297 
299  std::vector<std::map<std::string, std::vector<std::string>>>
300  GetParameterMap();
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
311  GetNumberOfParameterMaps();
312 
314  SITK_RETURN_SELF_TYPE_HEADER
315  SetParameter(const std::string key, const std::string value);
316 
318  SITK_RETURN_SELF_TYPE_HEADER
319  SetParameter(const std::string key, const std::vector<std::string> value);
320 
323  SITK_RETURN_SELF_TYPE_HEADER
324  SetParameter(const unsigned int index, const std::string key, const std::string value);
325 
328  SITK_RETURN_SELF_TYPE_HEADER
329  SetParameter(const unsigned int index, const std::string key, const std::vector<std::string> value);
330 
332  SITK_RETURN_SELF_TYPE_HEADER
333  AddParameter(const std::string key, const std::string value);
334 
337  SITK_RETURN_SELF_TYPE_HEADER
338  AddParameter(const unsigned int index, const std::string key, const std::string value);
339 
341  SITK_RETURN_SELF_TYPE_HEADER
342  AddParameter(const std::string key, const std::vector<std::string> value);
343 
346  SITK_RETURN_SELF_TYPE_HEADER
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  SITK_RETURN_SELF_TYPE_HEADER
360  RemoveParameter(const std::string key);
361 
363  SITK_RETURN_SELF_TYPE_HEADER
364  RemoveParameter(const unsigned int index, const std::string key);
365 
367  SITK_RETURN_SELF_TYPE_HEADER
368  SetInitialTransformParameterFileName(const std::string initialTransformParmaterFileName);
369 
371  std::string
372  GetInitialTransformParameterFileName();
373 
375  SITK_RETURN_SELF_TYPE_HEADER
376  RemoveInitialTransformParameterFileName();
377 
379  std::map<std::string, std::vector<std::string>>
380  ReadParameterFile(const std::string filename);
381 
383  SITK_RETURN_SELF_TYPE_HEADER
384  WriteParameterFile(const std::map<std::string, std::vector<std::string>> parameterMap, const std::string filename);
385 
391  Image
392  Execute();
393 
395  std::vector<std::map<std::string, std::vector<std::string>>>
396  GetTransformParameterMap();
397 
399  std::map<std::string, std::vector<std::string>>
400  GetTransformParameterMap(const unsigned int index);
401 
403  Image
404  GetResultImage();
405 
407  SITK_RETURN_SELF_TYPE_HEADER
409 
411  SITK_RETURN_SELF_TYPE_HEADER
412  PrintParameterMap(const ParameterMapType parameterMapVector);
413 
415  SITK_RETURN_SELF_TYPE_HEADER
416  PrintParameterMap(const ParameterMapVectorType parameterMapVector);
417 
418 private:
419  class ElastixImageFilterImpl;
420  const std::unique_ptr<ElastixImageFilterImpl> m_Pimple;
421 };
422 
423 // Procedural Interface
424 SITKElastix_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);
428 SITKElastix_EXPORT std::map<std::string, std::vector<std::string>>
429  ReadParameterFile(const std::string filename);
431 WriteParameterFile(const std::map<std::string, std::vector<std::string>> parameterMap, const std::string filename);
433 PrintParameterMap(const std::map<std::string, std::vector<std::string>> parameterMap);
435 PrintParameterMap(const std::vector<std::map<std::string, std::vector<std::string>>> parameterMapVector);
437 Elastix(const Image & fixedImage,
438  const Image & movingImage,
439  const bool logToConsole = false,
440  const bool logToFile = false,
441  const std::string outputDirectory = ".");
443 Elastix(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 = ".");
451 Elastix(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 = ".");
458 Elastix(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 = ".");
465 Elastix(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 = ".");
472 Elastix(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 = ".");
481 Elastix(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 = ".");
490 Elastix(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
itk::simple::Image
The Image class for SimpleITK.
Definition: sitkImage.h:76
itk::simple::PrintParameterMap
SITKElastix_EXPORT void PrintParameterMap(const std::map< std::string, std::vector< std::string >> parameterMap)
itk::simple::ElastixImageFilter::VectorOfImage
std::vector< Image > VectorOfImage
Definition: sitkElastixImageFilter.h:47
itk::simple::WriteParameterFile
SITKElastix_EXPORT void WriteParameterFile(const std::map< std::string, std::vector< std::string >> parameterMap, const std::string filename)
itk::simple::ElastixImageFilter::ParameterMapIterator
ParameterMapType::iterator ParameterMapIterator
Definition: sitkElastixImageFilter.h:55
sitkCommon.h
sitkImage.h
itk::simple::ElastixImageFilter::ParameterValueType
std::string ParameterValueType
Definition: sitkElastixImageFilter.h:50
itk::simple::ElastixImageFilter::ParameterKeyType
std::string ParameterKeyType
Definition: sitkElastixImageFilter.h:49
SITKElastix_EXPORT
#define SITKElastix_EXPORT
Definition: sitkElastixTransformixWrappers.h:32
itk::simple::ElastixImageFilter
The class that wraps the elastix registration library.
Definition: sitkElastixImageFilter.h:36
sitkElastixTransformixWrappers.h
itk::simple::ElastixImageFilter::ParameterMapConstIterator
ParameterMapType::const_iterator ParameterMapConstIterator
Definition: sitkElastixImageFilter.h:56
itk::simple::ElastixImageFilter::ParameterValueVectorType
std::vector< ParameterValueType > ParameterValueVectorType
Definition: sitkElastixImageFilter.h:51
itk::simple::ElastixImageFilter::Self
ElastixImageFilter Self
Definition: sitkElastixImageFilter.h:45
itk::simple::ElastixImageFilter::ParameterMapType
std::map< ParameterKeyType, ParameterValueVectorType > ParameterMapType
Definition: sitkElastixImageFilter.h:53
itk::simple::GetDefaultParameterMap
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)
itk::simple::ElastixImageFilter::m_Pimple
const std::unique_ptr< ElastixImageFilterImpl > m_Pimple
Definition: sitkElastixImageFilter.h:419
itk::simple::ElastixImageFilter::ParameterMapVectorType
std::vector< ParameterMapType > ParameterMapVectorType
Definition: sitkElastixImageFilter.h:54
itk::simple::Elastix
SITKElastix_EXPORT Image Elastix(const Image &fixedImage, const Image &movingImage, const bool logToConsole=false, const bool logToFile=false, const std::string outputDirectory=".")
itk::simple::ElastixImageFilter::ParameterValueVectorIterator
ParameterValueVectorType::iterator ParameterValueVectorIterator
Definition: sitkElastixImageFilter.h:52
itk::simple
Definition: sitkAdditionalProcedures.h:28
itk::simple::ReadParameterFile
SITKElastix_EXPORT std::map< std::string, std::vector< std::string > > ReadParameterFile(const std::string filename)