@@ -57,6 +57,8 @@ def init_dwi_preproc_wf(
57
57
else :
58
58
ref_file = dwi_file
59
59
60
+ sdc_method = None
61
+
60
62
# For doc building purposes
61
63
if not hasattr (layout , 'parse_file_entities' ):
62
64
metadata = {
@@ -80,8 +82,18 @@ def init_dwi_preproc_wf(
80
82
81
83
if (use_ants and not fmaps ):
82
84
fmaps .append ({'suffix' : 'ants' })
85
+ sdc_method = 'nonlinear_reg'
83
86
if (use_brainsuite and not fmaps ):
84
87
fmaps .append ({'suffix' : 'brainsuite' })
88
+ sdc_method = 'nonlinear_reg'
89
+
90
+ if fmaps :
91
+ fmaps .sort (key = lambda fmap : FMAP_PRIORITY [fmap ['suffix' ]])
92
+ fmap = fmaps [0 ]
93
+ if fmap ['suffix' ] == 'epi' :
94
+ sdc_method = 'topup'
95
+ if any (s in fmap ['suffix' ] for s in ['fieldmap' , 'phasediff' , 'phase1' ]):
96
+ sdc_method = 'fieldmap'
85
97
86
98
dwi_wf = pe .Workflow (name = wf_name )
87
99
@@ -92,15 +104,6 @@ def init_dwi_preproc_wf(
92
104
# synb0_dir, validate=False, derivatives=True
93
105
# )
94
106
# synb0 = synb0_layout.get(subject=subject_id, return_type='file')[0]
95
- # else:
96
- # Find fieldmaps. Options: (epi|fieldmap|phasediff|phase1|phase2|syn)
97
- fmaps = []
98
- if 'fieldmaps' not in ignore :
99
- for fmap in layout .get_fieldmap (dwi_file , return_list = True ):
100
- fmap ['metadata' ] = layout .get_metadata (
101
- fmap [fmap ['suffix' ]]
102
- )
103
- fmaps .append (fmap )
104
107
105
108
dwi_sdc_wf = init_sdc_wf (
106
109
subject_id ,
@@ -279,7 +282,7 @@ def b0_average(in_dwi, in_bval, b0_thresh, out_file=None):
279
282
fsl .BET (frac = bet_dwi , mask = True , robust = True ), name = 'bet_dwi_pre'
280
283
)
281
284
282
- dwi_eddy_wf = init_dwi_eddy_wf ()
285
+ dwi_eddy_wf = init_dwi_eddy_wf (omp_nthreads , sdc_method )
283
286
284
287
# ecc = pe.Node(
285
288
# fsl.Eddy(num_threads=omp_nthreads, repol=True, cnr_maps=True, residuals=True),
@@ -385,17 +388,15 @@ def get_b0_mask_fn(b0_file):
385
388
# ecc.inputs.in_acqp = acqp_file
386
389
# else:
387
390
# Decide what ecc will take: topup or fmap
391
+ # Else If epi files detected
388
392
if fmaps :
389
- fmaps .sort (key = lambda fmap : FMAP_PRIORITY [fmap ['suffix' ]])
390
- fmap = fmaps [0 ]
391
- # Else If epi files detected
392
393
if fmap ['suffix' ] == 'epi' :
393
394
dwi_wf .connect ([
394
395
(dwi_sdc_wf , dwi_eddy_wf , [('outputnode.out_topup' , 'inputnode.topup_fieldcoef' ),
395
396
('outputnode.out_movpar' , 'inputnode.topup_movpar' )])
396
397
])
397
- # Otherwise (fieldmaps)
398
- else :
398
+ # Otherwise (fieldmaps)
399
+ if any ( s in fmap [ 'suffix' ] for s in [ 'fieldmap' , 'phasediff' , 'phase1' ]) :
399
400
dwi_wf .connect ([
400
401
(bet_dwi0 , dwi_sdc_wf , [('out_file' , 'inputnode.b0_stripped' )]),
401
402
(dwi_sdc_wf , dwi_eddy_wf , [('outputnode.out_fmap' , 'inputnode.fieldmap_file' )])
0 commit comments