Skip to content

Commit 1aa443a

Browse files
committed
wip
1 parent ab6725e commit 1aa443a

File tree

6 files changed

+316
-78
lines changed

6 files changed

+316
-78
lines changed

dmriprep/workflows/dwi/base.py

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
Orchestrating the dwi preprocessing workflows
55
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
7-
.. autofunction:: init_dwi_preproc_wf
8-
97
"""
108

119
from bids import BIDSLayout
@@ -93,6 +91,14 @@ def init_dwi_preproc_wf(subject_id, dwi_file, metadata, parameters):
9391
name="outputnode",
9492
)
9593

94+
denoise = pe.Node(mrtrix3.DWIDenoise(), name="denoise")
95+
96+
unring = pe.Node(mrtrix3.MRDeGibbs(), name="unring")
97+
98+
resample = pe.Node(
99+
mrtrix3.MRResize(voxel_size=parameters.output_resolution), name="resample"
100+
)
101+
96102
def gen_index(in_file):
97103
import os
98104
import numpy as np
@@ -101,10 +107,7 @@ def gen_index(in_file):
101107
from nipype.utils.filemanip import fname_presuffix
102108

103109
out_file = fname_presuffix(
104-
in_file,
105-
suffix="_index.txt",
106-
newpath=os.path.abspath("."),
107-
use_ext=False,
110+
in_file, suffix="_index.txt", newpath=os.path.abspath("."), use_ext=False
108111
)
109112
vols = nib.load(in_file, mmap=NUMPY_MMAP).get_data().shape[-1]
110113
index_lines = np.ones((vols,))
@@ -114,9 +117,7 @@ def gen_index(in_file):
114117

115118
gen_idx = pe.Node(
116119
niu.Function(
117-
input_names=["in_file"],
118-
output_names=["out_file"],
119-
function=gen_index,
120+
input_names=["in_file"], output_names=["out_file"], function=gen_index
120121
),
121122
name="gen_index",
122123
)
@@ -162,11 +163,7 @@ def gen_acqparams(in_file, metadata):
162163
dwi_wf.connect(
163164
[
164165
(inputnode, gen_idx, [("dwi_file", "in_file")]),
165-
(
166-
inputnode,
167-
acqp,
168-
[("dwi_file", "in_file"), ("dwi_meta", "metadata")],
169-
),
166+
(inputnode, acqp, [("dwi_file", "in_file"), ("dwi_meta", "metadata")]),
170167
]
171168
)
172169

@@ -215,13 +212,10 @@ def b0_average(in_dwi, in_bval, b0_thresh, out_file=None):
215212
avg_b0_0.inputs.b0_thresh = parameters.b0_thresh
216213

217214
bet_dwi0 = pe.Node(
218-
fsl.BET(frac=parameters.bet_dwi, mask=True, robust=True),
219-
name="bet_dwi_pre",
215+
fsl.BET(frac=parameters.bet_dwi, mask=True, robust=True), name="bet_dwi_pre"
220216
)
221217

222-
ecc = pe.Node(
223-
fsl.Eddy(repol=True, cnr_maps=True, residuals=True), name="fsl_eddy"
224-
)
218+
ecc = pe.Node(fsl.Eddy(repol=True, cnr_maps=True, residuals=True), name="fsl_eddy")
225219

226220
if parameters.omp_nthreads:
227221
ecc.inputs.num_threads = parameters.omp_nthreads
@@ -290,9 +284,7 @@ def b0_average(in_dwi, in_bval, b0_thresh, out_file=None):
290284
fslroi = pe.Node(fsl.ExtractROI(t_min=0, t_size=1), name="fslroi")
291285

292286
bias_correct = pe.Node(
293-
ants.N4BiasFieldCorrection(
294-
save_bias=True, copy_header=True, dimension=3
295-
),
287+
ants.N4BiasFieldCorrection(save_bias=True, copy_header=True, dimension=3),
296288
name="bias_correct",
297289
)
298290

@@ -313,9 +305,7 @@ def get_b0_mask_fn(b0_file):
313305

314306
b0mask_node = pe.Node(
315307
niu.Function(
316-
input_names=["b0_file"],
317-
output_names=["mask_file"],
318-
function=get_b0_mask_fn,
308+
input_names=["b0_file"], output_names=["mask_file"], function=get_b0_mask_fn
319309
),
320310
name="getB0Mask",
321311
)
@@ -324,11 +314,7 @@ def get_b0_mask_fn(b0_file):
324314
[
325315
(inputnode, avg_b0_0, [("bval_file", "in_bval")]),
326316
(avg_b0_0, bet_dwi0, [("out_file", "in_file")]),
327-
(
328-
inputnode,
329-
ecc,
330-
[("bval_file", "in_bval"), ("bvec_file", "in_bvec")],
331-
),
317+
(inputnode, ecc, [("bval_file", "in_bval"), ("bvec_file", "in_bvec")]),
332318
(bet_dwi0, ecc, [("mask_file", "in_mask")]),
333319
(gen_idx, ecc, [("out_file", "in_index")]),
334320
(acqp, ecc, [("out_file", "in_acqp")]),
@@ -440,10 +426,7 @@ def get_b0_mask_fn(b0_file):
440426
(
441427
eddy_quad,
442428
outputnode,
443-
[
444-
("qc_json", "out_eddy_quad_json"),
445-
("qc_pdf", "out_eddy_quad_pdf"),
446-
],
429+
[("qc_json", "out_eddy_quad_json"), ("qc_pdf", "out_eddy_quad_pdf")],
447430
),
448431
(
449432
tensor_wf,

dmriprep/workflows/dwi/denoise.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,9 @@ def init_denoise_wf():
88

99
wf = pe.Workflow(name="denoise_wf")
1010

11-
inputnode = pe.Node(
12-
niu.IdentityInterface(fields=["dwi_file"]), name="inputnode"
13-
)
11+
inputnode = pe.Node(niu.IdentityInterface(fields=["dwi_file"]), name="inputnode")
1412

15-
outputnode = pe.Node(
16-
niu.IdentityInterface(fields=["out_file"]), name="outputnode"
17-
)
13+
outputnode = pe.Node(niu.IdentityInterface(fields=["out_file"]), name="outputnode")
1814

1915
denoise = pe.Node(mrtrix3.DWIDenoise(), name="denoise")
2016

0 commit comments

Comments
 (0)