Hello,
I’m trying to run a rigid + affine registration of around 800 images (CT scans), but I keep getting a Segmentation Fault error, when run using Python3 on Ubuntu.
The relevant part of the code is (I think):
for id_, item in tqdm(data_index.iterrows()):
try:
image = sitk.ReadImage(item[image_column])
print('Sucessfully read image ' + item[image_column])
except RuntimeError:
print(f'Could not read image: {id_:s}')
continue
try:
transform, iterations_rig, final_metric_rig, iterations_aff, final_metric_aff, image_resampled_aff = self.register_image_to_atlas(image)
except RuntimeError or TypeError:
print(f'Could not register image: {id_:s}')
continue
*defined transform_path*
sitk.WriteTransform(transform, transform_path)
*defined image_resampled_path*
sitk.WriteImage(image_resampled_aff, image_resampled_path)
“data_index” is a csv that contains all the paths to the images.
The function self.register_image_to_atlas(image) accepts the CT image path and performs the rigid and affine registration using the sitk.ImageRegistrationMethod() class. At the end, every output from this function is written to the data_index csv file.
I already tried increasing the stack allocated for this process with ulimit -s, but it didn’t work. I also tried running python under gdb, and got the following output, which as a beginner I don’t quite know how to interpret and solve:
Thread 123 "python" received signal SIGSEGV, Segmentation fault.
(gdb) backtrace
#0 0x00007fffec351bd3 in ?? () from path/my-project-env/lib/python3.8/site-packages/SimpleITK/_SimpleITK.cpython-38-x86_64-linux-gnu.so
#1 0x00007fffec346d00 in ?? () from path/my-project-env/lib/python3.8/site-packages/SimpleITK/_SimpleITK.cpython-38-x86_64-linux-gnu.so
#2 0x00007fffec3be611 in ?? () from path/my-project-env/lib/python3.8/site-packages/SimpleITK/_SimpleITK.cpython-38-x86_64-linux-gnu.so
#3 0x00007fffecd86490 in ?? () from path/my-project-env/lib/python3.8/site-packages/SimpleITK/_SimpleITK.cpython-38-x86_64-linux-gnu.so
#4 0x00007fffecd49f63 in ?? () from path/my-project-env/lib/python3.8/site-packages/SimpleITK/_SimpleITK.cpython-38-x86_64-linux-gnu.so
#5 0x00007fffecca24ca in ?? () from path/my-project-env/lib/python3.8/site-packages/SimpleITK/_SimpleITK.cpython-38-x86_64-linux-gnu.so
#6 0x00007ffff36d1ca4 in std::_Function_handler<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> (), std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<void*>, std::__future_base::_Result_base::_Deleter>, std::__future_base::_Task_state<std::_Bind<void* (*(itk::PoolMultiThreader::ThreadPoolInfoStruct*))(void*)>, std::allocator<int>, void* ()>::_M_run()::{lambda()#1}, void*> >::_M_invoke(std::_Any_data const&) ()
from /vol/medic02/users/cpicarr1/my-project-env/lib/python3.8/site-packages/SimpleITK/_SimpleITK.cpython-38-x86_64-linux-gnu.so
#7 0x00007ffff36d1d6b in ?? () from path/my-project-env/lib/python3.8/site-packages/SimpleITK/_SimpleITK.cpython-38-x86_64-linux-gnu.so
#8 0x00007ffff7d9147f in __pthread_once_slow (once_control=0x20f23d8, init_routine=0x7fffe8af0b80 <__once_proxy>) at pthread_once.c:116
#9 0x00007ffff36d2012 in ?? () from path/my-project-env/lib/python3.8/site-packages/SimpleITK/_SimpleITK.cpython-38-x86_64-linux-gnu.so
#10 0x00007ffff36d2e8a in ?? () from path/my-project-env/lib/python3.8/site-packages/SimpleITK/_SimpleITK.cpython-38-x86_64-linux-gnu.so
#11 0x00007ffff39ac3df in ?? () from path/my-project-env/lib/python3.8/site-packages/SimpleITK/_SimpleITK.cpython-38-x86_64-linux-gnu.so
#12 0x00007ffff7d88609 in start_thread (arg=<optimised out>) at pthread_create.c:477
#13 0x00007ffff7ec4293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
If anyone has any input on how this problem could be solved, I would be really thankful!