Overview

ImFusion Spine Plugin Python Bindings

Core Functionality Areas

Spine Data Structures:

  • SpineData: Container for complete spine with multiple vertebrae

  • OrientedVertebra: Individual vertebra representation with keypoints, planes, and splines

Spine Algorithms:

Example Usage

Basic spine analysis workflow:

>>> import imfusion.spine as spine
>>> import imfusion
>>> # Load CT image
>>> ct_image = imfusion.open("spine_ct.nii")
>>> # Create spine analysis algorithm
>>> alg = spine.SpineBaseAlgorithm(ct_image)
>>> # Set spine bounds automatically
>>> alg.set_bounds()
>>> # Localize and classify vertebrae
>>> status = alg.localize()
>>> # Get spine data with all vertebrae
>>> spine_data = alg.take_spine_data()
>>> print(f"Found {spine_data.num_vertebrae()} vertebrae")
>>> # Access individual vertebrae
>>> l1_vertebra = spine_data.vertebra("L1")
>>> position = l1_vertebra.calculate_position()
>>> # Segment specific vertebra
>>> l1_segmentation = alg.segment("L1")

2D X-ray analysis:

>>> # Load X-ray image
>>> xray = imfusion.open("spine_xray.dcm")
>>> # Create 2D localization algorithm
>>> alg_2d = spine.SpineLocalization2DAlgorithm(xray)
>>> # Run detection
>>> alg_2d.compute()

Poly-rigid deformation example:

>>> # Load CT volume and spine data
>>> ct_volume = imfusion.open("spine_ct.nii")
>>> spine_data = imfusion.open("spine_data.imf")  # :class:`~imfusion.anatomy.AnatomicalStructureCollection`
>>> # Create poly-rigid deformation algorithm
>>> deform_alg = spine.SpinePolyRigidDeformation(ct_volume, spine_data)
>>> # Configure deformation parameters
>>> deform_alg.chamfer_distance = True
>>> deform_alg.mode = spine.PolyRigidDeformationMode.BACKWARD
>>> deform_alg.inversion_steps = 50
>>> # Compute the deformation
>>> deform_alg.compute()

For detailed documentation of specific classes and functions, use Python’s built-in help() function or access the docstrings directly.

Note: This module requires the ImFusion Spine plugin to be properly installed.