{"id":21475,"library":"itk-registration","title":"ITK Registration","description":"The ITK Registration module provides algorithms for image registration, including rigid, affine, deformable (BSpline, Demons), and groupwise methods. This Python package wraps the ITK C++ registration framework. Current version 5.4.6, with a stable release cadence.","status":"active","version":"5.4.6","language":"python","source_language":"en","source_url":"https://github.com/InsightSoftwareConsortium/ITK","tags":["registration","image-processing","medical-imaging"],"install":[{"cmd":"pip install itk-registration","lang":"bash","label":"Default install"}],"dependencies":[{"reason":"Core ITK package is required.","package":"itk","optional":false}],"imports":[{"note":"All modules are accessed via the 'itk' package.","wrong":"import itkRegistration","symbol":"itk","correct":"import itk"}],"quickstart":{"code":"import itk\n\n# Define image types\nPixelType = itk.ctype('float')\nFixedDimension = 2\nMovingDimension = 2\nFixedImageType = itk.Image[PixelType, FixedDimension]\nMovingImageType = itk.Image[PixelType, MovingDimension]\n\n# Read images\nfixed_image = itk.imread('fixed_image.nii', PixelType)\nmoving_image = itk.imread('moving_image.nii', PixelType)\n\n# Set up registration\nRegistrationType = itk.ImageRegistrationMethod[FixedImageType, MovingImageType]\nregistration = RegistrationType.New()\nregistration.SetFixedImage(fixed_image)\nregistration.SetMovingImage(moving_image)\n\n# Set metric (e.g., MeanSquares)\nmetric = itk.MeanSquaresImageToImageMetric[FixedImageType, MovingImageType].New()\nregistration.SetMetric(metric)\n\n# Set transform (e.g., Affine)\ntransform = itk.AffineTransform[itk.D, 2].New()\nregistration.SetInitialTransform(transform)\n\n# Set optimizer\noptimizer = itk.RegularStepGradientDescentOptimizerv4.New()\nregistration.SetOptimizer(optimizer)\n\n# Set interpolator\ninterpolator = itk.LinearInterpolateImageFunction[MovingImageType, itk.D].New()\nregistration.SetInterpolator(interpolator)\n\n# Run registration\nregistration.Update()\n\n# Get result\nresult = registration.GetOutput()\nitk.imwrite(result, 'registered_image.nii')","lang":"python","description":"Basic affine registration of 2D images using MeanSquares metric."},"warnings":[{"fix":"Use PixelType = itk.ctype('float') and itk.imread('image.nii', PixelType).","message":"When using itk.imread, specify the pixel type explicitly with a numeric value or itk.ctype('float'). Default is itk.ctype('float') but be consistent with template types.","severity":"gotcha","affected_versions":">=5.0.0"},{"fix":"Define FixedImageType and MovingImageType with correct dimensions (e.g., itk.Image[itk.F, 3] for 3D float).","message":"ImageRegistrationMethod templates require both FixedImageType and MovingImageType. The types must match the actual image dimensions and pixel type.","severity":"gotcha","affected_versions":">=5.0.0"},{"fix":"Monitor https://discourse.itk.org for migration guides to ITK 6 registration.","message":"The 'itk.ImageRegistrationMethod' (v4 style) is still available but ITK v6 introduces a new registration framework. Users should migrate to the new API once stable.","severity":"deprecated","affected_versions":"5.x"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Define FixedImageType = itk.Image[itk.F, 2] (or itk.D) before creating the registration object.","cause":"Forgot to define the image type before using it in registration templates.","error":"NameError: name 'FixedImageType' is not defined"},{"fix":"Ensure FixedImageType and MovingImageType dimensions and pixel types match your images.","cause":"Mismatch between template types and actual image dimensions or pixel type.","error":"RuntimeError: Exception thrown in SimpleITK ImageRegistrationMethod_New"},{"fix":"Use metric = itk.MeanSquaresImageToImageMetric[FixedImageType, MovingImageType].New() with matching types.","cause":"Incorrect metric type template parameters.","error":"TypeError: in method 'New', argument 1 of type 'itkImageToImageMetricv4...'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}