Skip to content

Encountering segmentation fault when running elastix_registration_method() on both 2D and 3D images #295

@tieneupin

Description

@tieneupin

Hi there, I have been introduced to Elastix as a possible solution for some of my image alignment needs, and have been running into the aforementioned segmentation fault issue when I try implementing multi-threading on a 3D job.

Using the example elastix data provided, this is the test code that I've written that runs into that segmentation fault:

import numpy as np

from itk import imread
from itk.itkElastixRegistrationMethodPython import elastix_registration_method
from pathlib import Path
from tifffile import imwrite

# Load images
file_static = Path("/tutorials/elastix-examples/data/CT_3D_lung_fixed.mha")
img_static = np.asarray(imread(file_static))
dtype = str(img_static.dtype)
print(f"Using {file_static.name!r} as the reference image")

file_moving = Path("/tutorials/elastix-examples/data/CT_3D_lung_moving.mha")
img_moving = np.asarray(imread(file_moving))


# Register image while implementing multithreading
img_aligned, params = elastix_registration_method(
    img_static, img_moving,
    number_of_threads=2,
    log_to_console=False,
    )  # <-- CODE FAILS AT THIS STEP

I am running this on a Linux RHEL8 system using python v3.10.14 and itk-elastix v0.20.0

Any insight into what went wrong would be much appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions