Skip to content

Commit 1d93d9e

Browse files
authored
Merge pull request #2018 from oesteban/maint/config-file
ENH: Config module to replace long list of downstreamed arguments
2 parents 572a3ed + 4d55e58 commit 1d93d9e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1840
-1640
lines changed

.circleci/config.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -334,10 +334,10 @@ jobs:
334334
- data-v7-{{ .Branch }}-{{ .Revision }}
335335
- restore_cache:
336336
keys:
337-
- ds005-anat-v17-{{ .Branch }}-{{ .Revision }}
338-
- ds005-anat-v17-{{ .Branch }}
339-
- ds005-anat-v17-master
340-
- ds005-anat-v17-
337+
- ds005-anat-v18-{{ .Branch }}-{{ .Revision }}
338+
- ds005-anat-v18-{{ .Branch }}
339+
- ds005-anat-v18-master
340+
- ds005-anat-v18-
341341
- run:
342342
name: Set-up a Docker registry
343343
command: |
@@ -380,7 +380,7 @@ jobs:
380380
rm -rf /tmp/ds005/work/reportlets
381381
rm -rf /tmp/ds005/derivatives/fmriprep
382382
- save_cache:
383-
key: ds005-anat-v17-{{ .Branch }}-{{ .Revision }}-{{ epoch }}
383+
key: ds005-anat-v18-{{ .Branch }}-{{ .Revision }}-{{ epoch }}
384384
paths:
385385
- /tmp/ds005/work
386386

@@ -404,6 +404,8 @@ jobs:
404404
--output-spaces MNI152NLin2009cAsym fsaverage5 fsnative MNI152NLin6Asym anat \
405405
--use-plugin /home/circleci/src/fmriprep/.circleci/legacy.yml \
406406
--nthreads 2 --cifti-output -vv
407+
- store_artifacts:
408+
path: /tmp/ds005/derivatives
407409
- run:
408410
name: Move intermediate results for second run
409411
command: |
@@ -414,7 +416,7 @@ jobs:
414416
name: Checking outputs of full fMRIPrep run
415417
command: |
416418
mkdir -p /tmp/ds005/test
417-
find /tmp/ds005/derivatives -path */figures -prune -o -name "*" -print | sed s+/tmp/ds005/derivatives/++ | sort > /tmp/ds005/test/outputs.out
419+
find /tmp/ds005/derivatives \( -path */figures -o -path */log \) -prune -o -name "*" -print | sed s+/tmp/ds005/derivatives/++ | sort > /tmp/ds005/test/outputs.out
418420
diff /tmp/src/fmriprep/.circleci/ds005_outputs.txt /tmp/ds005/test/outputs.out
419421
exit $?
420422
- run:
@@ -437,7 +439,7 @@ jobs:
437439
command: |
438440
mkdir -p /tmp/ds005/test
439441
sudo rm -rf /tmp/ds005/derivatives_partial/freesurfer
440-
find /tmp/ds005/derivatives_partial -path */figures -prune -o -name "*" -print | sed s+/tmp/ds005/derivatives_partial/++ | sort > /tmp/ds005/test/outputs.out
442+
find /tmp/ds005/derivatives_partial \( -path */figures -o -path */log \) -prune -o -name "*" -print | sed s+/tmp/ds005/derivatives_partial/++ | sort > /tmp/ds005/test/outputs.out
441443
diff /tmp/src/fmriprep/.circleci/ds005_partial_outputs.txt /tmp/ds005/test/outputs.out
442444
exit $?
443445
- run:
@@ -458,7 +460,7 @@ jobs:
458460
-exec sh -c 'rm -f {}; touch {}' \;
459461
460462
- store_artifacts:
461-
path: /tmp/ds005
463+
path: /tmp/ds005/work
462464

463465
ds054:
464466
machine:
@@ -562,7 +564,7 @@ jobs:
562564
name: Checking outputs of fMRIPrep
563565
command: |
564566
mkdir -p /tmp/ds054/test
565-
find /tmp/ds054/derivatives -path */figures -prune -o -name "*" -print | sed s+/tmp/ds054/derivatives/++ | sort > /tmp/ds054/test/outputs.out
567+
find /tmp/ds054/derivatives \( -path */figures -o -path */log \) -prune -o -name "*" -print | sed s+/tmp/ds054/derivatives/++ | sort > /tmp/ds054/test/outputs.out
566568
diff /tmp/src/fmriprep/.circleci/ds054_outputs.txt /tmp/ds054/test/outputs.out
567569
exit $?
568570
- run:
@@ -700,7 +702,7 @@ jobs:
700702
name: Checking outputs of fMRIPrep
701703
command: |
702704
mkdir -p /tmp/ds210/test
703-
find /tmp/ds210/derivatives -path */figures -prune -o -name "*" -print | sed s+/tmp/ds210/derivatives/++ | sort > /tmp/ds210/test/outputs.out
705+
find /tmp/ds210/derivatives \( -path */figures -o -path */log \) -prune -o -name "*" -print | sed s+/tmp/ds210/derivatives/++ | sort > /tmp/ds210/test/outputs.out
704706
diff /tmp/src/fmriprep/.circleci/ds210_outputs.txt /tmp/ds210/test/outputs.out
705707
exit $?
706708
- run:

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ python:
1010

1111
before_install:
1212
- python -m pip install --upgrade pip
13-
- pip install "flake8<3.0" flake8-putty
13+
- pip install flake8
1414

1515
script:
1616
- flake8 fmriprep wrapper

docs/api.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
================
44
Developers - API
55
================
6+
Internal configuration system
7+
-----------------------------
8+
9+
.. automodule:: fmriprep.config
10+
:members: from_dict, load, get, dumps, to_filename, init_spaces
611

712
Workflows
813
---------

docs/usage.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Example: ::
3131
Command-Line Arguments
3232
----------------------
3333
.. argparse::
34-
:ref: fmriprep.cli.run.get_parser
34+
:ref: fmriprep.cli.parser._build_parser
3535
:prog: fmriprep
3636
:nodefault:
3737
:nodefaultconst:

docs/workflows.rst

Lines changed: 13 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -17,52 +17,10 @@ is presented below:
1717
:graph2use: orig
1818
:simple_form: yes
1919

20-
from collections import namedtuple
21-
from niworkflows.utils.spaces import Reference, SpatialReferences
20+
from fmriprep.workflows.tests import mock_config
2221
from fmriprep.workflows.base import init_single_subject_wf
23-
BIDSLayout = namedtuple('BIDSLayout', ('root'))
24-
wf = init_single_subject_wf(
25-
anat_only=False,
26-
aroma_melodic_dim=-200,
27-
bold2t1w_dof=9,
28-
cifti_output=False,
29-
debug=False,
30-
dummy_scans=None,
31-
echo_idx=None,
32-
err_on_aroma_warn=False,
33-
fmap_bspline=False,
34-
fmap_demean=True,
35-
force_syn=True,
36-
freesurfer=True,
37-
hires=True,
38-
ignore=[],
39-
layout=BIDSLayout('.'),
40-
longitudinal=False,
41-
low_mem=False,
42-
medial_surface_nan=False,
43-
name='single_subject_wf',
44-
omp_nthreads=1,
45-
output_dir='.',
46-
reportlets_dir='.',
47-
regressors_all_comps=False,
48-
regressors_dvars_th=1.5,
49-
regressors_fd_th=0.5,
50-
skull_strip_fixed_seed=False,
51-
skull_strip_template=Reference('OASIS30ANTs'),
52-
spaces=SpatialReferences(
53-
spaces=[('MNI152Lin', {}),
54-
('fsaverage', {'density': '10k'}),
55-
('T1w', {}),
56-
('fsnative', {})],
57-
checkpoint=True),
58-
subject_id='test',
59-
t2s_coreg=False,
60-
task_id='',
61-
use_aroma=False,
62-
use_bbr=True,
63-
use_syn=True,
64-
bids_filters=None,
65-
)
22+
with mock_config():
23+
wf = init_single_subject_wf('01')
6624

6725
Preprocessing of structural MRI
6826
-------------------------------
@@ -96,7 +54,7 @@ single reference template (see `Longitudinal processing`_).
9654
skull_strip_fixed_seed=False,
9755
)
9856

99-
See also *sMRIPrep*'s
57+
See also *sMRIPrep*'s
10058
:py:func:`~smriprep.workflows.anatomical.init_anat_preproc_wf`.
10159

10260
.. _t1preproc_steps:
@@ -218,7 +176,7 @@ would be processed by the following command::
218176
-autorecon1 \
219177
-noskullstrip
220178

221-
The second phase imports the brainmask calculated in the
179+
The second phase imports the brainmask calculated in the
222180
`Preprocessing of structural MRI`_ sub-workflow.
223181
The final phase resumes reconstruction, using the T2w image to assist
224182
in finding the pial surface, if available.
@@ -279,44 +237,13 @@ BOLD preprocessing
279237
:graph2use: orig
280238
:simple_form: yes
281239

282-
from collections import namedtuple
283-
from niworkflows.utils.spaces import SpatialReferences
240+
from fmriprep.workflows.tests import mock_config
241+
from fmriprep import config
284242
from fmriprep.workflows.bold.base import init_func_preproc_wf
285-
BIDSLayout = namedtuple('BIDSLayout', ['root'])
286-
wf = init_func_preproc_wf(
287-
aroma_melodic_dim=-200,
288-
bold2t1w_dof=9,
289-
bold_file='/completely/made/up/path/sub-01_task-nback_bold.nii.gz',
290-
cifti_output=False,
291-
debug=False,
292-
dummy_scans=None,
293-
err_on_aroma_warn=False,
294-
fmap_bspline=True,
295-
fmap_demean=True,
296-
force_syn=True,
297-
freesurfer=True,
298-
ignore=[],
299-
low_mem=False,
300-
medial_surface_nan=False,
301-
omp_nthreads=1,
302-
output_dir='.',
303-
regressors_all_comps=False,
304-
regressors_fd_th=0.5,
305-
regressors_dvars_th=1.5,
306-
reportlets_dir='.',
307-
t2s_coreg=False,
308-
spaces=SpatialReferences(
309-
spaces=[('MNI152Lin', {}),
310-
('fsaverage', {'density': '10k'}),
311-
('T1w', {}),
312-
('fsnative', {})],
313-
checkpoint=True),
314-
use_aroma=False,
315-
use_bbr=True,
316-
use_syn=True,
317-
layout=BIDSLayout('.'),
318-
num_bold=1,
319-
)
243+
with mock_config():
244+
bold_file = config.execution.bids_dir / 'sub-01' / 'func' \
245+
/ 'sub-01_task-mixedgamblestask_run-01_bold.nii.gz'
246+
wf = init_func_preproc_wf(str(bold_file))
320247

321248
Preprocessing of :abbr:`BOLD (blood-oxygen level-dependent)` files is
322249
split into multiple sub-workflows described below.
@@ -396,7 +323,7 @@ Slice time correction
396323
wf = init_bold_stc_wf(
397324
metadata={'RepetitionTime': 2.0,
398325
'SliceTiming': [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]},
399-
)
326+
)
400327

401328
If the ``SliceTiming`` field is available within the input dataset metadata,
402329
this workflow performs slice time correction prior to other signal resampling
@@ -501,7 +428,7 @@ Resampling BOLD runs onto standard spaces
501428
This sub-workflow concatenates the transforms calculated upstream (see
502429
`Head-motion estimation`_, `Susceptibility Distortion Correction (SDC)`_ --if
503430
fieldmaps are available--, `EPI to T1w registration`_, and an anatomical-to-standard
504-
transform from `Preprocessing of structural MRI`_) to map the
431+
transform from `Preprocessing of structural MRI`_) to map the
505432
:abbr:`EPI (echo-planar imaging)`
506433
image to the standard spaces given by the ``--output-spaces`` argument
507434
(see :ref:`output-spaces`).

fmriprep/__about__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
22
# vi: set ft=python sts=4 ts=4 sw=4 et:
3-
"""
4-
Base module variables
5-
"""
3+
"""Base module variables."""
64
from ._version import get_versions
75
__version__ = get_versions()['version']
86
del get_versions

fmriprep/__init__.py

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,17 @@
1-
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
31
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
42
# vi: set ft=python sts=4 ts=4 sw=4 et:
5-
"""
6-
This pipeline is developed by the Poldrack lab at Stanford University
7-
(https://poldracklab.stanford.edu/) for use at
8-
the Center for Reproducible Neuroscience (http://reproducibility.stanford.edu/),
9-
as well as for open-source software distribution.
10-
"""
3+
"""Top-module metadata."""
114

12-
from .__about__ import ( # noqa
13-
__version__,
5+
from .__about__ import (
146
__copyright__,
157
__credits__,
168
__packagename__,
9+
__version__,
1710
)
1811

19-
import warnings
20-
21-
# cmp is not used by fmriprep, so ignore nipype-generated warnings
22-
warnings.filterwarnings('ignore', r'cmp not installed')
23-
warnings.filterwarnings('ignore', r'This has not been fully tested. Please report any failures.')
24-
warnings.filterwarnings('ignore', r"can't resolve package from __spec__ or __package__")
25-
warnings.simplefilter('ignore', DeprecationWarning)
26-
warnings.simplefilter('ignore', ResourceWarning)
12+
__all__ = [
13+
'__copyright__',
14+
'__credits__',
15+
'__packagename__',
16+
'__version__',
17+
]

0 commit comments

Comments
 (0)