nipy / nipype

Workflows and interfaces for neuroimaging packages
https://nipype.readthedocs.org/en/latest/
Other
743 stars 524 forks source link

Segmentation Fault using fsl.ExtractROI() #3410

Open butellyn opened 2 years ago

butellyn commented 2 years ago

Summary

I am post-processing fMRI data that has already been run through fMRIPrep. I am trying to use fsl.ExtractROI(), but every time I run it, a segmentation fault occurs, and my stack is unlimited (i.e., ulimit -s returns "unlimited"). Do you know what might be causing this error?

Actual behavior

Segmentation fault occurs when using fsl.ExtractROI().

Expected behavior

I want to move the first X volumes from an fMRI time series.

Script/Workflow details

import os
import nipype.interfaces.fsl as fsl # importing FSL interface functions
from nipype import Node, Workflow 

dataDir = '/path/to/project/'
outDir = os.path.join(dataDir, 'amygconn')

nDelfMRI = 10

# directory where preprocessed fMRI data is located
baseDir = os.path.join(dataDir, 'fmriprep')
subjDir = os.path.join(baseDir, 'sub-1')
sesDir = os.path.join(subjDir, 'ses-1/func')

# location of the pre-processed fMRI & mask
fList = os.listdir(sesDir)
imagefMRI = [x for x in fList if ('preproc_bold.nii.gz' in x)][0]
imageMask = [x for x in fList if ('brain_mask.nii.gz' in x)][0]

filefMRI = os.path.join(sesDir, imagefMRI)
fileMask = os.path.join(sesDir, imageMask)

# skip dummy scans
extract = Node(fsl.ExtractROI(in_file=filefMRI, t_min=nDelfMRI, t_size=-1),
    name='extract')

https://github.com/NU-ACNLab/mwmh/blob/main/scripts/process/postprocess.py

Platform details:

{'commit_hash': 'b385720',
 'commit_source': 'installation',
 'networkx_version': '2.6.3',
 'nibabel_version': '3.2.1',
 'nipype_version': '1.7.0',
 'numpy_version': '1.19.0',
 'pkg_path': '/home/erb9722/.local/lib/python3.8/site-packages/nipype',
 'scipy_version': '1.5.1',
 'sys_executable': '/software/python/3.8.4/bin/python3',
 'sys_platform': 'linux',
 'sys_version': '3.8.4 (default, Jul 18 2020, 06:46:30) \n'
                '[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]',
 'traits_version': '6.3.2'}

Execution environment

effigies commented 2 years ago

Is the segfault in Python or fslroi?

butellyn commented 2 years ago

In Python

Screen Shot 2021-11-22 at 1 43 33 PM
effigies commented 2 years ago

Just to verify, you then are back in your Bash (or other) shell, not the Python prompt, correct? It's hard to tell from the screenshot whether Python or fslroi is segfaulting.

butellyn commented 2 years ago

Yes, Python exits at this point into the shell.

effigies commented 2 years ago

Hmm. I can't see anything ExtractROI is doing that other interfaces don't. Could you try enabling the faulthandler in your script and seeing what you get?

butellyn commented 2 years ago

Getting more detailed error output now

Screen Shot 2021-11-22 at 2 49 49 PM
effigies commented 2 years ago

Thanks, that's very helpful. So the erroring line is:

https://github.com/nipy/nipype/blob/b38572030f3d968c945675efaccd053d123f158b/nipype/utils/subprocess.py#L124

Unsure why this might happen; can't quickly find a recent BusError report related to select. If you have the patience, you could try reporting to Python itself and see if they can track it down.

Fortunately, this line is only called if the terminal output is "stream", so you may be able to work around the problem by setting terminal_output="none" when you initialize ExtractROI().