-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Encountering segmentation fault when running elastix_registration_method()
on both 2D and 3D images
#295
Comments
elastix_registration_method
leads to a segmentation fault when run on 3D images with multi-threading enabledelastix_registration_method()
on 3D images with multi-threading enabled leads to a segmentation fault
Hi, what version of Linux are you using? |
Hi, I'm running it on RHEL8. Have updated my question to reflect this. |
Something happened with our manylinux2014 packages (for older glibc). Are you able to reproduce the issue on a newer Linux that has glibc 2.28 or newer? Perhaps it is easy to do a quick test in a Docker image? |
Thanks for getting back to me, @thewtex ! Unfortunately, I do not have the know-how at present to set up and run a Docker image of a different Linux distribution. However, if you could keep in mind this issue as encountered on RHEL8 and inform me of a solution in due time, that would be much appreciated! |
Hi @thewtex , just an update to this matter: I have opted to perform the image analysis in two dimensions on a per-slice basis, and I surprisingly still run into this segmentation fault issue. Same Linux OS (RHEL8) and ITK-Elastix version (0.20.0). This was the relevant bit of code I was running: import numpy as np
from itk.elxParameterObjectPython import elastixParameterObject
from itk.itkElastixRegistrationMethodPython import elastix_registration_method
from tifffile import TiffFile
def run():
# Load TIFF files
print("Loading TIFF files")
ref_tiff = TiffFile("reference_image.tiff")
mov_tiff = TiffFile("moving_image.tiff")
# These are ImageJ-compatible TIFF images of shape (85, 2048, 2048)
# Load metadata
ref_series = ref_tiff.series[0]
mov_series = mov_tiff.series[0]
num_frames = mov_series.shape[0] # slices in stack
# Set up parameter object
print("Setting up initial registration parameters")
params_init: elastixParameterObject = elastixParameterObject.New()
params_map = params_init.GetDefaultParameterMap(
# Uncomment as needed
"rigid", # Translation + rotation
# "affine", # Translation + rotation + scaling + shearing
numberOfResolutions=1,
)
params_init.AddParameterMap(params_map)
# Align in xy plane
for f in range(num_frames):
ref_img = ref_series.pages[f].asarray()
if invert_reference is True:
ref_img = (2**bit_depth - 1) - ref_img # Order of subtraction is important
mov_img = mov_series.pages[f].asarray()
print(f"Aligning frame {f}")
reg_img, params_reg = elastix_registration_method(
ref_img, mov_img,
parameter_object=params_init,
log_to_console=False,
number_of_threads=1,
)
# Convert to NumPy array
reg_img = np.asarray(reg_img)
# Append to image stack
if f == 0:
reg_stk = [reg_img]
else:
reg_stk = np.append(
reg_stk,
[reg_img],
axis=0,
)
if __name__ == "__main__":
run() The segmentation fault appears to occur randomly at different points when iterating through the stack. It also occurs even when the Would appreciate your comments on this matter when you have the time. Thanks! |
elastix_registration_method()
on 3D images with multi-threading enabled leads to a segmentation faultelastix_registration_method()
on both 2D and 3D images
@tieneupin thanks for the report and script. It may be worth trying itkwasm-elastix. |
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:
I am running this on a Linux RHEL8 system using
python v3.10.14
anditk-elastix v0.20.0
Any insight into what went wrong would be much appreciated!
The text was updated successfully, but these errors were encountered: