Skip to content

Commit d32dc49

Browse files
committed
fix fieldmap querying for pybids 0.7
1 parent e5a2b9f commit d32dc49

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

fmriprep/workflows/bold/base.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
254254
'PhaseEncodingDirection': 'j',
255255
}
256256
fmaps = [{
257-
'type': 'phasediff',
257+
'suffix': 'phasediff',
258258
'phasediff': 'sub-03/ses-2/fmap/sub-03_ses-2_run-1_phasediff.nii.gz',
259259
'magnitude1': 'sub-03/ses-2/fmap/sub-03_ses-2_run-1_magnitude1.nii.gz',
260260
'magnitude2': 'sub-03/ses-2/fmap/sub-03_ses-2_run-1_magnitude2.nii.gz',
@@ -291,11 +291,11 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
291291
if 'fieldmaps' not in ignore:
292292
fmaps = layout.get_fieldmap(ref_file, return_list=True)
293293
for fmap in fmaps:
294-
fmap['metadata'] = layout.get_metadata(fmap[fmap['type']])
294+
fmap['metadata'] = layout.get_metadata(fmap[fmap['suffix']])
295295

296296
# Run SyN if forced or in the absence of fieldmap correction
297297
if force_syn or (use_syn and not fmaps):
298-
fmaps.append({'type': 'syn'})
298+
fmaps.append({'suffix': 'syn'})
299299

300300
# Short circuits: (True and True and (False or 'TooShort')) == 'TooShort'
301301
run_stc = ("SliceTiming" in metadata and
@@ -476,14 +476,14 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
476476
if not fmaps:
477477
LOGGER.warning('SDC: no fieldmaps found or they were ignored (%s).',
478478
ref_file)
479-
elif fmaps[0]['type'] == 'syn':
479+
elif fmaps[0]['suffix'] == 'syn':
480480
LOGGER.warning(
481481
'SDC: no fieldmaps found or they were ignored. '
482482
'Using EXPERIMENTAL "fieldmap-less SyN" correction '
483483
'for dataset %s.', ref_file)
484484
else:
485485
LOGGER.log(25, 'SDC: fieldmap estimation of type "%s" intended for %s found.',
486-
fmaps[0]['type'], ref_file)
486+
fmaps[0]['suffix'], ref_file)
487487

488488
# MULTI-ECHO EPI DATA #############################################
489489
if multiecho:
@@ -613,7 +613,7 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
613613

614614
if fmaps:
615615
from ..fieldmap.unwarp import init_fmap_unwarp_report_wf
616-
sdc_type = fmaps[0]['type']
616+
sdc_type = fmaps[0]['suffix']
617617

618618
# Report on BOLD correction
619619
fmap_unwarp_report_wf = init_fmap_unwarp_report_wf(

fmriprep/workflows/fieldmap/base.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def init_sdc_wf(fmaps, bold_meta, omp_nthreads=1,
7979
from fmriprep.workflows.fieldmap import init_sdc_wf
8080
wf = init_sdc_wf(
8181
fmaps=[{
82-
'type': 'phasediff',
82+
'suffix': 'phasediff',
8383
'phasediff': 'sub-03/ses-2/fmap/sub-03_ses-2_run-1_phasediff.nii.gz',
8484
'magnitude1': 'sub-03/ses-2/fmap/sub-03_ses-2_run-1_magnitude1.nii.gz',
8585
'magnitude2': 'sub-03/ses-2/fmap/sub-03_ses-2_run-1_magnitude2.nii.gz',
@@ -140,7 +140,7 @@ def init_sdc_wf(fmaps, bold_meta, omp_nthreads=1,
140140
"""
141141

142142
# TODO: To be removed (filter out unsupported fieldmaps):
143-
fmaps = [fmap for fmap in fmaps if fmap['type'] in FMAP_PRIORITY]
143+
fmaps = [fmap for fmap in fmaps if fmap['suffix'] in FMAP_PRIORITY]
144144

145145
workflow = Workflow(name='sdc_wf' if fmaps else 'sdc_bypass_wf')
146146
inputnode = pe.Node(niu.IdentityInterface(
@@ -170,15 +170,15 @@ def init_sdc_wf(fmaps, bold_meta, omp_nthreads=1,
170170
"""
171171

172172
# In case there are multiple fieldmaps prefer EPI
173-
fmaps.sort(key=lambda fmap: FMAP_PRIORITY[fmap['type']])
173+
fmaps.sort(key=lambda fmap: FMAP_PRIORITY[fmap['suffix']])
174174
fmap = fmaps[0]
175175

176176
# PEPOLAR path
177-
if fmap['type'] == 'epi':
177+
if fmap['suffix'] == 'epi':
178178
outputnode.inputs.method = 'PEB/PEPOLAR (phase-encoding based / PE-POLARity)'
179179
# Get EPI polarities and their metadata
180180
epi_fmaps = [(fmap_['epi'], fmap_['metadata']["PhaseEncodingDirection"])
181-
for fmap_ in fmaps if fmap_['type'] == 'epi']
181+
for fmap_ in fmaps if fmap_['suffix'] == 'epi']
182182
sdc_unwarp_wf = init_pepolar_unwarp_wf(
183183
bold_meta=bold_meta,
184184
epi_fmaps=epi_fmaps,
@@ -193,11 +193,11 @@ def init_sdc_wf(fmaps, bold_meta, omp_nthreads=1,
193193
])
194194

195195
# FIELDMAP path
196-
if fmap['type'] in ['fieldmap', 'phasediff']:
197-
outputnode.inputs.method = 'FMB (%s-based)' % fmap['type']
196+
if fmap['suffix'] in ['fieldmap', 'phasediff']:
197+
outputnode.inputs.method = 'FMB (%s-based)' % fmap['suffix']
198198
# Import specific workflows here, so we don't break everything with one
199199
# unused workflow.
200-
if fmap['type'] == 'fieldmap':
200+
if fmap['suffix'] == 'fieldmap':
201201
from .fmap import init_fmap_wf
202202
fmap_estimator_wf = init_fmap_wf(
203203
omp_nthreads=omp_nthreads,
@@ -206,7 +206,7 @@ def init_sdc_wf(fmaps, bold_meta, omp_nthreads=1,
206206
fmap_estimator_wf.inputs.inputnode.fieldmap = fmap['fieldmap']
207207
fmap_estimator_wf.inputs.inputnode.magnitude = fmap['magnitude']
208208

209-
if fmap['type'] == 'phasediff':
209+
if fmap['suffix'] == 'phasediff':
210210
from .phdiff import init_phdiff_wf
211211
fmap_estimator_wf = init_phdiff_wf(omp_nthreads=omp_nthreads)
212212
# set inputs
@@ -235,7 +235,7 @@ def init_sdc_wf(fmaps, bold_meta, omp_nthreads=1,
235235
])
236236

237237
# FIELDMAP-less path
238-
if any(fm['type'] == 'syn' for fm in fmaps):
238+
if any(fm['suffix'] == 'syn' for fm in fmaps):
239239
syn_sdc_wf = init_syn_sdc_wf(
240240
bold_pe=bold_meta.get('PhaseEncodingDirection', None),
241241
omp_nthreads=omp_nthreads)
@@ -250,7 +250,7 @@ def init_sdc_wf(fmaps, bold_meta, omp_nthreads=1,
250250
])
251251

252252
# XXX Eliminate branch when forcing isn't an option
253-
if fmap['type'] == 'syn': # No fieldmaps, but --use-syn
253+
if fmap['suffix'] == 'syn': # No fieldmaps, but --use-syn
254254
outputnode.inputs.method = 'FLB ("fieldmap-less", SyN-based)'
255255
sdc_unwarp_wf = syn_sdc_wf
256256
else: # --force-syn was called when other fieldmap was present

0 commit comments

Comments
 (0)