Skip to content

Commit cc00977

Browse files
committed
style changes
1 parent 45f78d4 commit cc00977

File tree

3 files changed

+31
-44
lines changed

3 files changed

+31
-44
lines changed

dmriprep/utils/bids.py

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
"""
2+
Utilities to handle BIDS inputs
3+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4+
"""
5+
16
import warnings
27
import json
38
import sys
@@ -51,7 +56,7 @@ def collect_participants(
5156
... str(datadir / 'ds114'), participant_label=['02', '14'],
5257
... strict=True, bids_validate=False) # doctest: +IGNORE_EXCEPTION_DETAIL
5358
Traceback (most recent call last):
54-
fmriprep.utils.bids.BIDSError:
59+
dmriprep.utils.bids.BIDSError:
5560
...
5661
"""
5762

@@ -91,19 +96,15 @@ def collect_participants(
9196
found_label = sorted(set(participant_label) & all_participants)
9297
if not found_label:
9398
raise BIDSError(
94-
"Could not find participants [{}]".format(
95-
", ".join(participant_label)
96-
),
99+
"Could not find participants [{}]".format(", ".join(participant_label)),
97100
bids_dir,
98101
)
99102

100103
# Warn if some IDs were not found
101104
notfound_label = sorted(set(participant_label) - all_participants)
102105
if notfound_label:
103106
exc = BIDSError(
104-
"Some participants were not found: {}".format(
105-
", ".join(notfound_label)
106-
),
107+
"Some participants were not found: {}".format(", ".join(notfound_label)),
107108
bids_dir,
108109
)
109110
if strict:
@@ -114,7 +115,7 @@ def collect_participants(
114115

115116

116117
def validate_input_dir(bids_dir, all_subjects, subject_list):
117-
# Ignore issues and warnings that should not influence FMRIPREP
118+
# Ignore issues and warnings that should not influence DMRIPREP
118119
import tempfile
119120
import subprocess
120121

@@ -162,18 +163,11 @@ def validate_input_dir(bids_dir, all_subjects, subject_list):
162163
ignored_subjects = all_subjects.difference(subject_list)
163164
if ignored_subjects:
164165
for subject in ignored_subjects:
165-
validator_config_dict["ignoredFiles"].append(
166-
"/sub-%s/**" % subject
167-
)
166+
validator_config_dict["ignoredFiles"].append("/sub-%s/**" % subject)
168167
with tempfile.NamedTemporaryFile("w+") as temp:
169168
temp.write(json.dumps(validator_config_dict))
170169
temp.flush()
171170
try:
172-
subprocess.check_call(
173-
["bids-validator", bids_dir, "-c", temp.name]
174-
)
171+
subprocess.check_call(["bids-validator", bids_dir, "-c", temp.name])
175172
except FileNotFoundError:
176-
print(
177-
"bids-validator does not appear to be installed",
178-
file=sys.stderr,
179-
)
173+
print("bids-validator does not appear to be installed", file=sys.stderr)

dmriprep/workflows/base.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
#!/usr/bin/env python
22

3+
"""
4+
dMRIprep base processing workflows
5+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
7+
.. autofunction:: init_dmriprep_wf
8+
.. autofunction:: init_single_subject_wf
9+
10+
"""
11+
312
import os
413
from copy import deepcopy
514

@@ -106,14 +115,8 @@ def init_single_subject_wf(subject_id, name, parameters):
106115
("outputnode.out_mask", "inputnode.mask"),
107116
("outputnode.out_b0_pre", "inputnode.b0"),
108117
("outputnode.out_b0_mask_pre", "inputnode.b0_mask"),
109-
(
110-
"outputnode.out_eddy_quad_json",
111-
"inputnode.eddy_quad_json",
112-
),
113-
(
114-
"outputnode.out_eddy_quad_pdf",
115-
"inputnode.eddy_quad_pdf",
116-
),
118+
("outputnode.out_eddy_quad_json", "inputnode.eddy_quad_json"),
119+
("outputnode.out_eddy_quad_pdf", "inputnode.eddy_quad_pdf"),
117120
("outputnode.out_dtifit_FA", "inputnode.dtifit_FA"),
118121
("outputnode.out_dtifit_V1", "inputnode.dtifit_V1"),
119122
("outputnode.out_dtifit_sse", "inputnode.dtifit_sse"),

dmriprep/workflows/dwi/outputs.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
# -*- coding: utf-8 -*-
22

3-
import os
4-
53
from nipype.pipeline import engine as pe
64
from nipype.interfaces import io as nio, utility as niu
75

86

97
def init_output_wf(subject_id, session_id, output_folder):
108

11-
op_wf = pe.Workflow(name="output_wf")
9+
output_wf = pe.Workflow(name="output_wf")
1210

1311
inputnode = pe.Node(
1412
niu.IdentityInterface(
@@ -38,11 +36,7 @@ def build_path(output_folder, subject_id, session_id):
3836
import os
3937

4038
return os.path.join(
41-
output_folder,
42-
"dmriprep",
43-
"sub-" + subject_id,
44-
"ses-" + session_id,
45-
"dwi",
39+
output_folder, "dmriprep", "sub-" + subject_id, "ses-" + session_id, "dwi"
4640
)
4741

4842
concat = pe.Node(
@@ -56,7 +50,7 @@ def build_path(output_folder, subject_id, session_id):
5650

5751
datasink = pe.Node(nio.DataSink(), name="datasink")
5852

59-
op_wf.connect(
53+
output_wf.connect(
6054
[
6155
(
6256
inputnode,
@@ -73,23 +67,19 @@ def build_path(output_folder, subject_id, session_id):
7367
datasink,
7468
[
7569
("dwi", "@result.@dwi"),
76-
("bval", "@result.@bval"),
7770
("bvec", "@result.@bvec"),
78-
("index", "@result.@index"),
79-
("acq_params", "@result.@acq_params"),
71+
("bval", "@result.@bval"),
8072
("mask", "@result.@mask"),
8173
("b0", "@result.@b0"),
82-
("b0_mask", "@result.@b0_mask"),
83-
# ("out_fieldmap_brain", "@result.@fmapbrain"),
8474
("eddy_quad_json", "@result.@eddy_quad_json"),
8575
("eddy_quad_pdf", "@result.@eddy_quad_pdf"),
8676
("dtifit_FA", "@result.@fa"),
87-
("dtifit_V1", "@result.@v1"),
88-
("dtifit_sse", "@result.@sse"),
89-
("noise", "@result.@noise"),
77+
("dtifit_MD", "@result.@md"),
78+
("dtifit_AD", "@result.@ad"),
79+
("dtifit_RD", "@result.@rd"),
9080
],
9181
),
9282
]
9383
)
9484

95-
return op_wf
85+
return output_wf

0 commit comments

Comments
 (0)