Skip to content

Commit be6fedc

Browse files
committed
Merge remote-tracking branch 'upstream/master' into no_error_aroma
2 parents 479ff61 + 42eafa4 commit be6fedc

File tree

14 files changed

+110
-93
lines changed

14 files changed

+110
-93
lines changed

CHANGES.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
1.3.0 (February 7, 2019)
2+
========================
3+
4+
We start the 1.3.x series including a few bugfixes, housekeeping duty and a refactors
5+
to leverage `sMRIPrep <https://github.com/poldracklab/smriprep>`__ (which is a fork of
6+
fMRIPrep's anatomical workflow), pybids>=0.7 for querying dataset, and
7+
`TemplateFlow <https://github.com/templateflow>`__ for handling standard spaces.
8+
9+
* [FIX] Bad ``fsnative`` replacement in CIfTI workflow (#1476) @oesteban
10+
* [FIX] Avoid warning when generating boilerplate (#1464) @oesteban
11+
* [MAINT] resolves #1485 : patch fmriprep-docker automount for use with Python 3.7 (#1486) @rciric
12+
* [RF] Use anatomical workflows from sMRIPrep (#1482) @oesteban
13+
* [MAINT] Update sentry-sdk (#1490) @chrisfilo
14+
* [ENH] Remaining TemplateFlow integrations (#1494) @oesteban
15+
* [MAINT] Update to keep up with poldracklab/niworkflows#299 (#1496) @oesteban
16+
* [FIX] Updating bids-validator to 1.1.3 (#1498) @chrisfilo
17+
18+
119
1.2.6-1 (January 24, 2019)
220
==========================
321

Dockerfile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ RUN apt-get install -y nodejs
104104
RUN npm install -g svgo
105105

106106
# Installing bids-validator
107-
RUN npm install -g [email protected].0
107+
RUN npm install -g [email protected].3
108108

109109
# Installing and setting up ICA_AROMA
110110
RUN mkdir -p /opt/ICA-AROMA && \
@@ -161,10 +161,13 @@ RUN pip install "datalad==0.10.0" && \
161161
rm -rf ~/.cache/pip
162162

163163
RUN git config --global user.name "First Last" && \
164-
git config --global user.email "[email protected]" && \
165-
datalad install -r https://github.com/templateflow/templateflow.git
166-
RUN datalad get $TEMPLATEFLOW_HOME/tpl-MNI152NLin2009cAsym/*_T1w.nii.gz \
164+
git config --global user.email "[email protected]"
165+
166+
RUN datalad install -r https://github.com/templateflow/templateflow.git && \
167+
datalad get $TEMPLATEFLOW_HOME/tpl-MNI152NLin2009cAsym/*_T1w.nii.gz \
167168
$TEMPLATEFLOW_HOME/tpl-MNI152NLin2009cAsym/*_desc-brain_mask.nii.gz \
169+
$TEMPLATEFLOW_HOME/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_desc-fMRIPrep_boldref.nii.gz \
170+
$TEMPLATEFLOW_HOME/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_desc-DKT31_dseg.nii.gz \
168171
$TEMPLATEFLOW_HOME/tpl-MNI152Lin/*_T1w.nii.gz \
169172
$TEMPLATEFLOW_HOME/tpl-MNI152Lin/*_desc-brain_mask.nii.gz \
170173
$TEMPLATEFLOW_HOME/tpl-OASIS30ANTs/*_T1w.nii.gz \

docs/workflows.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ is presented below:
1919
:simple_form: yes
2020

2121
from fmriprep.workflows.base import init_single_subject_wf
22+
from collections import namedtuple
23+
BIDSLayout = namedtuple('BIDSLayout', ['root'], defaults='.')
2224
wf = init_single_subject_wf(
25+
layout=BIDSLayout(),
2326
subject_id='test',
2427
name='single_subject_wf',
2528
task_id='',
@@ -30,7 +33,6 @@ is presented below:
3033
freesurfer=True,
3134
reportlets_dir='.',
3235
output_dir='.',
33-
bids_dir='.',
3436
skull_strip_template='OASIS30ANTs',
3537
skull_strip_fixed_seed=False,
3638
template='MNI152NLin2009cAsym',

fmriprep/__about__.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,27 +84,28 @@
8484
]
8585

8686
REQUIRES = [
87-
'grabbit==0.2.3',
8887
'indexed_gzip>=0.8.8',
8988
'nibabel>=2.2.1',
9089
'nilearn',
9190
'nipype>=1.1.6',
9291
'nitime',
93-
'niworkflows>=0.6.1,<0.7.0a0',
92+
'niworkflows',
9493
'numpy',
9594
'pandas',
9695
'psutil>=5.4',
97-
'pybids==0.6.5',
96+
'pybids>=0.7.0,<0.8.0a0',
9897
'pyyaml',
9998
'scikit-image',
100-
'smriprep>=0.0.4,<0.1.0a0',
99+
'smriprep>=0.0.5,<0.1.0a0',
101100
'statsmodels',
102101
'tedana>=0.0.5',
103102
'templateflow>=0.0.4',
104103
]
105104

106105

107106
LINKS_REQUIRES = [
107+
'git+https://github.com/poldracklab/niworkflows.git@'
108+
'b97787ee2f1b93cafb104664b60fa0c4fd81253a#egg=niworkflows-0.7.1',
108109
]
109110

110111
TESTS_REQUIRES = [
@@ -125,7 +126,7 @@
125126
],
126127
'duecredit': ['duecredit'],
127128
'resmon': [],
128-
'sentry': ['sentry-sdk>=0.5.3'],
129+
'sentry': ['sentry-sdk>=0.6.9'],
129130
'tests': TESTS_REQUIRES,
130131
}
131132
EXTRA_REQUIRES['docs'] = EXTRA_REQUIRES['doc']

fmriprep/cli/run.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,7 @@ def build_workflow(opts, retval):
556556
from subprocess import check_call, CalledProcessError, TimeoutExpired
557557
from pkg_resources import resource_filename as pkgrf
558558
from shutil import copyfile
559+
from bids import BIDSLayout
559560

560561
from nipype import logging, config as ncfg
561562
from niworkflows.utils.bids import collect_participants
@@ -610,8 +611,9 @@ def build_workflow(opts, retval):
610611

611612
# First check that bids_dir looks like a BIDS folder
612613
bids_dir = os.path.abspath(opts.bids_dir)
614+
layout = BIDSLayout(bids_dir, validate=False)
613615
subject_list = collect_participants(
614-
bids_dir, participant_label=opts.participant_label)
616+
layout, participant_label=opts.participant_label)
615617

616618
# Load base plugin_settings from file if --use-plugin
617619
if opts.use_plugin is not None:
@@ -719,6 +721,7 @@ def build_workflow(opts, retval):
719721
logger.warning('Option --debug is deprecated and has no effect')
720722

721723
retval['workflow'] = init_fmriprep_wf(
724+
layout=layout,
722725
subject_list=subject_list,
723726
task_id=opts.task_id,
724727
echo_idx=opts.echo_idx,
@@ -734,7 +737,6 @@ def build_workflow(opts, retval):
734737
skull_strip_fixed_seed=opts.skull_strip_fixed_seed,
735738
work_dir=work_dir,
736739
output_dir=output_dir,
737-
bids_dir=bids_dir,
738740
freesurfer=opts.run_reconall,
739741
output_spaces=output_spaces,
740742
template=opts.template,

fmriprep/utils/bids.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@
66
Utilities to handle BIDS inputs
77
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
88
9-
Fetch some test data
10-
11-
>>> import os
12-
>>> from niworkflows import data
13-
>>> data_root = data.get_bids_examples(variant='BIDS-examples-1-enh-ds054')
14-
>>> os.chdir(data_root)
15-
169
"""
1710
import os
1811
import json

fmriprep/workflows/base.py

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
from .bold import init_func_preproc_wf
3434

3535

36-
def init_fmriprep_wf(subject_list, task_id, echo_idx, run_uuid, work_dir, output_dir, bids_dir,
36+
def init_fmriprep_wf(layout, subject_list, task_id, echo_idx, run_uuid, work_dir, output_dir,
3737
ignore, debug, low_mem, anat_only, longitudinal, t2s_coreg,
3838
omp_nthreads, skull_strip_template, skull_strip_fixed_seed,
3939
freesurfer, output_spaces, template, medial_surface_nan, cifti_output, hires,
@@ -51,15 +51,17 @@ def init_fmriprep_wf(subject_list, task_id, echo_idx, run_uuid, work_dir, output
5151
:simple_form: yes
5252
5353
import os
54-
os.environ['FREESURFER_HOME'] = os.getcwd()
54+
from collections import namedtuple
55+
BIDSLayout = namedtuple('BIDSLayout', ['root'], defaults='.')
5556
from fmriprep.workflows.base import init_fmriprep_wf
56-
wf = init_fmriprep_wf(subject_list=['fmripreptest'],
57+
os.environ['FREESURFER_HOME'] = os.getcwd()
58+
wf = init_fmriprep_wf(layout=BIDSLayout(),
59+
subject_list=['fmripreptest'],
5760
task_id='',
5861
echo_idx=None,
5962
run_uuid='X',
6063
work_dir='.',
6164
output_dir='.',
62-
bids_dir='.',
6365
ignore=[],
6466
debug=False,
6567
low_mem=False,
@@ -90,6 +92,8 @@ def init_fmriprep_wf(subject_list, task_id, echo_idx, run_uuid, work_dir, output
9092
9193
Parameters
9294
95+
layout : BIDSLayout object
96+
BIDS dataset layout
9397
subject_list : list
9498
List of subject labels
9599
task_id : str or None
@@ -103,8 +107,6 @@ def init_fmriprep_wf(subject_list, task_id, echo_idx, run_uuid, work_dir, output
103107
Directory in which to store workflow execution state and temporary files
104108
output_dir : str
105109
Directory in which to save derivatives
106-
bids_dir : str
107-
Root directory of BIDS dataset
108110
ignore : list
109111
Preprocessing steps to skip (may include "slicetiming", "fieldmaps")
110112
debug : bool
@@ -182,13 +184,13 @@ def init_fmriprep_wf(subject_list, task_id, echo_idx, run_uuid, work_dir, output
182184
reportlets_dir = os.path.join(work_dir, 'reportlets')
183185
for subject_id in subject_list:
184186
single_subject_wf = init_single_subject_wf(
187+
layout=layout,
185188
subject_id=subject_id,
186189
task_id=task_id,
187190
echo_idx=echo_idx,
188191
name="single_subject_" + subject_id + "_wf",
189192
reportlets_dir=reportlets_dir,
190193
output_dir=output_dir,
191-
bids_dir=bids_dir,
192194
ignore=ignore,
193195
debug=debug,
194196
low_mem=low_mem,
@@ -230,8 +232,8 @@ def init_fmriprep_wf(subject_list, task_id, echo_idx, run_uuid, work_dir, output
230232
return fmriprep_wf
231233

232234

233-
def init_single_subject_wf(subject_id, task_id, echo_idx, name, reportlets_dir, output_dir,
234-
bids_dir, ignore, debug, low_mem, anat_only, longitudinal, t2s_coreg,
235+
def init_single_subject_wf(layout, subject_id, task_id, echo_idx, name, reportlets_dir,
236+
output_dir, ignore, debug, low_mem, anat_only, longitudinal, t2s_coreg,
235237
omp_nthreads, skull_strip_template, skull_strip_fixed_seed,
236238
freesurfer, output_spaces, template, medial_surface_nan,
237239
cifti_output, hires, use_bbr, bold2t1w_dof, fmap_bspline, fmap_demean,
@@ -252,13 +254,15 @@ def init_single_subject_wf(subject_id, task_id, echo_idx, name, reportlets_dir,
252254
:simple_form: yes
253255
254256
from fmriprep.workflows.base import init_single_subject_wf
255-
wf = init_single_subject_wf(subject_id='test',
257+
from collections import namedtuple
258+
BIDSLayout = namedtuple('BIDSLayout', ['root'], defaults='.')
259+
wf = init_single_subject_wf(layout=BIDSLayout(),
260+
subject_id='test',
256261
task_id='',
257262
echo_idx=None,
258263
name='single_subject_wf',
259264
reportlets_dir='.',
260265
output_dir='.',
261-
bids_dir='.',
262266
ignore=[],
263267
debug=False,
264268
low_mem=False,
@@ -288,6 +292,8 @@ def init_single_subject_wf(subject_id, task_id, echo_idx, name, reportlets_dir,
288292
289293
Parameters
290294
295+
layout : BIDSLayout object
296+
BIDS dataset layout
291297
subject_id : str
292298
List of subject labels
293299
task_id : str or None
@@ -321,8 +327,6 @@ def init_single_subject_wf(subject_id, task_id, echo_idx, name, reportlets_dir,
321327
Directory in which to save reportlets
322328
output_dir : str
323329
Directory in which to save derivatives
324-
bids_dir : str
325-
Root directory of BIDS dataset
326330
freesurfer : bool
327331
Enable FreeSurfer surface reconstruction (may increase runtime)
328332
output_spaces : list
@@ -377,9 +381,8 @@ def init_single_subject_wf(subject_id, task_id, echo_idx, name, reportlets_dir,
377381
't1w': ['/completely/made/up/path/sub-01_T1w.nii.gz'],
378382
'bold': ['/completely/made/up/path/sub-01_task-nback_bold.nii.gz']
379383
}
380-
layout = None
381384
else:
382-
subject_data, layout = collect_data(bids_dir, subject_id, task_id, echo_idx)
385+
subject_data = collect_data(layout, subject_id, task_id, echo_idx)[0]
383386

384387
# Make sure we always go through these two checks
385388
if not anat_only and subject_data['bold'] == []:
@@ -421,7 +424,8 @@ def init_single_subject_wf(subject_id, task_id, echo_idx, name, reportlets_dir,
421424
bidssrc = pe.Node(BIDSDataGrabber(subject_data=subject_data, anat_only=anat_only),
422425
name='bidssrc')
423426

424-
bids_info = pe.Node(BIDSInfo(), name='bids_info', run_without_submitting=True)
427+
bids_info = pe.Node(BIDSInfo(
428+
bids_dir=layout.root, bids_validate=False), name='bids_info')
425429

426430
summary = pe.Node(SubjectSummary(output_spaces=output_spaces, template=template),
427431
name='summary', run_without_submitting=True)
@@ -464,12 +468,12 @@ def init_single_subject_wf(subject_id, task_id, echo_idx, name, reportlets_dir,
464468
(bidssrc, summary, [('t1w', 't1w'),
465469
('t2w', 't2w'),
466470
('bold', 'bold')]),
467-
(bids_info, summary, [('subject_id', 'subject_id')]),
471+
(bids_info, summary, [('subject', 'subject_id')]),
472+
(bids_info, anat_preproc_wf, [(('subject', _prefix), 'inputnode.subject_id')]),
468473
(bidssrc, anat_preproc_wf, [('t1w', 'inputnode.t1w'),
469474
('t2w', 'inputnode.t2w'),
470475
('roi', 'inputnode.roi'),
471476
('flair', 'inputnode.flair')]),
472-
(summary, anat_preproc_wf, [('subject_id', 'inputnode.subject_id')]),
473477
(bidssrc, ds_report_summary, [(('t1w', fix_multi_T1w_source_name), 'source_file')]),
474478
(summary, ds_report_summary, [('out_report', 'in_file')]),
475479
(bidssrc, ds_report_about, [(('t1w', fix_multi_T1w_source_name), 'source_file')]),
@@ -532,3 +536,9 @@ def init_single_subject_wf(subject_id, task_id, echo_idx, name, reportlets_dir,
532536
])
533537

534538
return workflow
539+
540+
541+
def _prefix(subid):
542+
if subid.startswith('sub-'):
543+
return subid
544+
return '-'.join(('sub', subid))

fmriprep/workflows/bold/base.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -246,15 +246,15 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
246246

247247
sbref_file = None
248248
# For doc building purposes
249-
if layout is None or bold_file == 'bold_preprocesing':
249+
if not hasattr(layout, 'parse_file_entities'):
250250
LOGGER.log(25, 'No valid layout: building empty workflow.')
251251
metadata = {
252252
'RepetitionTime': 2.0,
253253
'SliceTiming': [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9],
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',
@@ -264,16 +264,16 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
264264
else:
265265
# Find associated sbref, if possible
266266
entities = layout.parse_file_entities(ref_file)
267-
entities['type'] = 'sbref'
268-
files = layout.get(**entities, extensions=['nii', 'nii.gz'])
267+
entities['suffix'] = 'sbref'
268+
files = layout.get(return_type='file', extensions=['nii', 'nii.gz'], **entities)
269269
refbase = os.path.basename(ref_file)
270270
if 'sbref' in ignore:
271271
LOGGER.info("Single-band reference files ignored.")
272272
elif files and multiecho:
273273
LOGGER.warning("Single-band reference found, but not supported in "
274274
"multi-echo workflows at this time. Ignoring.")
275275
elif files:
276-
sbref_file = files[0].filename
276+
sbref_file = files[0]
277277
sbbase = os.path.basename(sbref_file)
278278
if len(files) > 1:
279279
LOGGER.warning(
@@ -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(

0 commit comments

Comments
 (0)