Skip to content

Commit 0086c3d

Browse files
committed
Subtract phases before unwrapping
1 parent 6b6ef2a commit 0086c3d

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
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: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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)