Skip to content

Commit 03ce021

Browse files
authored
Merge pull request #70 from AKSoo/subtractfirst
ENH: Phase1/2 - subtract phases before unwrapping
2 parents 21c8d9b + 87bd64d commit 03ce021

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

sdcflows/interfaces/fmap.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,10 @@ def _subtract_phases(in_phases, in_meta, newpath=None):
706706
sub_data = in_phases_nii[1].get_fdata(dtype='float32') - \
707707
in_phases_nii[0].get_fdata(dtype='float32')
708708

709+
# wrap negative radians back to [0, 2pi]
710+
sub_data[sub_data < 0] += 2 * np.pi
711+
sub_data = np.clip(sub_data, 0.0, 2 * np.pi)
712+
709713
new_meta = in_meta[1].copy()
710714
new_meta.update(in_meta[0])
711715
new_meta['EchoTime1'] = echo_times[0]

sdcflows/workflows/phdiff.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def init_phdiff_wf(omp_nthreads, name='phdiff_wf'):
105105
phmap2rads = pe.MapNode(PhaseMap2rads(), name='phmap2rads',
106106
iterfield=['in_file'], run_without_submitting=True)
107107
# FSL PRELUDE will perform phase-unwrapping
108-
prelude = pe.MapNode(fsl.PRELUDE(), iterfield=['phase_file'], name='prelude')
108+
prelude = pe.Node(fsl.PRELUDE(), name='prelude')
109109

110110
calc_phdiff = pe.Node(SubtractPhases(), name='calc_phdiff',
111111
run_without_submitting=True)
@@ -120,12 +120,11 @@ def init_phdiff_wf(omp_nthreads, name='phdiff_wf'):
120120
(magnitude_wf, prelude, [('outputnode.fmap_ref', 'magnitude_file'),
121121
('outputnode.fmap_mask', 'mask_file')]),
122122
(split, phmap2rads, [('map_file', 'in_file')]),
123-
(phmap2rads, prelude, [('out_file', 'phase_file')]),
124-
(prelude, calc_phdiff, [('unwrapped_phase_file', 'in_phases')]),
123+
(phmap2rads, calc_phdiff, [('out_file', 'in_phases')]),
125124
(split, calc_phdiff, [('meta', 'in_meta')]),
126-
(calc_phdiff, fmap_postproc_wf, [
127-
('phase_diff', 'inputnode.fmap'),
128-
('metadata', 'inputnode.metadata')]),
125+
(calc_phdiff, prelude, [('phase_diff', 'phase_file')]),
126+
(prelude, fmap_postproc_wf, [('unwrapped_phase_file', 'inputnode.fmap')]),
127+
(calc_phdiff, fmap_postproc_wf, [('metadata', 'inputnode.metadata')]),
129128
(magnitude_wf, fmap_postproc_wf, [
130129
('outputnode.fmap_mask', 'inputnode.fmap_mask'),
131130
('outputnode.fmap_ref', 'inputnode.fmap_ref')]),

0 commit comments

Comments
 (0)