4
4
Orchestrating the dwi preprocessing workflows
5
5
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6
6
7
- .. autofunction:: init_dwi_preproc_wf
8
-
9
7
"""
10
8
11
9
from bids import BIDSLayout
@@ -93,6 +91,14 @@ def init_dwi_preproc_wf(subject_id, dwi_file, metadata, parameters):
93
91
name = "outputnode" ,
94
92
)
95
93
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
+
96
102
def gen_index (in_file ):
97
103
import os
98
104
import numpy as np
@@ -101,10 +107,7 @@ def gen_index(in_file):
101
107
from nipype .utils .filemanip import fname_presuffix
102
108
103
109
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
108
111
)
109
112
vols = nib .load (in_file , mmap = NUMPY_MMAP ).get_data ().shape [- 1 ]
110
113
index_lines = np .ones ((vols ,))
@@ -114,9 +117,7 @@ def gen_index(in_file):
114
117
115
118
gen_idx = pe .Node (
116
119
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
120
121
),
121
122
name = "gen_index" ,
122
123
)
@@ -162,11 +163,7 @@ def gen_acqparams(in_file, metadata):
162
163
dwi_wf .connect (
163
164
[
164
165
(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" )]),
170
167
]
171
168
)
172
169
@@ -215,13 +212,10 @@ def b0_average(in_dwi, in_bval, b0_thresh, out_file=None):
215
212
avg_b0_0 .inputs .b0_thresh = parameters .b0_thresh
216
213
217
214
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"
220
216
)
221
217
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" )
225
219
226
220
if parameters .omp_nthreads :
227
221
ecc .inputs .num_threads = parameters .omp_nthreads
@@ -290,9 +284,7 @@ def b0_average(in_dwi, in_bval, b0_thresh, out_file=None):
290
284
fslroi = pe .Node (fsl .ExtractROI (t_min = 0 , t_size = 1 ), name = "fslroi" )
291
285
292
286
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 ),
296
288
name = "bias_correct" ,
297
289
)
298
290
@@ -313,9 +305,7 @@ def get_b0_mask_fn(b0_file):
313
305
314
306
b0mask_node = pe .Node (
315
307
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
319
309
),
320
310
name = "getB0Mask" ,
321
311
)
@@ -324,11 +314,7 @@ def get_b0_mask_fn(b0_file):
324
314
[
325
315
(inputnode , avg_b0_0 , [("bval_file" , "in_bval" )]),
326
316
(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" )]),
332
318
(bet_dwi0 , ecc , [("mask_file" , "in_mask" )]),
333
319
(gen_idx , ecc , [("out_file" , "in_index" )]),
334
320
(acqp , ecc , [("out_file" , "in_acqp" )]),
@@ -440,10 +426,7 @@ def get_b0_mask_fn(b0_file):
440
426
(
441
427
eddy_quad ,
442
428
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" )],
447
430
),
448
431
(
449
432
tensor_wf ,
0 commit comments