-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX: Convert SEI fieldmaps given in rad/s into Hz
Adds a lightweight node (`run_without_submitting=True`) wrapping an interface that just checks the units of the input image and divides by 2pi when units are rad/s. Unfortunatelly, we don't currently have data to test these fieldmaps in some integration/smoke test. Resolves: #124.
- Loading branch information
Showing
3 changed files
with
66 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"""Test fieldmap interfaces.""" | ||
import numpy as np | ||
import nibabel as nb | ||
import pytest | ||
|
||
from ..fmap import CheckB0Units | ||
|
||
|
||
@pytest.mark.parametrize("units", ("rad/s", "Hz")) | ||
def test_units(tmpdir, units): | ||
"""Check the conversion of units.""" | ||
tmpdir.chdir() | ||
hz = np.ones((5, 5, 5), dtype="float32") * 100 | ||
data = hz.copy() | ||
|
||
if units == "rad/s": | ||
data *= 2.0 * np.pi | ||
|
||
nb.Nifti1Image(data, np.eye(4), None).to_filename("data.nii.gz") | ||
out_data = nb.load( | ||
CheckB0Units(units=units, in_file="data.nii.gz").run().outputs.out_file | ||
).get_fdata(dtype="float32") | ||
|
||
assert np.allclose(hz, out_data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters