Skip to content

Commit 8896975

Browse files
committed
fix eddy and fmap branching
1 parent 3a54270 commit 8896975

File tree

4 files changed

+22
-18
lines changed

4 files changed

+22
-18
lines changed

dmriprep/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def main(
178178
omp_nthreads,
179179
ignore,
180180
use_ants,
181-
use_syn,
181+
use_brainsuite,
182182
work_dir,
183183
synb0_dir,
184184
write_graph

dmriprep/workflows/dwi/base.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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')])

dmriprep/workflows/fieldmap/base.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ def init_sdc_wf(
6363
# )
6464
# else:
6565
fmaps.sort(key=lambda fmap: FMAP_PRIORITY[fmap['suffix']])
66-
fmap = fmaps[0]
66+
try:
67+
fmap = fmaps[0]
68+
except:
69+
return
6770

6871
if fmap['suffix'] == 'epi':
6972
from .pepolar import init_pepolar_wf

dmriprep/workflows/fieldmap/brainsuite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def init_brainsuite_wf():
2828
name='inputnode')
2929

3030
outputnode = pe.Node(
31-
niu.IdentityInterface(fields=['out_fmap']), name='outputnode'
31+
niu.IdentityInterface(fields=['out_dwi']), name='outputnode'
3232
)
3333

3434
bias_corr = pe.Node(brainsuite.Bfc(minBias=0.5, maxBias=1.5), name='bias_corr')

0 commit comments

Comments
 (0)