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  SITK_RETURN_SELF_TYPE_HEADER
290  SetParameterMaps(const std::vector<std::map<std::string, std::vector<std::string>>> parameterMapVector) { return SetParameterMap(parameterMapVector);}
291 
293  SITK_RETURN_SELF_TYPE_HEADER
294  SetParameterMap(const std::map<std::string, std::vector<std::string>> parameterMap);
295 
297  SITK_RETURN_SELF_TYPE_HEADER
298  AddParameterMap(const std::map<std::string, std::vector<std::string>> parameterMap);
299 
301  std::vector<std::map<std::string, std::vector<std::string>>>
302  GetParameterMap();
303  std::vector<std::map<std::string, std::vector<std::string>>>
304  GetParameterMaps() { return GetParameterMap(); };
305 
308  std::map<std::string, std::vector<std::string>>
309  GetDefaultParameterMap(const std::string transformName,
310  const unsigned int numberOfResolutions = 4,
311  const double finalGridSpacingInPhysicalUnits = 10.0);
312 
314  unsigned int
315  GetNumberOfParameterMaps();
316 
318  SITK_RETURN_SELF_TYPE_HEADER
319  SetParameter(const std::string key, const std::string value);
320 
322  SITK_RETURN_SELF_TYPE_HEADER
323  SetParameter(const std::string key, const std::vector<std::string> value);
324 
327  SITK_RETURN_SELF_TYPE_HEADER
328  SetParameter(const unsigned int index, const std::string key, const std::string value);
329 
332  SITK_RETURN_SELF_TYPE_HEADER
333  SetParameter(const unsigned int index, const std::string key, const std::vector<std::string> value);
334 
336  SITK_RETURN_SELF_TYPE_HEADER
337  AddParameter(const std::string key, const std::string value);
338 
341  SITK_RETURN_SELF_TYPE_HEADER
342  AddParameter(const unsigned int index, const std::string key, const std::string value);
343 
345  SITK_RETURN_SELF_TYPE_HEADER
346  AddParameter(const std::string key, const std::vector<std::string> value);
347 
350  SITK_RETURN_SELF_TYPE_HEADER
351  AddParameter(const unsigned int index, const std::string key, const std::vector<std::string> value);
352 
354  std::vector<std::string>
355  GetParameter(const std::string key);
356 
359  std::vector<std::string>
360  GetParameter(const unsigned int index, const std::string key);
361 
363  SITK_RETURN_SELF_TYPE_HEADER
364  RemoveParameter(const std::string key);
365 
367  SITK_RETURN_SELF_TYPE_HEADER
368  RemoveParameter(const unsigned int index, const std::string key);
369 
371  SITK_RETURN_SELF_TYPE_HEADER
372  SetInitialTransformParameterFileName(const std::string initialTransformParmaterFileName);
373 
375  std::string
376  GetInitialTransformParameterFileName();
377 
379  SITK_RETURN_SELF_TYPE_HEADER
380  RemoveInitialTransformParameterFileName();
381 
383  std::map<std::string, std::vector<std::string>>
384  ReadParameterFile(const std::string filename);
385 
387  SITK_RETURN_SELF_TYPE_HEADER
388  WriteParameterFile(const std::map<std::string, std::vector<std::string>> parameterMap, const std::string filename);
389 
395  Image
396  Execute();
397 
399  std::vector<std::map<std::string, std::vector<std::string>>>
400  GetTransformParameterMap();
401 
403  std::map<std::string, std::vector<std::string>>
404  GetTransformParameterMap(const unsigned int index);
405 
407  Image
408  GetResultImage();
409 
411  SITK_RETURN_SELF_TYPE_HEADER
413 
415  SITK_RETURN_SELF_TYPE_HEADER
416  PrintParameterMap(const ParameterMapType parameterMapVector);
417 
419  SITK_RETURN_SELF_TYPE_HEADER
420  PrintParameterMap(const ParameterMapVectorType parameterMapVector);
421 
422 private:
423  class ElastixImageFilterImpl;
424  const std::unique_ptr<ElastixImageFilterImpl> m_Pimple;
425 };
426 
427 // Procedural Interface
428 SITKElastix_EXPORT std::map<std::string, std::vector<std::string>>
429  GetDefaultParameterMap(const std::string transform,
430  const unsigned int numberOfResolutions = 4,
431  const double finalGridSpacingInPhysicalUnits = 8.0);
432 SITKElastix_EXPORT std::map<std::string, std::vector<std::string>>
433  ReadParameterFile(const std::string filename);
435 WriteParameterFile(const std::map<std::string, std::vector<std::string>> parameterMap, const std::string filename);
437 PrintParameterMap(const std::map<std::string, std::vector<std::string>> parameterMap);
439 PrintParameterMap(const std::vector<std::map<std::string, std::vector<std::string>>> parameterMapVector);
441 Elastix(const Image & fixedImage,
442  const Image & movingImage,
443  const bool logToConsole = false,
444  const bool logToFile = false,
445  const std::string outputDirectory = ".");
447 Elastix(const Image & fixedImage,
448  const Image & movingImage,
449  const Image & fixedMask,
450  const Image & movingMask,
451  const bool logToConsole = false,
452  const bool logToFile = false,
453  const std::string outputDirectory = ".");
455 Elastix(const Image & fixedImage,
456  const Image & movingImage,
457  const std::string defaultParameterMapName,
458  const bool logToConsole = false,
459  const bool logToFile = false,
460  const std::string outputDirectory = ".");
462 Elastix(const Image & fixedImage,
463  const Image & movingImage,
464  const std::map<std::string, std::vector<std::string>> parameterMap,
465  const bool logToConsole = false,
466  const bool logToFile = false,
467  const std::string outputDirectory = ".");
469 Elastix(const Image & fixedImage,
470  const Image & movingImage,
471  const std::vector<std::map<std::string, std::vector<std::string>>> parameterMapVector,
472  const bool logToConsole = false,
473  const bool logToFile = false,
474  const std::string outputDirectory = ".");
476 Elastix(const Image & fixedImage,
477  const Image & movingImage,
478  const std::string defaultParameterMapName,
479  const Image & fixedMask,
480  const Image & movingMask,
481  const bool logToConsole = false,
482  const bool logToFile = false,
483  const std::string outputDirectory = ".");
485 Elastix(const Image & fixedImage,
486  const Image & movingImage,
487  const std::map<std::string, std::vector<std::string>>,
488  const Image & fixedMask,
489  const Image & movingMask,
490  const bool logToConsole = false,
491  const bool logToFile = false,
492  const std::string outputDirectory = ".");
494 Elastix(const Image & fixedImage,
495  const Image & movingImage,
496  std::vector<std::map<std::string, std::vector<std::string>>> parameterMapVector,
497  const Image & fixedMask,
498  const Image & movingMask,
499  const bool logToConsole = false,
500  const bool logToFile = false,
501  const std::string outputDirectory = ".");
502 
503 } // namespace itk::simple
504 
505 #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::SetParameterMaps
Self & SetParameterMaps(const std::vector< std::map< std::string, std::vector< std::string >>> parameterMapVector)
Definition: sitkElastixImageFilter.h:290
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:423
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)
itk::simple::ElastixImageFilter::GetParameterMaps
std::vector< std::map< std::string, std::vector< std::string > > > GetParameterMaps()
Definition: sitkElastixImageFilter.h:304