'tr' Trait undefined in fMRIPrep

Recently, I start to process task fMRI using fmriprep.
Here is the batch file

#!/bin/bash

Data_DIR=/share/ceph/yuzi20group/shared/
BIDS_DIR=/home/kaz220/fmri_prep/visual_task/data
OUT_DIR=/home/kaz220/fmri_prep/visual_task/output
WORK_DIR=/home/kaz220/fmri_prep/visual_task/processing

SINGULARITY_BIN=/share/ceph/hawk/yuzi20_123121/shared

FMRIPREP_OPTS="--omp-nthreads 8 --nthreads 12 --mem_mb 300000 --output-spaces MNI152NLin2009cAsym --dummy-scans 6 --no-submm-recon --fs-no-reconall --skip_bids_validation"
echo $SUBJECT

unset PYTHONPATH
export FS_LICENSE=/home/kaz220/fmri_prep/other_files_need/FreesurferLicense/freesurfer.txt

cmd="singularity run --cleanenv -B ${Data_DIR} $SINGULARITY_BIN/fmriprep-20.2.3.simg ${BIDS_DIR} ${OUT_DIR} participant --participant-label $SUBJECT --fs-license-file ${FS_LICENSE} -w ${WORK_DIR} ${FMRIPREP_OPTS}"

echo Commandline: $cmd
echo $SUBJECT
eval $cmd

It is always used to process the rs-fMRI and works, but when it come to the task fMRI, it raise a error. Anyone could provide some idea?
Here is the error info:

You are using fMRIPrep-20.2.3, and a newer version of fMRIPrep is available: 22.0.2.
Please check out our documentation about how and when to upgrade:
https://fmriprep.readthedocs.io/en/latest/faq.html#upgrading
Process Process-2:
Traceback (most recent call last):
  File "/usr/local/miniconda/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
    self.run()
  File "/usr/local/miniconda/lib/python3.7/multiprocessing/process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/cli/workflow.py", line 82, in build_workflow
    retval["workflow"] = init_fmriprep_wf()
  File "/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/workflows/base.py", line 64, in init_fmriprep_wf
    single_subject_wf = init_single_subject_wf(subject_id)
  File "/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/workflows/base.py", line 304, in init_single_subject_wf
    func_preproc_wf = init_func_preproc_wf(bold_file)
  File "/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/workflows/bold/base.py", line 281, in init_func_preproc_wf
    tr=metadata.get("RepetitionTime")),
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/interfaces/base/core.py", line 641, in __init__
    from_file=from_file, resource_monitor=resource_monitor, **inputs
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/interfaces/base/core.py", line 191, in __init__
    self.inputs.trait_set(**inputs)
  File "/usr/local/miniconda/lib/python3.7/site-packages/traits/has_traits.py", line 1543, in trait_set
    setattr( self, name, value )
  File "/usr/local/miniconda/lib/python3.7/site-packages/traits/trait_handlers.py", line 172, in error
    value )
traits.trait_errors.TraitError: The 'tr' trait of a FunctionalSummaryInputSpec instance must be a float, but a value of None <class 'NoneType'> was specified.

Hello,

A few things:

  1. I recommend updating to the latest version of fMRIPrep. If it is important for you to stay on the LTS version, you can update to 20.2.7. Otherwise, the latest version is 22.0.2.
  2. Are your data BIDS valid? I am guessing the error is from RepetitionTime not being specified in the BOLD JSON files.
  3. It is not recommended to run fs-no-reconall. See here.

Best,
Steven

Thanks for the response. I see the error reason is that I forgot to upload the json file…And the key question for me is that is there any sentence statement specific for the batch file of task fmri preprocessing compared to rs-fmri?

No, fMRIPrep only does minimal preprocessing, so these are steps that should be taken regardless if the fMRI is task or resting-state. What you do with the preprocessed files will of course be different.

Best,
Steven

Thanks for reply. So you mean the batch file for task-fmri or rs-fmri preprocessing should be same? And, with json file, now it raises new problem…

You are using fMRIPrep-20.2.3, and a newer version of fMRIPrep is available: 22.0.2.
Please check out our documentation about how and when to upgrade:
https://fmriprep.readthedocs.io/en/latest/faq.html#upgrading
Process Process-2:
Traceback (most recent call last):
  File "/usr/local/miniconda/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
    self.run()
  File "/usr/local/miniconda/lib/python3.7/multiprocessing/process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/cli/workflow.py", line 82, in build_workflow
    retval["workflow"] = init_fmriprep_wf()
  File "/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/workflows/base.py", line 64, in init_fmriprep_wf
    single_subject_wf = init_single_subject_wf(subject_id)
  File "/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/workflows/base.py", line 304, in init_single_subject_wf
    func_preproc_wf = init_func_preproc_wf(bold_file)
  File "/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/workflows/bold/base.py", line 392, in init_func_preproc_wf
    bold_stc_wf = init_bold_stc_wf(name='bold_stc_wf', metadata=metadata)
  File "/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/workflows/bold/stc.py", line 75, in init_bold_stc_wf
    slice_encoding_direction=metadata.get('SliceEncodingDirection', 'k')),
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/interfaces/afni/base.py", line 214, in __init__
    super(AFNICommand, self).__init__(**inputs)
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/interfaces/base/core.py", line 703, in __init__
    super(CommandLine, self).__init__(**inputs)
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/interfaces/base/core.py", line 191, in __init__
    self.inputs.trait_set(**inputs)
  File "/usr/local/miniconda/lib/python3.7/site-packages/traits/has_traits.py", line 1543, in trait_set
    setattr( self, name, value )
  File "/usr/local/miniconda/lib/python3.7/site-packages/traits/trait_handlers.py", line 172, in error
    value )
traits.trait_errors.TraitError: The 'slice_encoding_direction' trait of a TShiftInputSpec instance must be 'k' or 'k-', but a value of 'i' <class 'str'> was specified.

What that mean? Which parameter in json file is wrong?

Yes (for the most part), but as I said in the first reply, I think upgrading the version and removing the fs-no-reconall flag would be advisable. There are exceptions, for example, what you would use to define a motion outlier might be different in rest vs task.

I am not sure exactly what field this is referring to. Are your JSON files BIDS valid? If not, it might be worth using a tool such as dcm2bids to make BIDS JSON files from your original dicoms.

Best,
Steven

For that part, I have different idea.

<kbd>--fs-no-reconall, --no-freesurfer</kbd>
disable FreeSurfer surface preprocessing. Note : –no-freesurfer is deprecated and will be removed in 1.2. Use –fs-no-reconall instead.

Seen In the fmriprep document, this step just use freesurfer for surface preprocssing. I am not make sure applying freesurfer, how the fmri quality can be improve, since this step always increase lots of the computation time and resource. And apply or not, we compare the time series, FD, function connectivity, we did not see a huge difference.

Do you know any function or software which are used for bids validation of JSON files? Since I only have BIDS structured folder with nii. files. I did not get the original dicom file…

{
	"RepetitionTime": 2, 
	"MultibandAccelerationFactor": 2, 
	"SliceEncodingDirection": "i", 
	"PulseSequenceType": "Multiband gradient echo EPI", 
	"FlipAngle": 80, 
	"TaskName": "vissearch", 
	"SliceTiming": [
	0.0, 
	0.93, 
	1.8575, 
	0.805, 
	1.7325, 
	0.6825, 
	1.61, 
	0.5575,
	1.485,
	0.435,
	1.3625,
	0.31,
	1.2375,
	0.1875,
	1.115,
	0.0625,
	0.99,
	1.92,
	0.8675,
	1.795,
	0.7425,
	1.6725,
	0.62,
	1.5475,
	0.495,
	1.425,
	0.3725,
	1.3,
	0.2475,
	1.1775,
	0.125, 
	1.0525, 
	0.0,
	0.93, 
	1.8575, 
	0.805, 
	1.7325, 
	0.6825, 
	1.61, 
	0.5575, 
	1.485, 
	0.435, 
	1.3625, 
	0.31, 
	1.2375,
	0.1875,
	1.115, 
	0.0625, 
	0.99, 
	1.92, 
	0.8675, 
	1.795, 
	0.7425, 
	1.6725,
	0.62, 
	1.5475,
	0.495, 
	1.425, 
	0.3725, 
	1.3, 
	0.2475, 
	1.1775, 
	0.125,
	1.0525
	], 
	"EchoTime": 0.03, 
	"Manufacturer": "Siemens"
}

This is my JSON file

Freesurfer processing enables boundary based registration which improves spatial normalization. This can be important for analyses where all subjects have to be in a common space. It also enables analyses to be done on the surface of the brain (e.g. CIFTI outputs), which tend to be more specific.

Have you checked this through the BIDS validator? Usually dcm2niix returns several more fields. I don’t think the SliceEncodingDirection field is required for fMRIPrep, so you can try deleting it or setting it to “k” to make the validator happy. I do notice that you do not have a PhaseEncodingDirection; this can make susceptibility distortion correction go wrong. Doing some kind of susceptibility distortion correction (either with fieldmaps or using fmiprep’s fieldmap-less method) is important so the BOLD file can match more closely to the anatomical image.

OK, I might change it in future…

ok, I will try. About the ‘PhaseEncodingDirection’ parameter…I have no way to regenerate the JSON file, since we did not have DICOM. But very appreciated for your help~