Fmriprep antsApplyTransforms error: 'Could not create IO object'

Dear fmriprep experts,

Hi! I’m running fmriprep on the Healthy Brain Network dataset for preprocessing, and keep running into a same problem in a random manner.

I am using the following command:

fmriprep-docker my/input/directory my/output/directory participant --participant-label NDAREU890CYJ --skull-strip-template MNIPediatricAsym:cohort-1 --output-spaces MNIPediatricAsym:cohort-1:res-2 --skip_bids_validation --fs-license-file Desktop/license.txt --nthreads 12 --low-mem --work-dir Desktop/HBN/MRI/temp

and I have added the pediatric template as the output space since I am using a developmental dataset.

fmriprep has been working with most of the subject data pretty well, except for some where it says that it failed and the workflow did not execute cleanly. This is the error description I found in the html :

Traceback (most recent call last):
  File "/opt/conda/lib/python3.8/site-packages/nipype/pipeline/plugins/multiproc.py", line 67, in run_node
    result["result"] = node.run(updatehash=updatehash)
  File "/opt/conda/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 516, in run
    result = self._run_interface(execute=True)
  File "/opt/conda/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 635, in _run_interface
    return self._run_command(execute)
  File "/opt/conda/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 741, in _run_command
    result = self._interface.run(cwd=outdir)
  File "/opt/conda/lib/python3.8/site-packages/nipype/interfaces/base/core.py", line 428, in run
    runtime = self._run_interface(runtime)
  File "/opt/conda/lib/python3.8/site-packages/niworkflows/interfaces/fixes.py", line 64, in _run_interface
    runtime = super(FixHeaderApplyTransforms, self)._run_interface(
  File "/opt/conda/lib/python3.8/site-packages/nipype/interfaces/base/core.py", line 822, in _run_interface
    self.raise_exception(runtime)
  File "/opt/conda/lib/python3.8/site-packages/nipype/interfaces/base/core.py", line 749, in raise_exception
    raise RuntimeError(
RuntimeError: Command:
antsApplyTransforms --default-value 0 --float 0 --input
/scratch/fmriprep_wf/single_subject_NDAREU890CYJ_wf/anat_preproc_wf/surface_recon_wf/segs_to_native_aparc_aseg/resample/
 --interpolation MultiLabel --output seg_trans.nii.gz --reference-image /home/fmriprep/.cache/templateflow/tpl-
MNIPediatricAsym/cohort-1/tpl-MNIPediatricAsym_cohort-1_res-2_T1w.nii.gz --transform
/scratch/fmriprep_wf/single_subject_NDAREU890CYJ_wf/anat_preproc_wf/anat_norm_wf/_template_MNIPediatricAsymcohort-
1/registration/ants_t1_to_mniComposite.h5
Standard output:
Standard error:
Exception caught during reference file reading
itk::ImageFileReaderException (0x3d74740)
Location: "unknown"
File: /src/ants/build/staging/include/ITK-5.1/itkImageFileReader.hxx
Line: 133
Description:  Could not create IO object for reading file /home/fmriprep/.cache/templateflow/tpl-
MNIPediatricAsym/cohort-1/tpl-MNIPediatricAsym_cohort-1_res-2_T1w.nii.gz
  Tried to create one of the following:
    BMPImageIO
    BioRadImageIO
    Bruker2dseqImageIO
    GDCMImageIO
    GE4ImageIO
    GE5ImageIO
    GiplImageIO
    HDF5ImageIO
    JPEGImageIO
    JPEG2000ImageIO
    LSMImageIO
    MGHImageIO
    MINCImageIO
    MRCImageIO
    MetaImageIO
    NiftiImageIO
    NrrdImageIO
    PNGImageIO
    StimulateImageIO
    TIFFImageIO
    VTKImageIO
  You probably failed to set a file suffix, or
    set the suffix to an unsupported type.
 file /home/fmriprep/.cache/templateflow/tpl-MNIPediatricAsym/cohort-1/tpl-MNIPediatricAsym_cohort-1_res-2_T1w.nii.gz
Segmentation fault
Return code: 139

I am suspecting that it’s an issue about ANTS using a non-default template (according to https://neurostars.org/t/moving-images-from-mni-to-bold-epi-native-space/ and https://neurostars.org/t/fmriprep-potentially-antsapplytransforms-and-hd5-issue/ ),
but what is puzzling is that when I remove all output files and rerun fmriprep on the same data with the same commands, it sometimes works.
So, I am growing suspicions that it might be a memory issue since I have been encountering some lately.

Would anyone have any suggestions about the problem? It would be a big help.
Thank you in advance!

Sujin.

Hi,

As a check, have you tried rerunning these subjects with a a clean working directory? Also what version of fMRIprep are you using?

Best,
Steven

Thanks for asking!

Yes, I did rerun with a clean working directory and my fmriprep version is 21.0.2 :slight_smile:

Hi,

I’m getting the same error from ITK consistently - file reader exception for a .nii.gz - and could not find any other threads with this exact problem. I’m running fmriprep 24.0.0 in a singularity image on a Linux cluster. I tried clearing my work directory, and allocating additional memory as well as wall time to the job. The command as well as error message are as follows.

Command:

singularity run  \
                --cleanenv  \
		-B {TEMPLATEFLOW_HOME}:/templateflow \
                -B {FMRIPREP_RESOURCES_PATH}:/resources \
                -B {BIDS_DIR}:/data \
                -B {WORK_DIR}:/work \
                -B {OUTPUT_DIR}:/output \
        {FMRIPREP_RESOURCES_PATH}/fmriprep-24.0.0.simg /data /output \
        participant --participant_label 01\
        -w /work \
        --nprocs 8 \
        --write-graph \
        --fs-license-file /resources/license.txt \
        --skip_bids_validation \
        --ignore slicetiming \
	--notrack \
        --fs-no-reconall \
Stderr:
	Exception caught during reference file reading 

	itk::ImageFileReaderException (0x559b1a0d2a60)
	Location: "unknown" 
	File: /opt/conda/envs/fmriprep/include/ITK-5.3/itkImageFileReader.hxx
	Line: 132
	Description:  Could not create IO object for reading file /work/fmriprep_24_0_wf/sub_01_wf/bold_task_rest_wf/bold_fit_wf/hmc_boldref_wf/gen_avg/sub-01_task-rest_bold_valid_average.nii.gz
	  Tried to create one of the following:
	    BMPImageIO
	    BioRadImageIO
	    Bruker2dseqImageIO
	    GDCMImageIO
	    GE4ImageIO
	    GE5ImageIO
	    GiplImageIO
	    HDF5ImageIO
	    JPEGImageIO
	    JPEG2000ImageIO
	    LSMImageIO
	    MGHImageIO
	    MINCImageIO
	    MRCImageIO
	    MetaImageIO
	    NiftiImageIO
	    NrrdImageIO
	    PNGImageIO
	    StimulateImageIO
	    TIFFImageIO
	    VTKImageIO
	  You probably failed to set a file suffix, or
	    set the suffix to an unsupported type.


	 file /work/fmriprep_24_0_wf/sub_01_wf/bold_task_rest_wf/bold_fit_wf/hmc_boldref_wf/gen_avg/sub-01_task-rest_bold_valid_average.nii.gz

I am using the --skip_bids_validation flag in the command since I get the following error during bids validation of the dataset:

1: [ERR] We were unable to parse header data from this NIfTI file. Please ensure it is not corrupted or mislabeled. (code: 26 - NIFTI_HEADER_UNREADABLE)
		./sub-01/func/sub-01_task-rest_bold.nii.gz

However, I am able to slice and plot the data accurately using nibabel and have not run into readability issues before this. Let me know if you have any other ideas about what else could be causing this error. Possibly upgrading ITK or changing my version of fmriprep could help?

Much appreciated,

William