Skip to content

Commit 11f09ba

Browse files
committed
enh: update workflows to use config, add mock config system
1 parent 43cca2c commit 11f09ba

20 files changed

+352
-368
lines changed

MANIFEST.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,3 @@ include LICENSE
55
# versioneer
66
include versioneer.py
77
include dmriprep/_version.py
8-
9-
# data
10-
include dmriprep/config/reports-spec.yml

dmriprep/cli/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def parse_args(args=None, namespace=None):
245245

246246
# Initialize --output-spaces if not defined
247247
if config.execution.output_spaces is None:
248-
config.execution.output_spaces = SpatialReferences([Reference(("run", {}))])
248+
config.execution.output_spaces = SpatialReferences([Reference("run")])
249249

250250
# Retrieve logging level
251251
build_log = config.loggers.cli

dmriprep/cli/workflow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def build_workflow(config_file, retval):
6363

6464
# Build main workflow
6565
INIT_MSG = """
66-
Running dMRIPREP version {version}:
66+
Running dMRIPrep version {version}:
6767
* BIDS dataset path: {bids_dir}.
6868
* Participant list: {subject_list}.
6969
* Run identifier: {uuid}.

dmriprep/config/__init__.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
The module has a :py:func:`~dmriprep.config.to_filename` function to allow writing out
1212
the settings to hard disk in *ToML* format, which looks like:
1313
14-
.. literalinclude:: ../dmriprep/data/tests/config.toml
14+
.. literalinclude:: ../../dmriprep/data/tests/config.toml
1515
:language: toml
1616
:name: dmriprep.toml
1717
:caption: **Example file representation of dMRIPrep settings**.
@@ -532,11 +532,5 @@ def init_spaces(checkpoint=True):
532532
if checkpoint and not spaces.is_cached():
533533
spaces.checkpoint()
534534

535-
# Add the default standard space if not already present (required by several sub-workflows)
536-
if "MNI152NLin2009cAsym" not in spaces.get_spaces(nonstandard=False, dim=(3,)):
537-
spaces.add(
538-
Reference("MNI152NLin2009cAsym", {})
539-
)
540-
541535
# Make the SpatialReferences object available
542536
workflow.spaces = spaces

dmriprep/config/testing.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""Utilities and mocks for testing and documentation building."""
2+
import os
3+
from contextlib import contextmanager
4+
from pathlib import Path
5+
from pkg_resources import resource_filename as pkgrf
6+
from toml import loads
7+
from tempfile import mkdtemp
8+
9+
10+
@contextmanager
11+
def mock_config():
12+
"""Create a mock config for documentation and testing purposes."""
13+
from .. import config
14+
_old_fs = os.getenv('FREESURFER_HOME')
15+
if not _old_fs:
16+
os.environ['FREESURFER_HOME'] = mkdtemp()
17+
18+
filename = Path(pkgrf('dmriprep', 'data/tests/config.toml'))
19+
settings = loads(filename.read_text())
20+
for sectionname, configs in settings.items():
21+
if sectionname != 'environment':
22+
section = getattr(config, sectionname)
23+
section.load(configs, init=False)
24+
config.nipype.init()
25+
config.loggers.init()
26+
config.init_spaces()
27+
28+
config.execution.work_dir = Path(mkdtemp())
29+
config.execution.bids_dir = Path(pkgrf('dmriprep', 'data/tests/THP')).absolute()
30+
config.execution.init()
31+
32+
yield
33+
34+
if not _old_fs:
35+
del os.environ["FREESURFER_HOME"]

dmriprep/data/tests/THP/CHANGES

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2.0.0 2018-04-09
2+
3+
- Renamed dataset name to same as OpenfMRI
4+
- Entered authors
5+
6+
1.0.0 2018-04-09
7+
8+
- Initial publish
9+
10+
1.0.0 2016-08-31
11+
12+
- initial release

dmriprep/data/tests/THP/README

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
2+
This Datasets is from a Traveling Human Phantom (THP) dataset that was
3+
collected for a multi-site neuroimaging reliability study. The THP dataset
4+
includes repeated multi-modal magnetic resonance (MR) images
5+
obtained for five healthy controls performed at eight imaging centers. The
6+
modalities include diffusion weighted images (DWI) and three-dimensional T1
7+
weighted MP-RAGE and T2 SPACE sequences. Intra-subject and inter-site
8+
variability for MRI scans was and can be assessed as repeated images were taken
9+
across multiple imaging protocols.
10+
11+
Another use for the THP dataset could be to evaluate and improve one's tool
12+
against multi-modal and multi-site data. In addition to the THP dataset, which
13+
is useful as it is, we share our processed results. DWI datasets were processed
14+
to produce common rotationally invariant scalar images and diffusion tensor
15+
images. Anatomical images, T1 and T2, were processed with the BRAINSTools suite
16+
to produce anatomical segmentations.
17+
18+
@article{magnotta2012multicenter,
19+
abstract = {A number of studies are now collecting diffusion tensor imaging
20+
(DTI) data across sites. While the reliability of anatomical images has been
21+
established by a number of groups, the reliability of DTI data has not been
22+
studied as extensively. In this study, five healthy controls were recruited and
23+
imaged at eight imaging centers. Repeated measures were obtained across two
24+
imaging protocols allowing intra-subject and inter-site variability to be
25+
assessed. Regional measures within white matter were obtained for standard
26+
rotationally invariant measures: fractional anisotropy, mean diffusivity,
27+
radial diffusivity, and axial diffusivity. Intra-subject coefficient of
28+
variation (CV) was typically {\textless}1{\%} for all scalars and regions.
29+
Inter-site CV increased to {\~{}}1{\%}-3{\%}. Inter-vendor variation was
30+
similar to inter-site variability. This variability includes differences in the
31+
actual implementation of the sequence.}, author = {Magnotta, Vincent a. and
32+
Matsui, Joy T. and Liu, Dawei and Johnson, Hans J. and Long, Jeffrey D. and
33+
Bolster, Bradley D. and Mueller, Bryon a. and Lim, Kelvin O. and Mori, Susumu
34+
and Helmer, Karl and Turner, Jessica a. and Lowe, Mark J. and Aylward,
35+
Elizabeth and Flashman, Laura a. and Bonett, Greg and Paulsen, Jane S.},
36+
doi = {10.1089/brain.2012.0112},
37+
isbn = {8605457767},
38+
issn = {2158-0014},
39+
journal = {Brain Connectivity},
40+
keywords = {diffusion tensor,fractional anisotropy,magnetic resonance,mean diffusivity,reliability,white matter},
41+
mendeley-groups = {ReginaThesis,BiosketchReferences,JoysThesis,JoyCrossSectionalDWI,TEMP{\_}HOWES{\_}RE},
42+
month = {jan},
43+
number = {6},
44+
pages = {121018043201009},
45+
pmid = {23075313},
46+
publisher = {Mary Ann Liebert, Inc. 140 Huguenot Street, 3rd Floor New Rochelle, NY 10801 USA},
47+
title = {{Multi-Center Reliability of Diffusion Tensor Imaging}},
48+
url = {http://www.ncbi.nlm.nih.gov/pubmed/23075313 http://online.liebertpub.com/doi/abs/10.1089/brain.2012.0112 http://www.pubmedcentral.nih.gov/articlerender.fcgi?artid=3623569},
49+
volume = {2},
50+
year = {2012}
51+
}
52+
53+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"Name":"DWI Traveling Human Phantom Study","BIDSVersion":"1.0.0","License":"PDDL","Authors":["Vincent A. Magnotta","Joy T. Matsui","Dawei Liu","Hans J. Johnson","Jeffrey D. Long","Bradley D. Bolster Jr","Bryon A. Mueller","Kelvin Lim","Susumu Mori","Karl G. Helmer","Jessica A. Turner","Sarah Reading","Mark J. Lowe","Elizabeth Aylward","Laura A. Flashman","Greg Bonett","Jane S. Paulsen"],"HowToAcknowledge":"Please reference the following papers: DOI: 10.1089/brain.2012.0112 V. a. Magnotta, J. T. Matsui, D. Liu, H. J. Johnson, J. D. Long, B. D. Bolster, B. a. Mueller, K. O. Lim, S. Mori, K. Helmer, J. a. Turner, M. J. Lowe, E. Aylward, L. a. Flashman, G. Bonett, and J. S. Paulsen, 'Multi-Center Reliability of Diffusion Tensor Imaging,' Brain Connect., vol. 2, no. 6, p. 121018043201009, Jan. 2012.","Funding":"This work was supported, in part, by awards from CHDI Foundation, Inc.; NIH R01NS050568; NINDS NS40068 Neu- robiological Predictors of Huntington's Disease; and NINDS R01 NS054893 Cognitive and Functional Brain Changes in Preclinical HD. Dr. Turner was supported by NCRR 1 U24 RR021992 from the Functional Imaging Biomedical Infor- matics Network (S.G. Potkin, PI) for her work on this project while at the University of California, Irvine. This publication was supported by the National Center for Research Resour- ces and the National Center for Advancing Translational Sciences, National Institutes of Health, through Grant UL1RR024979. The content is solely the responsibility of the authors and does not necessarily represent the official views of the NIH.","ReferencesAndLinks":["http://online.liebertpub.com/doi/abs/10.1089/brain.2012.0112"],"DatasetDOI":"10.1089/brain.2012.0112"}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"Manufacturer": "Siemens",
3+
"ManufacturersModelName": "TrioTim",
4+
"MagneticFieldStrength": 3,
5+
"FlipAngle": 10,
6+
"EchoTime": 0.00287,
7+
"RepetitionTime": 2.3,
8+
"PhaseEncodingDirection": "i-",
9+
"PulseSequenceType": "MPRAGE"
10+
}

dmriprep/data/tests/THP/sub-THP0005/anat/sub-THP0005_T1w.nii.gz

Whitespace-only changes.

0 commit comments

Comments
 (0)