{"id":5478,"library":"simpleitk","title":"SimpleITK","description":"SimpleITK is a simplified, open-source interface to the Insight Segmentation and Registration Toolkit (ITK) for image registration and segmentation. It supports multiple programming languages, including Python, and offers a high-level, procedural interface to ITK's extensive algorithms. It aims to make image analysis more accessible for rapid prototyping, education, and various applications, especially in medical imaging. The current version is 2.5.3, with regular releases.","status":"active","version":"2.5.3","language":"en","source_language":"en","source_url":"https://github.com/SimpleITK/SimpleITK","tags":["image processing","medical imaging","segmentation","registration","ITK"],"install":[{"cmd":"pip install SimpleITK","lang":"bash","label":"PyPI (recommended)"},{"cmd":"conda install -c conda-forge simpleitk","lang":"bash","label":"Conda"}],"dependencies":[],"imports":[{"note":"The PyPI package name is lowercase ('simpleitk'), but the Python module to import uses camel case ('SimpleITK'). By convention, it's often aliased as 'sitk'.","wrong":"import simpleitk","symbol":"SimpleITK","correct":"import SimpleITK as sitk"}],"quickstart":{"code":"import SimpleITK as sitk\n\n# Create a 2D image (e.g., 64x64 pixels, 16-bit integer)\nimage_size = [64, 64]\nimage = sitk.Image(image_size, sitk.sitkInt16)\n\n# Set some pixel values (e.g., a square in the middle)\n# Note: SimpleITK indexing is (x,y,z), while numpy conversion often reverses axes.\nimage[10:50, 10:50] = 100\n\n# Apply a Gaussian smoothing filter\ngaussian_filter = sitk.SmoothingRecursiveGaussianImageFilter()\ngaussian_filter.SetSigma(2.0) # Set the standard deviation of the Gaussian\nsmoothed_image = gaussian_filter.Execute(image)\n\n# Get a pixel value at a specific index\npixel_value = smoothed_image.GetPixel((32, 32))\nprint(f\"Pixel value at (32,32) after smoothing: {pixel_value}\")\n\n# Save the image (e.g., to a MetaImage file format)\nsitk.WriteImage(smoothed_image, \"smoothed_image.mha\")\nprint(\"Saved smoothed_image.mha\")\n\n# To visualize the image, you would typically use an external viewer\n# For example, if ImageJ/Fiji is installed and configured:\n# sitk.Show(smoothed_image, 'Smoothed Image')","lang":"python","description":"This quickstart demonstrates how to create a SimpleITK image, set pixel values, apply a Gaussian smoothing filter, read a pixel value, and save the resulting image to disk. For visualization, external tools like ImageJ/Fiji are typically used via `sitk.Show()`."},"warnings":[{"fix":"Replace `tx.AddTransform(tx1)` with `tx = sitk.CompositeTransform([tx1, tx2])`.","message":"SimpleITK 2.0 removed the `Transform::AddTransform` method. Composite transformations are now handled by a dedicated `CompositeTransform` class, requiring explicit creation of this class instead of adding transforms to a generic `Transform` object.","severity":"breaking","affected_versions":"2.0.0 and later"},{"fix":"Instead of `filter.Execute(image, param1, param2)`, use `filter.SetParam1(param1); filter.SetParam2(param2); output = filter.Execute(image)`.","message":"With SimpleITK 2.0, filter `Execute` methods no longer accept parameters as arguments. All filter parameters must be set via their respective `SetXYZ` methods on the filter object before calling `Execute`.","severity":"breaking","affected_versions":"2.0.0 and later"},{"fix":"Be mindful of axis order during conversion and adjust indexing or array reshaping accordingly. For a 3D image, SimpleITK's `image[x,y,z]` corresponds to NumPy's `np_array[z,y,x]`.","message":"When converting between a SimpleITK `Image` object and a NumPy array (e.g., using `sitk.GetArrayFromImage` or `sitk.GetImageFromArray`), the axis order is reversed. SimpleITK uses (x, y, z) indexing, while NumPy typically uses (z, y, x) (depth, rows, columns).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Install the appropriate Microsoft Visual C++ Redistributable for Visual Studio package for your Python and SimpleITK build (e.g., for VS 2015-2022).","message":"On Windows, importing SimpleITK may fail with `ImportError: DLL load failed while importing _SimpleITK: The specified module could not be found`. This often indicates missing Microsoft Visual C++ Redistributable packages.","severity":"gotcha","affected_versions":"All versions on Windows"},{"fix":"Install a compatible image viewer (e.g., ImageJ/Fiji) and configure environment variables if necessary for `sitk.Show()` to find it. Alternatively, convert SimpleITK images to NumPy arrays (`sitk.GetArrayFromImage`) and use plotting libraries like Matplotlib or specialized visualization tools.","message":"SimpleITK does not include a built-in image viewer. While `sitk.Show()` can launch an external viewer (like ImageJ/Fiji), users might expect immediate visualization without additional software or configuration.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Consult the ITK v5 Migration Guide for details on underlying ITK changes. Review SimpleITK documentation and examples for compatible patterns.","message":"SimpleITK 2.0 upgraded its underlying ITK dependency to version 5 (ITKv5). This major update brought numerous changes to ITK's internal workings and behaviors, which can indirectly affect SimpleITK users, especially those working with advanced features or custom ITK integrations.","severity":"breaking","affected_versions":"2.0.0 and later"},{"fix":"If encountered, consider testing with SimpleITK 2.0.2 if possible, or preprocess images to ensure orthonormal direction cosines where applicable. The issue often relates to dataset specifics.","message":"Some versions of SimpleITK, particularly when dealing with specific datasets, may encounter issues with non-orthonormal direction cosines, leading to errors like 'ITK only supports orthonormal direction cosines. No orthonormal definition found.' This can be problematic for certain medical imaging data.","severity":"gotcha","affected_versions":"Potentially 2.0.3 and higher, observed in 2.1.x"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}