Skip to content

Commit 406c729

Browse files
committed
Fix docstring, and Directory import
1 parent dc64c72 commit 406c729

File tree

1 file changed

+55
-54
lines changed

1 file changed

+55
-54
lines changed

nipype/interfaces/bids.py

Lines changed: 55 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,22 @@
22
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
33
# vi: set ft=python sts=4 ts=4 sw=4 et:
44
""" Set of interfaces that allow interaction with BIDS data. Currently
5-
available interfaces are:
5+
available interfaces are:
66
7-
BIDSDataGrabber: Query data from BIDS dataset using pybids grabbids.
7+
BIDSDataGrabber: Query data from BIDS dataset using pybids grabbids.
88
9-
Change directory to provide relative paths for doctests
10-
>>> import os
11-
>>> import bids
12-
>>> filepath = os.path.realpath(os.path.dirname(bids.__file__))
13-
>>> datadir = os.path.realpath(os.path.join(filepath, 'grabbids/tests/data/'))
14-
>>> os.chdir(datadir)
9+
Change directory to provide relative paths for doctests
10+
>>> import os
11+
>>> import bids
12+
>>> filepath = os.path.realpath(os.path.dirname(bids.__file__))
13+
>>> datadir = os.path.realpath(os.path.join(filepath, 'grabbids/tests/data/'))
14+
>>> os.chdir(datadir)
1515
1616
"""
1717

1818
from .base import (traits,
1919
DynamicTraitedSpec,
20+
Directory,
2021
BaseInterface,
2122
isdefined,
2223
Str,
@@ -32,9 +33,9 @@
3233
from warnings import warn
3334

3435
class BIDSDataGrabberInputSpec(DynamicTraitedSpec):
35-
base_dir = traits.Directory(exists=True,
36-
desc='Path to BIDS Directory.',
37-
mandatory=True)
36+
base_dir = Directory(exists=True,
37+
desc='Path to BIDS Directory.',
38+
mandatory=True)
3839
output_query = traits.Dict(key_trait=Str,
3940
value_trait=traits.Dict,
4041
desc='Queries for outfield outputs')
@@ -47,49 +48,49 @@ class BIDSDataGrabberInputSpec(DynamicTraitedSpec):
4748
class BIDSDataGrabber(BaseInterface):
4849

4950
""" BIDS datagrabber module that wraps around pybids to allow arbitrary
50-
querying of BIDS datasets.
51-
52-
Examples
53-
--------
54-
55-
>>> from nipype.interfaces.bids import BIDSDataGrabber
56-
>>> from os.path import basename
57-
>>> import pprint
58-
59-
Select all files from a BIDS project
60-
61-
>>> bg = BIDSDataGrabber()
62-
>>> bg.inputs.base_dir = 'ds005/'
63-
>>> results = bg.run()
64-
>>> len(results.outputs.outfield) # doctest: +ALLOW_UNICODE
65-
135
66-
67-
Using dynamically created, user-defined input fields,
68-
filter files based on BIDS entities.
69-
70-
>>> bg = BIDSDataGrabber(infields = ['subject', 'run'])
71-
>>> bg.inputs.base_dir = 'ds005/'
72-
>>> bg.inputs.subject = '01'
73-
>>> bg.inputs.run = '01'
74-
>>> results = bg.run()
75-
>>> basename(results.outputs.outfield[0]) # doctest: +ALLOW_UNICODE
76-
'sub-01_task-mixedgamblestask_run-01_bold.nii.gz'
77-
78-
Using user-defined output fields, return different types of outputs,
79-
filtered on common entities
80-
filter files based on BIDS entities.
81-
82-
>>> bg = BIDSDataGrabber(infields = ['subject'], outfields = ['func', 'anat'])
83-
>>> bg.inputs.base_dir = 'ds005/'
84-
>>> bg.inputs.subject = '01'
85-
>>> bg.inputs.output_query['func'] = dict(modality='func')
86-
>>> bg.inputs.output_query['anat'] = dict(modality='anat')
87-
>>> results = bg.run()
88-
>>> basename(results.outputs.func[0]) # doctest: +ALLOW_UNICODE
89-
'sub-01_task-mixedgamblestask_run-01_bold.nii.gz'
90-
91-
>>> basename(results.outputs.anat[0]) # doctest: +ALLOW_UNICODE
92-
'sub-01_T1w.nii.gz'
51+
querying of BIDS datasets.
52+
53+
Examples
54+
--------
55+
56+
>>> from nipype.interfaces.bids import BIDSDataGrabber
57+
>>> from os.path import basename
58+
>>> import pprint
59+
60+
Select all files from a BIDS project
61+
62+
>>> bg = BIDSDataGrabber()
63+
>>> bg.inputs.base_dir = 'ds005/'
64+
>>> results = bg.run()
65+
>>> len(results.outputs.outfield) # doctest: +ALLOW_UNICODE
66+
135
67+
68+
Using dynamically created, user-defined input fields,
69+
filter files based on BIDS entities.
70+
71+
>>> bg = BIDSDataGrabber(infields = ['subject', 'run'])
72+
>>> bg.inputs.base_dir = 'ds005/'
73+
>>> bg.inputs.subject = '01'
74+
>>> bg.inputs.run = '01'
75+
>>> results = bg.run()
76+
>>> basename(results.outputs.outfield[0]) # doctest: +ALLOW_UNICODE
77+
'sub-01_task-mixedgamblestask_run-01_bold.nii.gz'
78+
79+
Using user-defined output fields, return different types of outputs,
80+
filtered on common entities
81+
filter files based on BIDS entities.
82+
83+
>>> bg = BIDSDataGrabber(infields = ['subject'], outfields = ['func', 'anat'])
84+
>>> bg.inputs.base_dir = 'ds005/'
85+
>>> bg.inputs.subject = '01'
86+
>>> bg.inputs.output_query['func'] = dict(modality='func')
87+
>>> bg.inputs.output_query['anat'] = dict(modality='anat')
88+
>>> results = bg.run()
89+
>>> basename(results.outputs.func[0]) # doctest: +ALLOW_UNICODE
90+
'sub-01_task-mixedgamblestask_run-01_bold.nii.gz'
91+
92+
>>> basename(results.outputs.anat[0]) # doctest: +ALLOW_UNICODE
93+
'sub-01_T1w.nii.gz'
9394
"""
9495
input_spec = BIDSDataGrabberInputSpec
9596
output_spec = DynamicTraitedSpec

0 commit comments

Comments
 (0)