1
2
3import sys
4import SimpleITK as sitk
5
6if len(sys.argv) < 3:
7 print("Usage: ParameterMaps <fixedImage> <movingImage> [outputImage]")
8 sys.exit(1)
9
10
13
14print("SimpleITK Elastix Parameter Maps Example")
15print("=" * 60)
16
17
18
20
21
23
24
25
26
27parameter_map["Transform"] = ["AffineTransform"]
28parameter_map["MaximumNumberOfIterations"] = ["512"]
29parameter_map["NumberOfSpatialSamples"] = ["8192"]
30
31
32
33
35elastix_image_filter.SetFixedImage(fixed_image)
36elastix_image_filter.SetMovingImage(moving_image)
37
40
42bspline_map["FinalGridSpacingInPhysicalUnits"] = ["8.0"]
43elastix_image_filter.AddParameterMap(bspline_map)
44
45elastix_image_filter.LogToConsoleOff()
46result_image = elastix_image_filter.Execute()
47
48
49transform_parameter_maps = elastix_image_filter.GetTransformParameterMaps()
50
51
52
53
55
56
58
59
60
61if len(sys.argv) > 3:
62 output_dir = sys.argv[3]
63 for i, tpm in enumerate(transform_parameter_maps):
64 filename = f"{output_dir}_TransformParameters_{i}.txt"
67print("Example completed successfully!")
68print("=" * 60)
The class that wraps the elastix registration library.
SITKIO_EXPORT Image ReadImage(const PathType &filename, PixelIDValueEnum outputPixelType=sitkUnknown, const std::string &imageIO="")
ReadImage is a procedural interface to the ImageFileReader class which is convenient for most image r...
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)
SITKIO_EXPORT void WriteImage(const Image &image, const PathType &fileName, bool useCompression=false, int compressionLevel=-1)
WriteImage is a procedural interface to the ImageFileWriter. class which is convenient for many image...
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)