@@ -57,6 +57,8 @@ def init_dwi_preproc_wf(
5757 else :
5858 ref_file = dwi_file
5959
60+ sdc_method = None
61+
6062 # For doc building purposes
6163 if not hasattr (layout , 'parse_file_entities' ):
6264 metadata = {
@@ -80,8 +82,18 @@ def init_dwi_preproc_wf(
8082
8183 if (use_ants and not fmaps ):
8284 fmaps .append ({'suffix' : 'ants' })
85+ sdc_method = 'nonlinear_reg'
8386 if (use_brainsuite and not fmaps ):
8487 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'
8597
8698 dwi_wf = pe .Workflow (name = wf_name )
8799
@@ -92,15 +104,6 @@ def init_dwi_preproc_wf(
92104 # synb0_dir, validate=False, derivatives=True
93105 # )
94106 # 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 )
104107
105108 dwi_sdc_wf = init_sdc_wf (
106109 subject_id ,
@@ -279,7 +282,7 @@ def b0_average(in_dwi, in_bval, b0_thresh, out_file=None):
279282 fsl .BET (frac = bet_dwi , mask = True , robust = True ), name = 'bet_dwi_pre'
280283 )
281284
282- dwi_eddy_wf = init_dwi_eddy_wf ()
285+ dwi_eddy_wf = init_dwi_eddy_wf (omp_nthreads , sdc_method )
283286
284287 # ecc = pe.Node(
285288 # fsl.Eddy(num_threads=omp_nthreads, repol=True, cnr_maps=True, residuals=True),
@@ -385,17 +388,15 @@ def get_b0_mask_fn(b0_file):
385388 # ecc.inputs.in_acqp = acqp_file
386389 # else:
387390 # Decide what ecc will take: topup or fmap
391+ # Else If epi files detected
388392 if fmaps :
389- fmaps .sort (key = lambda fmap : FMAP_PRIORITY [fmap ['suffix' ]])
390- fmap = fmaps [0 ]
391- # Else If epi files detected
392393 if fmap ['suffix' ] == 'epi' :
393394 dwi_wf .connect ([
394395 (dwi_sdc_wf , dwi_eddy_wf , [('outputnode.out_topup' , 'inputnode.topup_fieldcoef' ),
395396 ('outputnode.out_movpar' , 'inputnode.topup_movpar' )])
396397 ])
397- # Otherwise (fieldmaps)
398- else :
398+ # Otherwise (fieldmaps)
399+ if any ( s in fmap [ 'suffix' ] for s in [ 'fieldmap' , 'phasediff' , 'phase1' ]) :
399400 dwi_wf .connect ([
400401 (bet_dwi0 , dwi_sdc_wf , [('out_file' , 'inputnode.b0_stripped' )]),
401402 (dwi_sdc_wf , dwi_eddy_wf , [('outputnode.out_fmap' , 'inputnode.fieldmap_file' )])
0 commit comments