KeyError: 'RepetitionTime' in version 1.3.0.post2 and fieldmap data are not recognized by fMRIprep

Hi all,
I am testing using fMRIprep to preprocess my fMRI data. In my first try, everything looks good. But today, when I ran them again, I met the problem related to RepetitionTime. The key ‘RepetitionTime’ is present in the .json file. I searched this question, and found some people have the same problem in older version. I followed suggestions in their post but still cannot figure it out. Here is my traceback information:

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/run.py”, line 751, in build_workflow
ignore_aroma_err=opts.ignore_aroma_denoising_errors,
File “/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/workflows/base.py”, line 218, in init_fmriprep_wf
ignore_aroma_err=ignore_aroma_err,
File “/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/workflows/base.py”, line 516, in init_single_subject_wf
num_bold=len(subject_data[‘bold’]))
File “/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/workflows/bold/base.py”, line 683, in init_func_preproc_wf
name=‘carpetplot_wf’)
File “/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/workflows/bold/confounds.py”, line 370, in init_carpetplot_wf
tr=metadata[‘RepetitionTime’],
KeyError: ‘RepetitionTime’
fMRIPrep: Please report errors to https://github.com/poldracklab/fmriprep/issues

My data passed BIDS validator:
This dataset appears to be BIDS compatible.
Summary: 800 Files, 2.46GB, 1 - Subject, 1 - Session
Available Tasks: fMRI_test
Available Modalities: T1w, bold, events, fieldmap

I also tried:
find $BIDS_DIR -name ‘_bold.’
find $BIDS_DIR -name ‘*_bold.json’ -exec grep RepetitionTime “{}” +
and can get related information:

./func/sub-01_task-test_run-01_bold.json
./func/sub-01_task-test_run-02_bold.nii.gz
./func/sub-01_task-test_run-02_bold.json
./func/sub-01_task-test_run-01_bold.nii.gz

./func/sub-01_task-test_run-01_bold.json: “RepetitionTime”: 1.74
./func/sub-01_task-test_run-02_bold.json: “RepetitionTime”: 1.74

So I am guessing, is it because ‘RepetitionTime’ cannot be recognized by fMRIPrep?

In addition, my second question is, I added filedmap data for distortion correction, and they were detected in BIDS validation(as you ca see in brief report from validation). However. in preprocessing, it said “SDC: no fieldmaps found or they were ignored (/data/Derivatives/fmriprep/sub-01/func/sub-01_task-test_run-01_space-MNI152NLin2009cAsym_desc-preproc_bold.nii.gz).” I collected two phase and two magnitude images as fieldmaps and organized them in following way:


Does anyone know if I did it in the wrong way? Or if not, what should I do to solve this?

Thanks in advance!

Hi @Shengjie_Xu,

Ref Q1. Can you post the exact command line you are using?

Ref Q2. For fMRIPrep to understand how the fieldmaps should be used, their sidecar json should point to the bold run(s) that should be corrected using the fieldmap. Your case is one example of “Two phase images and two magnitude images”, and it is unclear where the IntendedFor field should be defined (whether it should be the phase1.json or the phase2.json). @ChrisGorgolewski, do you know on top of your head how this should be disambiguated?

Hi Oesteban,

Thanks for your prompt reply!

(1) I think I maybe figure out my first question myself. But this is an interesting issue. As I am new to fMRIprep, I want to do some practices before I use it for future use. I successfully ran it last time, then I deleted outputs in Derivatives folder, and ran it with fieldmap data again. After that, I met the problem. Thus, I removed all data (original data and related files) and use new data to re-build the whole BIDS folder. Then it works now (new preprocessing is still ongoing now, but no error information is given, but I am not sure whether something surprising will happen or not.) So I am thinking, is it because fMRIprep did some changes on my original data, and they cannot be re-processed?

Here is the command line I am using: fmriprep-docker /home/erlichlab/Test/fMRI_test /home/erlichlab/Test/fMRI_test/Derivatives participant --fs-license-file /home/erlichlab/Test/license.txt

(2) I tried with your suggestion by adding “IntentedFor” in all phase and magnitude json file, “IntendedFor”: [“func/sub-01_task-test_run-01_bold.nii”, “func/sub-01_task-test_run-02_bold.nii”].
And then, it complains KeyError: ‘phase’. I still passed online BIDS validation test, but have no idea what happens. Sorry for my naive question, but I appreciate it a lot if you give any comments on this.

fMRIPrep would never dare to change your original data. If it did, please let us know how because that is definitely not acceptable.

As regards your original error, could you share your data (or a cropped version of it) with us, so that we can replicate?

Yes, it seems you are hitting this issue now. We are in the process of fixing it, but I can’t make any promises at this point. Sorry about that. For now I can suggest you to add --ignore fieldmaps and maybe --use-syn-sdc if you want to have some susceptibility distortion correction.

For my first question, I tried several times, and found it might be related to files read/write privilege. I used sudo, and no problem exits this time.

Thanks for your helpful suggestion on fieldmap issue!

2 posts were split to a new topic: Manage Docker as a non-root user