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 {
31  namespace simple {
32 
37 {
38 public:
39 
42 
45 
47 
48  typedef std::vector< Image > VectorOfImage;
49 
50  typedef std::string ParameterKeyType;
51  typedef std::string ParameterValueType;
52  typedef std::vector< ParameterValueType > ParameterValueVectorType;
53  typedef ParameterValueVectorType::iterator ParameterValueVectorIterator;
54  typedef std::map< ParameterKeyType, ParameterValueVectorType > ParameterMapType;
55  typedef std::vector< ParameterMapType > ParameterMapVectorType;
56  typedef ParameterMapType::iterator ParameterMapIterator;
57  typedef ParameterMapType::const_iterator ParameterMapConstIterator;
58 
59  std::string GetName() const;
60 
62  SITK_RETURN_SELF_TYPE_HEADER SetFixedImage( const Image& fixedImage );
63 
65  SITK_RETURN_SELF_TYPE_HEADER SetFixedImage( const VectorOfImage& fixedImages );
66 
68  SITK_RETURN_SELF_TYPE_HEADER AddFixedImage( const Image& fixedImage );
69 
71  Image& GetFixedImage( const unsigned long index );
72 
74  VectorOfImage& GetFixedImage();
75 
77  SITK_RETURN_SELF_TYPE_HEADER RemoveFixedImage( const unsigned long index );
78 
80  SITK_RETURN_SELF_TYPE_HEADER RemoveFixedImage();
81 
83  unsigned int GetNumberOfFixedImages();
84 
86  SITK_RETURN_SELF_TYPE_HEADER SetMovingImage( const Image& movingImages );
87 
89  SITK_RETURN_SELF_TYPE_HEADER SetMovingImage( const VectorOfImage& movingImage );
90 
92  SITK_RETURN_SELF_TYPE_HEADER AddMovingImage( const Image& movingImage );
93 
95  Image& GetMovingImage( const unsigned long index );
96 
98  VectorOfImage& GetMovingImage();
99 
101  SITK_RETURN_SELF_TYPE_HEADER RemoveMovingImage( const unsigned long index );
102 
104  SITK_RETURN_SELF_TYPE_HEADER RemoveMovingImage();
105 
107  unsigned int GetNumberOfMovingImages();
108 
110  SITK_RETURN_SELF_TYPE_HEADER SetFixedMask( const Image& fixedMask );
111 
113  SITK_RETURN_SELF_TYPE_HEADER SetFixedMask( const VectorOfImage& fixedMasks );
114 
116  SITK_RETURN_SELF_TYPE_HEADER AddFixedMask( const Image& fixedMask );
117 
119  Image& GetFixedMask( const unsigned long index );
120 
122  VectorOfImage& GetFixedMask();
123 
125  SITK_RETURN_SELF_TYPE_HEADER RemoveFixedMask( const unsigned long index );
126 
128  SITK_RETURN_SELF_TYPE_HEADER RemoveFixedMask();
129 
131  unsigned int GetNumberOfFixedMasks();
132 
134  SITK_RETURN_SELF_TYPE_HEADER SetMovingMask( const Image& movingMask );
135 
137  SITK_RETURN_SELF_TYPE_HEADER SetMovingMask( const VectorOfImage& movingMasks );
138 
140  SITK_RETURN_SELF_TYPE_HEADER AddMovingMask( const Image& movingMask );
141 
143  Image& GetMovingMask( const unsigned long index );
144 
146  VectorOfImage& GetMovingMask();
147 
149  SITK_RETURN_SELF_TYPE_HEADER RemoveMovingMask( const unsigned long index );
150 
152  SITK_RETURN_SELF_TYPE_HEADER RemoveMovingMask();
153 
155  unsigned int GetNumberOfMovingMasks();
156 
158  SITK_RETURN_SELF_TYPE_HEADER SetFixedPointSetFileName( const std::string fixedPointSetFileName );
159 
161  std::string GetFixedPointSetFileName();
162 
164  SITK_RETURN_SELF_TYPE_HEADER RemoveFixedPointSetFileName();
165 
167  SITK_RETURN_SELF_TYPE_HEADER SetMovingPointSetFileName( const std::string movingPointSetFileName );
168 
170  std::string GetMovingPointSetFileName();
171 
173  SITK_RETURN_SELF_TYPE_HEADER RemoveMovingPointSetFileName();
174 
176  SITK_RETURN_SELF_TYPE_HEADER SetOutputDirectory( const std::string outputDirectory );
177 
179  std::string GetOutputDirectory();
180 
182  SITK_RETURN_SELF_TYPE_HEADER RemoveOutputDirectory();
183 
185  SITK_RETURN_SELF_TYPE_HEADER SetLogFileName( const std::string logFileName );
186 
188  std::string GetLogFileName();
189 
191  SITK_RETURN_SELF_TYPE_HEADER RemoveLogFileName();
192 
194  SITK_RETURN_SELF_TYPE_HEADER SetLogToFile( const bool logToFile );
195 
197  bool GetLogToFile();
198 
200  SITK_RETURN_SELF_TYPE_HEADER LogToFileOn();
201 
203  SITK_RETURN_SELF_TYPE_HEADER LogToFileOff();
204 
206  SITK_RETURN_SELF_TYPE_HEADER SetLogToConsole( bool );
207 
209  bool GetLogToConsole();
210 
212  SITK_RETURN_SELF_TYPE_HEADER LogToConsoleOn();
213 
215  SITK_RETURN_SELF_TYPE_HEADER LogToConsoleOff();
216 
219  SITK_RETURN_SELF_TYPE_HEADER SetNumberOfThreads( int n );
220 
222  int GetNumberOfThreads();
223 
225  SITK_RETURN_SELF_TYPE_HEADER SetParameterMap( const std::string transformName, const unsigned int numberOfResolutions = 4u, const double finalGridSpacingInPhysicalUnits = 10.0 );
226 
228  SITK_RETURN_SELF_TYPE_HEADER SetParameterMap( const std::vector< std::map< std::string, std::vector< std::string > > > parameterMapVector );
229 
231  SITK_RETURN_SELF_TYPE_HEADER SetParameterMap( const std::map< std::string, std::vector< std::string > > parameterMap );
232 
234  SITK_RETURN_SELF_TYPE_HEADER AddParameterMap( const std::map< std::string, std::vector< std::string > > parameterMap );
235 
237  std::vector< std::map< std::string, std::vector< std::string > > > GetParameterMap();
238 
240  std::map< std::string, std::vector< std::string > > GetDefaultParameterMap( const std::string transformName, const unsigned int numberOfResolutions = 4, const double finalGridSpacingInPhysicalUnits = 10.0 );
241 
243  unsigned int GetNumberOfParameterMaps();
244 
246  SITK_RETURN_SELF_TYPE_HEADER SetParameter( const std::string key, const std::string value );
247 
249  SITK_RETURN_SELF_TYPE_HEADER SetParameter( const std::string key, const std::vector< std::string > value );
250 
252  SITK_RETURN_SELF_TYPE_HEADER SetParameter( const unsigned int index, const std::string key, const std::string value );
253 
255  SITK_RETURN_SELF_TYPE_HEADER SetParameter( const unsigned int index, const std::string key, const std::vector< std::string > value );
256 
258  SITK_RETURN_SELF_TYPE_HEADER AddParameter( const std::string key, const std::string value );
259 
261  SITK_RETURN_SELF_TYPE_HEADER AddParameter( const unsigned int index, const std::string key, const std::string value );
262 
264  SITK_RETURN_SELF_TYPE_HEADER AddParameter( const std::string key, const std::vector< std::string > value );
265 
267  SITK_RETURN_SELF_TYPE_HEADER AddParameter( const unsigned int index, const std::string key, const std::vector< std::string > value );
268 
270  std::vector< std::string > GetParameter( const std::string key );
271 
273  std::vector< std::string > GetParameter( const unsigned int index, const std::string key );
274 
276  SITK_RETURN_SELF_TYPE_HEADER RemoveParameter( const std::string key );
277 
279  SITK_RETURN_SELF_TYPE_HEADER RemoveParameter( const unsigned int index, const std::string key );
280 
282  SITK_RETURN_SELF_TYPE_HEADER SetInitialTransformParameterFileName( const std::string initialTransformParmaterFileName );
283 
285  std::string GetInitialTransformParameterFileName();
286 
288  SITK_RETURN_SELF_TYPE_HEADER RemoveInitialTransformParameterFileName();
289 
291  std::map< std::string, std::vector< std::string > > ReadParameterFile( const std::string filename );
292 
294  SITK_RETURN_SELF_TYPE_HEADER WriteParameterFile( const std::map< std::string, std::vector< std::string > > parameterMap, const std::string filename );
295 
301  Image Execute();
302 
304  std::vector< std::map< std::string, std::vector< std::string > > > GetTransformParameterMap();
305 
307  std::map< std::string, std::vector< std::string > > GetTransformParameterMap( const unsigned int index );
308 
310  Image GetResultImage();
311 
313  SITK_RETURN_SELF_TYPE_HEADER PrintParameterMap();
314 
316  SITK_RETURN_SELF_TYPE_HEADER PrintParameterMap( const ParameterMapType parameterMapVector );
317 
319  SITK_RETURN_SELF_TYPE_HEADER PrintParameterMap( const ParameterMapVectorType parameterMapVector );
320 
321 private:
322 
323  class ElastixImageFilterImpl;
324  const std::unique_ptr<ElastixImageFilterImpl> m_Pimple;
325 
326 };
327 
328 // Procedural Interface
329 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 );
330 SITKElastix_EXPORT std::map< std::string, std::vector< std::string > > ReadParameterFile( const std::string filename );
331 SITKElastix_EXPORT void WriteParameterFile( const std::map< std::string, std::vector< std::string > > parameterMap, const std::string filename );
332 SITKElastix_EXPORT void PrintParameterMap( const std::map< std::string, std::vector< std::string > > parameterMap );
333 SITKElastix_EXPORT void PrintParameterMap( const std::vector< std::map< std::string, std::vector< std::string > > > parameterMapVector );
334 SITKElastix_EXPORT Image Elastix( const Image& fixedImage, const Image& movingImage, const bool logToConsole = false, const bool logToFile = false, const std::string outputDirectory = "." );
335 SITKElastix_EXPORT Image Elastix( const Image& fixedImage, const Image& movingImage, const Image& fixedMask, const Image& movingMask, const bool logToConsole = false, const bool logToFile = false, const std::string outputDirectory = "." );
336 SITKElastix_EXPORT Image Elastix( const Image& fixedImage, const Image& movingImage, const std::string defaultParameterMapName, const bool logToConsole = false, const bool logToFile = false, const std::string outputDirectory = "." );
337 SITKElastix_EXPORT Image Elastix( const Image& fixedImage, const Image& movingImage, const std::map< std::string, std::vector< std::string > > parameterMap, const bool logToConsole = false, const bool logToFile = false, const std::string outputDirectory = "." );
338 SITKElastix_EXPORT Image Elastix( const Image& fixedImage, const Image& movingImage, const std::vector< std::map< std::string, std::vector< std::string > > > parameterMapVector, const bool logToConsole = false, const bool logToFile = false, const std::string outputDirectory = "." );
339 SITKElastix_EXPORT Image Elastix( const Image& fixedImage, const Image& movingImage, const std::string defaultParameterMapName, const Image& fixedMask, const Image& movingMask, const bool logToConsole = false, const bool logToFile = false, const std::string outputDirectory = "." );
340 SITKElastix_EXPORT Image Elastix( const Image& fixedImage, const Image& movingImage, const std::map< std::string, std::vector< std::string > >, const Image& fixedMask, const Image& movingMask, const bool logToConsole = false, const bool logToFile = false, const std::string outputDirectory = "." );
341 SITKElastix_EXPORT Image Elastix( const Image& fixedImage, const Image& movingImage, std::vector< std::map< std::string, std::vector< std::string > > > parameterMapVector, const Image& fixedMask, const Image& movingMask, const bool logToConsole = false, const bool logToFile = false, const std::string outputDirectory = "." );
342 
343 } // end namespace simple
344 } // end namespace itk
345 
346 #endif // sitkElastixImageFilter_h
itk::simple::Image
The Image class for SimpleITK.
Definition: sitkImage.h:76
itk::simple::ElastixImageFilter::ParameterValueVectorType
std::vector< ParameterValueType > ParameterValueVectorType
Definition: sitkElastixImageFilter.h:52
itk::simple::ReadParameterFile
SITKElastix_EXPORT std::map< std::string, std::vector< std::string > > ReadParameterFile(const std::string filename)
itk::simple::ElastixImageFilter::ParameterMapIterator
ParameterMapType::iterator ParameterMapIterator
Definition: sitkElastixImageFilter.h:56
sitkCommon.h
sitkImage.h
itk::simple::ElastixImageFilter::ParameterValueType
std::string ParameterValueType
Definition: sitkElastixImageFilter.h:51
itk::simple::ElastixImageFilter::ParameterKeyType
std::string ParameterKeyType
Definition: sitkElastixImageFilter.h:50
SITKElastix_EXPORT
#define SITKElastix_EXPORT
Definition: sitkElastixTransformixWrappers.h:32
itk::simple::ElastixImageFilter::VectorOfImage
std::vector< Image > VectorOfImage
Definition: sitkElastixImageFilter.h:48
itk::simple::ElastixImageFilter
The class that wraps the elastix registration library.
Definition: sitkElastixImageFilter.h:36
sitkElastixTransformixWrappers.h
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::ParameterMapConstIterator
ParameterMapType::const_iterator ParameterMapConstIterator
Definition: sitkElastixImageFilter.h:57
itk::simple::ElastixImageFilter::Self
ElastixImageFilter Self
Definition: sitkElastixImageFilter.h:46
itk::simple::ElastixImageFilter::ParameterMapType
std::map< ParameterKeyType, ParameterValueVectorType > ParameterMapType
Definition: sitkElastixImageFilter.h:54
itk::simple::WriteParameterFile
SITKElastix_EXPORT void WriteParameterFile(const std::map< std::string, std::vector< std::string > > parameterMap, const std::string filename)
itk::simple::ElastixImageFilter::m_Pimple
const std::unique_ptr< ElastixImageFilterImpl > m_Pimple
Definition: sitkElastixImageFilter.h:323
itk
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::ParameterMapVectorType
std::vector< ParameterMapType > ParameterMapVectorType
Definition: sitkElastixImageFilter.h:55
itk::simple::ElastixImageFilter::ParameterValueVectorIterator
ParameterValueVectorType::iterator ParameterValueVectorIterator
Definition: sitkElastixImageFilter.h:53
itk::simple::PrintParameterMap
SITKElastix_EXPORT void PrintParameterMap(const std::map< std::string, std::vector< std::string > > parameterMap)