ITK error in fmriprep pipeline

Dear experts,

I am processing multi-echo fmri data in fmriprep 1.5.4. Two of my subject returned this error.

[Node] Error on “fmriprep_wf.single_subject_023_wf.func_preproc_task_study_run_01_echo_1_wf.bold_bold_trans_wf.bold_transform” (/localscratch/hyang336.44163445.0/fmriprep_wf/single_subject_023_wf/func_preproc_task_study_run_01_echo_1_wf/bold_bold_trans_wf/bold_file…project…6050199…switt4…switt4-bids…Kohler…PPC_MD…bids…sub-023…func…sub-023_task-study_run-01_echo-3_bold.nii.gz/bold_transform)
210203-18:01:45,449 nipype.workflow ERROR:
Node bold_transform.a2 failed to run on host gra1271.
210203-18:01:45,556 nipype.workflow ERROR:
Saving crash info to /scratch/hyang336/working_dir/PPC_MD/fmriprep_1.5.4_corrected/fmriprep/sub-023/log/20210203-172014_2e1efc22-4e13-4ac3-b7c5-fdc0e4956f40/crash-20210203-180145-hyang336-bold_transform.a2-c757fa92-0f1d-4f94-bf59-48a9ca1d97f8.txt
Traceback (most recent call last):
File “/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/plugins/legacymultiproc.py”, line 69, in run_node
result[‘result’] = node.run(updatehash=updatehash)
File “/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py”, line 479, in run
result = self._run_interface(execute=True)
File “/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py”, line 585, in _run_interface
return self._run_command(execute)
File “/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py”, line 678, in _run_command
result = self._interface.run(cwd=outdir)
File “/usr/local/miniconda/lib/python3.7/site-packages/nipype/interfaces/base/core.py”, line 382, in run
runtime = self._run_interface(runtime)
File “/usr/local/miniconda/lib/python3.7/site-packages/niworkflows/interfaces/itk.py”, line 113, in _run_interface
xfms_list = _arrange_xfms(transforms, num_files, tmp_folder)
File “/usr/local/miniconda/lib/python3.7/site-packages/niworkflows/interfaces/itk.py”, line 294, in _arrange_xfms
’ the number of input image files (%d).’ % (nxforms, num_files))
RuntimeError: Number of transforms (118) found in the ITK file does not match the number of input image files (117).

The two numbers on the last line differed between the two subjects, but the difference between the two numbers was always 1.

Does anyone know a cause of this?

Thanks,
HY

Does this problem persist in more recent versions of fMRIPrep? If you try the latest 1.5.x, you should be able to re-use your working directory.

Problem is, I am running it on a cluster with a singularity image built by someone else. For 1.5.x it only has 1.5.4. I can try running it on 20.0.5, 20.1.1, or 20.2.0 though.

I would recommend 20.2.0, then, since that is our long-term support series. I strongly suspect this was resolved since 1.5.4, which is over a year old, but you will want to run the same version of fMRIPrep on all subjects in a study to ensure that the data are comparable.

The error showed up in 20.2.0 as well.

[Node] Error on “fmriprep_wf.single_subject_015_wf.func_preproc_task_test_run_01_echo_1_wf.bold_bold_trans_wf.bold_transform” (/localscratch/hyang336.44219326.0/fmriprep_wf/single_subject_015_wf/func_preproc_task_test_run_01_echo_1_wf/bold_bold_trans_wf/bold_file…project…6050199…switt4…switt4-bids…Kohler…PPC_MD…bids…sub-015…func…sub-015_task-test_run-01_echo-3_bold.nii.gz/bold_transform)
210204-23:10:46,384 nipype.workflow ERROR:
Node bold_transform.a2 failed to run on host gra1223.
210204-23:10:46,397 nipype.workflow ERROR:
Saving crash info to /scratch/hyang336/working_dir/PPC_MD/fmriprep_20.2.0/fmriprep/sub-015/log/20210204-210600_af6a6ece-d8d0-4183-b275-011727587858/crash-20210204-231046-hyang336-bold_transform.a2-0bd4327c-928f-4d5d-b5b1-46a51412ce71.txt
Traceback (most recent call last):
File “/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/plugins/legacymultiproc.py”, line 67, in run_node
result[“result”] = node.run(updatehash=updatehash)
File “/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py”, line 516, in run
result = self._run_interface(execute=True)
File “/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py”, line 635, in _run_interface
return self._run_command(execute)
File “/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py”, line 741, in _run_command
result = self._interface.run(cwd=outdir)
File “/usr/local/miniconda/lib/python3.7/site-packages/nipype/interfaces/base/core.py”, line 419, in run
runtime = self._run_interface(runtime)
File “/usr/local/miniconda/lib/python3.7/site-packages/niworkflows/interfaces/itk.py”, line 147, in _run_interface
xfms_list = _arrange_xfms(transforms, num_files, tmp_folder)
File “/usr/local/miniconda/lib/python3.7/site-packages/niworkflows/interfaces/itk.py”, line 288, in _arrange_xfms
" the number of input image files (%d)." % (nxforms, num_files)
RuntimeError: Number of transforms (144) found in the ITK file does not match the number of input image files (143).

Are all subjects multiecho? Or just these two?

All subjects were multiecho with the same scanning protocol.

Any updates or insights on what might caused this problem?

If I had to guess, there’s an issue where non-steady-state volumes are being dropped unexpectedly. Can you provide your full command? (Apologies about the delayed responses.)

bidsBatch -s 023 -j Long fmriprep_1.5.4 ~/projects/ctb-akhanf/switt4/switt4-bids/Kohler/PPC_MD/bids ~/scratch/working_dir/PPC_MD/fmriprep_1.5.4_corrected/ participant --output-spaces T1w MNI152NLin2009cAsym

this command was run on Compute Canada cluster so it contains some extra stuff there to handle job submission.

Hmm. This is quite surprising. I expected there either to be a --dummy-scans or --use-aroma flag in there. Would it be possible for you to share a subject where this happens?

It will be a large zip, what is your preferred way of sharing?

The simplest thing would be to put on OpenNeuro and keep it private: https://openneuro.org/. You can share access with me; my username is the same as on this forum, but @ gmail.com.

Otherwise, I’m happy to download from any place that you can make it accessible.

Do you need the raw BIDS dataset or the post-fmriprep version?

Raw, please, so we can try to reproduce the error in fMRIPrep.

Do you need any of the .json or .tsv files in the BIDS directory other than the participants folders?

Yes, it would be good to have the TSV and JSON files.

Just shared with you through Google Drive, let me know if the files are complete. Also these are not defaced so please delete it afterwards.

Just a note that I have been able to reproduce the issue. Looking into it as time permits.

@H_Y I’ve found the issue with your data:

$ nib-ls */func/*.nii.gz
sub-015/func/sub-015_task-test_run-01_echo-1_bold.nii.gz    uint16 [100, 100,  66, 144] 2.00x2.00x2.00x2.50   sform
sub-015/func/sub-015_task-test_run-01_echo-2_bold.nii.gz    uint16 [100, 100,  66, 144] 2.00x2.00x2.00x2.50   sform
sub-015/func/sub-015_task-test_run-01_echo-3_bold.nii.gz    uint16 [100, 100,  66, 143] 2.00x2.00x2.00x2.50   sform
sub-023/func/sub-023_task-study_run-01_echo-1_bold.nii.gz   uint16 [100, 100,  66, 118] 2.00x2.00x2.00x2.50   sform
sub-023/func/sub-023_task-study_run-01_echo-2_bold.nii.gz   uint16 [100, 100,  66, 118] 2.00x2.00x2.00x2.50   sform
sub-023/func/sub-023_task-study_run-01_echo-3_bold.nii.gz   uint16 [100, 100,  66, 117] 2.00x2.00x2.00x2.50   sform

Note that the third echo is one volume shorter than the other two, in both cases. When fMRIPrep estimates the motion on the first echo, it gets 144/118 transformations. It is unclear how to apply these to a third echo series that’s one volume shorter.