{"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":"python","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,"search_vec":"'2.5.3':66 'access':50 'aim':44 'algorithm':42 'analysi':48 'applic':57 'current':63 'educ':54 'especi':58 'extens':41 'high':34 'high-level':33 'imag':19,47,61,70,73 'includ':28 'insight':12 'interfac':9,37 'itk':17,39,76 'languag':27 'level':35 'make':46 'medic':60,72 'multipl':25 'offer':31 'open':7 'open-sourc':6 'procedur':36 'process':71 'program':26 'prototyp':53 'python':29 'rapid':52 'registr':15,20,75 'regular':68 'releas':69 'segment':13,22,74 'simpleitk':1,2 'simplifi':5 'sourc':8 'support':24 'toolkit':16 'various':56 'version':64","created_at":"2026-04-14T01:35:34.731468+00:00","updated_at":"2026-04-17T15:12:02.999492+00:00","problems":[{"fix":"Install SimpleITK using `pip install SimpleITK` or `conda install -c simpleitk simpleitk`.","cause":"The SimpleITK library is not installed in the current Python environment or the environment is not correctly activated.","error":"ModuleNotFoundError: No module named 'simpleitk'"},{"fix":"Convert the NumPy array to a SimpleITK image using `sitk.GetImageFromArray(numpy_array)` before passing it to SimpleITK functions.","cause":"A SimpleITK function was called with a NumPy array when it expected a `simpleitk.Image` object.","error":"TypeError: argument must be simpleitk.Image, not numpy.ndarray"},{"fix":"Convert the SimpleITK image to a NumPy array using `numpy_array = sitk.GetArrayFromImage(sitk_image)` and then access `numpy_array.shape`.","cause":"SimpleITK `Image` objects do not directly expose NumPy array attributes like `shape` or `dtype` without explicit conversion.","error":"AttributeError: 'simpleitk.Image' object has no attribute 'shape'"},{"fix":"Verify the file path, ensure the file exists at the specified location, and confirm it is a valid, readable image file with a supported format.","cause":"The specified image file path is incorrect, the file does not exist, or the file is unreadable, corrupted, or in an unsupported format.","error":"RuntimeError: Exception thrown in SimpleITK ImageFileReader_Execute: ... (File not found/Unable to read)"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"2.5.6","cli_name":"","cli_version":null,"type":"library","homepage":"http://simpleitk.org/","github":"https://github.com/SimpleITK/SimpleITK","docs":"https://simpleitk.readthedocs.io/en/release/","changelog":null,"pypi":"https://pypi.org/project/simpleitk/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["data","ai-ml"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-30","next_check":"2026-07-28","install_tag":null}}