Fmriprep: Fieldmaps KeyError: 'phase'

I get the following error, when I include fieldmaps. I have two phase images and two magnitude images in the fmap folder.

The directory structures passes the BIDS validator, albeit with some warnings, none of which related to fieldmaps.

/usr/local/miniconda/lib/python3.6/site-packages/bids/layout/bids_layout.py:208: ResourceWarning: unclosed file <_io.TextIOWrapper name=’/data/sub-006/ses-glu/fmap/sub-006_ses-glu_run-1_phase1.json’ mode=‘r’ encoding=‘utf-8’>
encoding=‘utf-8’))
Process Process-2:
Traceback (most recent call last):
File “/usr/local/miniconda/lib/python3.6/multiprocessing/process.py”, line 258, in _bootstrap
self.run()
File “/usr/local/miniconda/lib/python3.6/multiprocessing/process.py”, line 93, in run
self._target(*self._args, **self._kwargs)
File “/usr/local/miniconda/lib/python3.6/site-packages/fmriprep/cli/run.py”, line 738, in build_workflow
ignore_aroma_err=opts.ignore_aroma_denoising_errors,
File “/usr/local/miniconda/lib/python3.6/site-packages/fmriprep/workflows/base.py”, line 216, in init_fmriprep_wf
ignore_aroma_err=ignore_aroma_err,
File “/usr/local/miniconda/lib/python3.6/site-packages/fmriprep/workflows/base.py”, line 505, in init_single_subject_wf
num_bold=len(subject_data[‘bold’]))
File “/usr/local/miniconda/lib/python3.6/site-packages/fmriprep/workflows/bold/base.py”, line 292, in init_func_preproc_wf
fmap[‘metadata’] = layout.get_metadata(fmap[fmap[‘type’]])
KeyError: ‘phase’

The content of the phase1.json is as follows:
{ “EchoTime”:.00562,
“IntendedFor”:
[“ses-%s/func/sub-%s_ses-%s_task-%s_run-1_bold.nii” % (session, subj, session, ‘abc’),
“ses-%s/func/sub-%s_ses-%s_task-%s_run-1_bold.nii” % (session, subj, session, ‘rest’)]}

Thanks.

1 Like

See https://github.com/poldracklab/fmriprep/issues/1169 and https://github.com/poldracklab/fmriprep/pull/1359.

1 Like

I’m running into the same issue myself. Is there a way to create a phase difference image from the two phase images so that fmriprep can apply the fieldmap corrections?

@CFS There is a work-in-progress on this: https://github.com/poldracklab/fmriprep/pull/1359

You can try using Matt’s branch of fMRIPrep for the moment, and see if it works for you. See the patching working repositories section of the documentation.

1 Like