Slice timing correction failed fmriprep

Hi, I have been running a bunch of subjects using fmriprep (fmriprep/23.1.4) While most of my subjects run fine, slice timing error keeps occuring in some subject even I tried to rerun it in a fresh work directory. I’ve also checked my slice timings and they all seemed to be correct to me. Acquisition times are kind of the same across all individuals. No specific bad motions and artifacts have been spotted. So I am running out of ideas of what it could cause this. I’ve attached my slice timing crash report here.


Node: fmriprep_23_1_wf.single_subject_M085678_wf.func_preproc_ses_A5512_task_kamin_acq_AP_wf.bold_stc_wf.slice_timing_correction
Working directory: /vast/palmer/scratch/corlett/sf674/predcode/mprc/20/work/fmriprep_23_1_wf/single_subject_M085678_wf/func_preproc_ses_A5512_task_kamin_acq_AP_wf/bold_stc_wf/slice_timing_correction

Node inputs:

args = <undefined>
environ = {}
ignore = <undefined>
in_file = <undefined>
interp = <undefined>
num_threads = 1
out_file = <undefined>
outputtype = NIFTI_GZ
rlt = <undefined>
rltplus = <undefined>
slice_encoding_direction = k
slice_timing = [0.0, 0.43, 0.8575, 0.3075, 0.735, 0.185, 0.6125, 0.0625, 0.49, 0.9175, 0.3675, 0.795, 0.245, 0.6725, 0.1225, 0.5525, 0.0, 0.43, 0.8575, 0.3075, 0.735, 0.185, 0.6125, 0.0625, 0.49, 0.9175, 0.3675, 0.795, 0.245, 0.6725, 0.1225, 0.5525, 0.0, 0.43, 0.8575, 0.3075, 0.735, 0.185, 0.6125, 0.0625, 0.49, 0.9175, 0.3675, 0.795, 0.245, 0.6725, 0.1225, 0.5525, 0.0, 0.43, 0.8575, 0.3075, 0.735, 0.185, 0.6125, 0.0625, 0.49, 0.9175, 0.3675, 0.795, 0.245, 0.6725, 0.1225, 0.5525, 0.0, 0.43, 0.8575, 0.3075, 0.735, 0.185, 0.6125, 0.0625, 0.49, 0.9175, 0.3675, 0.795, 0.245, 0.6725, 0.1225, 0.5525]
tpattern = <undefined>
tr = 1s
tslice = <undefined>
tzero = 0.459

Traceback (most recent call last):
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/pipeline/plugins/multiproc.py", line 67, in run_node
    result["result"] = node.run(updatehash=updatehash)
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/pipeline/engine/nodes.py", line 527, in run
    result = self._run_interface(execute=True)
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/pipeline/engine/nodes.py", line 645, in _run_interface
    return self._run_command(execute)
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/pipeline/engine/nodes.py", line 771, in _run_command
    raise NodeExecutionError(msg)
nipype.pipeline.engine.nodes.NodeExecutionError: Exception raised while executing Node slice_timing_correction.

Cmdline:
	3dTshift -ignore 1 -prefix sub-M085678_ses-A5512_task-kamin_acq_AP_bold_tshift.nii.gz -tpattern @slice_timing.1D -TR 1s -tzero 0.459 /vast/palmer/scratch/corlett/sf674/predcode/mprc/20/work/fmriprep_23_1_wf/single_subject_M085678_wf/func_preproc_ses_A5512_task_kamin_acq_AP_wf/bold_stc_wf/slice_timing_correction/sub-M085678_ses-A5512_task-kamin_acq_AP_bold.nii.gz
Stdout:

Stderr:
	++ 3dTshift: AFNI version=AFNI_23.2.02 (Jul 28 2023) [64-bit]
	** AFNI converts NIFTI_datatype=512 (UINT16) in file /vast/palmer/scratch/corlett/sf674/predcode/mprc/20/work/fmriprep_23_1_wf/single_subject_M085678_wf/func_preproc_ses_A5512_task_kamin_acq_AP_wf/bold_stc_wf/slice_timing_correction/sub-M085678_ses-A5512_task-kamin_acq_AP_bold.nii.gz to FLOAT32
	     Warnings of this type will be muted for this session.
	     Set AFNI_NIFTI_TYPE_WARN to YES to see them all, NO to see none.
	e[7m*+ WARNING:e[0m   If you are performing spatial transformations on an oblique dset,
	  such as /vast/palmer/scratch/corlett/sf674/predcode/mprc/20/work/fmriprep_23_1_wf/single_subject_M085678_wf/func_preproc_ses_A5512_task_kamin_acq_AP_wf/bold_stc_wf/slice_timing_correction/sub-M085678_ses-A5512_task-kamin_acq_AP_bold.nii.gz,
	  or viewing/combining it with volumes of differing obliquity,
	  you should consider running: 
	     3dWarp -deoblique 
	  on this and  other oblique datasets in the same session.
	 See 3dWarp -help for details.
	++ Oblique dataset:/vast/palmer/scratch/corlett/sf674/predcode/mprc/20/work/fmriprep_23_1_wf/single_subject_M085678_wf/func_preproc_ses_A5512_task_kamin_acq_AP_wf/bold_stc_wf/slice_timing_correction/sub-M085678_ses-A5512_task-kamin_acq_AP_bold.nii.gz is 19.985428 degrees from plumb.
	Killed
Traceback:
	Traceback (most recent call last):
	  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/interfaces/base/core.py", line 453, in aggregate_outputs
	    setattr(outputs, key, val)
	  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/interfaces/base/traits_extension.py", line 330, in validate
	    value = super(File, self).validate(objekt, name, value, return_pathlike=True)
	  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/interfaces/base/traits_extension.py", line 135, in validate
	    self.error(objekt, name, str(value))
	  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/traits/base_trait_handler.py", line 74, in error
	    raise TraitError(
	traits.trait_errors.TraitError: The 'out_file' trait of a TShiftOutputSpec instance must be a pathlike object or string representing an existing file, but a value of '/vast/palmer/scratch/corlett/sf674/predcode/mprc/20/work/fmriprep_23_1_wf/single_subject_M085678_wf/func_preproc_ses_A5512_task_kamin_acq_AP_wf/bold_stc_wf/slice_timing_correction/sub-M085678_ses-A5512_task-kamin_acq_AP_bold_tshift.nii.gz' <class 'str'> was specified.

	During handling of the above exception, another exception occurred:

	Traceback (most recent call last):
	  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/interfaces/base/core.py", line 400, in run
	    outputs = self.aggregate_outputs(runtime)
	  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/interfaces/base/core.py", line 460, in aggregate_outputs
	    raise FileNotFoundError(msg)
	FileNotFoundError: No such file or directory '/vast/palmer/scratch/corlett/sf674/predcode/mprc/20/work/fmriprep_23_1_wf/single_subject_M085678_wf/func_preproc_ses_A5512_task_kamin_acq_AP_wf/bold_stc_wf/slice_timing_correction/sub-M085678_ses-A5512_task-kamin_acq_AP_bold_tshift.nii.gz' for output 'out_file' of a TShift interface

Many thanks,
Sarah

Hi @SarahFan, and welcome to neurostars!

Please share the command you used to run fmriprep and the BIDS validation output.

Best,
Steven

Hi Steven,

Thanks for your fast reply. Here is the command I use to run fmriprep on the cluster

fmriprep -v /home/sf674/palmer_scratch/predcode/yale/0/sub-M042300 /home/sf674/palmer_scratch/predcode/yale/0/outputs participant -w /home/sf674/palmer_scratch/predcode/yale/0/work --fs-license-file $EBROOTFMRIPREP/license.txt --skip_bids_validation --nproc ${SLURM_CPUS_PER_TASK}

We actually had to flag the skip_bis validation (as shown above) to have fmriprep running. While our data structure matches the bids format, it somehow didn’t like it. I am pasting below my data structure for this subject .



├── anat
│   ├── sub-M085678_ses-A5512_T1w.json
│   └── sub-M085678_ses-A5512_T1w.nii.gz
├── fmap
│   ├── sub-M085678_ses-A5512_fieldmap_AP.json
│   ├── sub-M085678_ses-A5512_fieldmap_AP.nii.gz
│   ├── sub-M085678_ses-A5512_fieldmap_PA.json
│   └── sub-M085678_ses-A5512_fieldmap_PA.nii.gz
└── func
    ├── sub-M085678_ses-A5512_task-kamin_acq_AP_bold.json
    ├── sub-M085678_ses-A5512_task-kamin_acq_AP_bold.nii.gz
    ├── sub-M085678_ses-A5512_task-kamin_acq_AP_events.tsv
    ├── sub-M085678_ses-A5512_task-kamin_acq_PA_bold.json
    ├── sub-M085678_ses-A5512_task-kamin_acq_PA_bold.nii.gz
    └── sub-M085678_ses-A5512_task-kamin_acq_PA_events.tsv

Hi @SarahFan,

  1. it looks like you are running fmriprep via bare-metal installation (I.e. python). You should use a container (Singulairty/Apprainer or Docker) instead to make sure your software dependencies are correct.

  2. Your data are not BIDS valid. Make the following changes

Replace all acq_PA/AP with dir-AP/PA, and put that dir label in your field maps too.

In your fieldmaps, remove _fieldmap, and the suffix should be epi.nii.gz/json

Rerun without skipping bids validation after making these changes. If you have questions you can refer to the BIDS specification here: Magnetic Resonance Imaging - Brain Imaging Data Structure v1.9.0

Also it looks like you are running fmriprep on a subject folder, when it should be run on the root BIDS directory (one level above the subject folders).

Best,
Steven

Thanks so much Steven for this awesome troubleshoot. I will rename these files and try again and let you know how it goes.

However, I remain curious of why most of my subjects ran fine without BIDS valid data structures while only a few individuals have obstacles?

I have not been running it on a subject folder. It has always been on the root BIDS directory. Sorry for the confusing appearance.

Hi @SarahFan,

It may have recognized the fmri files okay but the fieldmaps it would definitely not find (but not error out since they are not necessary for fmriprep, but recommended). You should also make sure you have the IntendedFor or B0FieldSource/B0Identifier fields filled out in your fmap json files so they can be used to correct your data accordingly.

Best,
Steven

Got you! Thanks for the tips. Happy holidays!

No problem, you too!