8000 ENH: Add get/set_zooms(units='norm') to manipulate zooms in mm/s units by effigies · Pull Request #567 · nipy/nibabel · GitHub
[go: up one dir, main page]

Skip to content

ENH: Add get/set_zooms(units='norm') to manipulate zooms in mm/s units #567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3f3b450
ENH: Add get_norm_zooms for zooms in mm/s units
effigies Oct 24, 2017
d26acfb
ENH: Add get_norm_zooms for MGHHeader
effigies Dec 18, 2017
de9323c
ENH: Add set_norm_zooms
effigies Dec 21, 2017
5c30366
FIX: Various unit issues
effigies Dec 21, 2017
4b86d3e
TEST: Test get/set_norm_zooms
effigies Dec 21, 2017
eb1d8ff
TEST: Fix warnings
effigies Dec 21, 2017
6ba8b66
RF: get_norm_zooms -> get_zooms(units="canonical")
effigies Jan 12, 2018
1357a3b
TEST: Update get_zooms tests
effigies Jan 13, 2018
096da88
FIX: Set default t_code even if no t_zoom
effigies Jan 13, 2018
798fc4e
TEST: Add units specification to tests
effigies Feb 19, 2018
f31aba5
TEST: Add setup/teardown to try to catch warnings properly [WIP]
effigies Feb 19, 2018
27234c3
TEST: Try using clear_and_catch_warnings
effigies Feb 19, 2018
8899bc7
RF: Add units parameter to set_zooms
effigies Mar 12, 2018
da54665
TEST: More complete zoom testing, revert unnecessary change
effigies Mar 12, 2018
1620f31
TEST: Improve warning filters, check set_zooms behavior more thoroughly
effigies Mar 12, 2018
5d96f5c
TEST: Explicitly test non-temporal t_units during set_zooms(units="no…
effigies Mar 12, 2018
233f7f0
TEST: Filter warnings for unmodified superclass tests only
effigies Mar 12, 2018
4babf08
ENH: Add units/raise_unknown to MINC/ECAT get_zooms
effigies Mar 12, 2018
6cd83f7
ENH: Validate units parameter in all get/set_zooms
effigies Mar 13, 2018
94cbd0d
FIX: Correct and simplify NIFTI logic
effigies Mar 14, 2018
cfc5abe
TEST: Clear nifti1 module warnings
effigies Mar 20, 2018
3562921
TEST: Check edge cases
effigies Mar 20, 2018
d9199ca
TEST: Add unit to bad set_zoom call
effigies Mar 20, 2018
98e43a0
TEST: Check get_zooms units arg in MINC/ECAT
effigies Mar 20, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
TEST: Clear nifti1 module warnings
  • Loading branch information
effigies committed Dec 27, 2022
commit cfc5abe65c032ef70938e14a9d6966b04cf02cf6
18 changes: 9 additions & 9 deletions nibabel/tests/test_nifti1.py
8000
Original file line number Diff line number Diff line change
Expand Up @@ -719,23 +719,23 @@ def test_recoded_fields(self):
assert hdr.get_value_label('slice_code') == 'alternating decreasing'

def test_general_init(self):
with clear_and_catch_warnings() as warns:
with clear_and_catch_warnings(modules=(nifti1,)) as warns:
warnings.filterwarnings('ignore', 'get_zooms', FutureWarning)
warnings.filterwarnings('ignore', 'set_zooms', FutureWarning)
warnings.filterwarnings('ignore', 'Unknown (spatial|time) units',
UserWarning)
super(TestNifti1PairHeader, self).test_general_init()

def test_from_header(self):
with clear_and_catch_warnings() as warns:
with clear_and_catch_warnings(modules=(nifti1,)) as warns:
warnings.filterwarnings('ignore', 'get_zooms', FutureWarning)
warnings.filterwarnings('ignore', 'set_zooms', FutureWarning)
warnings.filterwarnings('ignore', 'Unknown (spatial|time) units',
UserWarning)
super(TestNifti1PairHeader, self).test_from_header()

def test_data_shape_zooms_affine(self):
with clear_and_catch_warnings() as warns:
with clear_and_catch_warnings(modules=(nifti1,)) as warns:
warnings.filterwarnings('ignore', 'get_zooms', FutureWarning)
warnings.filterwarnings('ignore', 'set_zooms', FutureWarning)
warnings.filterwarnings('ignore', 'Unknown (spatial|time) units',
Expand Down Expand Up @@ -1207,7 +1207,7 @@ def test_zooms_edge_cases(self):
img = img_klass(arr, aff)

# Unknown units = 2 warnings
with clear_and_catch_warnings() as warns:
with clear_and_catch_warnings(modules=(nifti1,)) as warns:
warnings.simplefilter('always')
assert_array_almost_equal(img.header.get_zooms(units='norm'),
(1, 1, 1, 1))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unclear to me why (in Python 2 only) this is failing to raise warnings.

Expand All @@ -1216,7 +1216,7 @@ def test_zooms_edge_cases(self):
units='norm', raise_unknown=True)

img.header.set_xyzt_units(xyz='meter')
with clear_and_catch_warnings() as warns:
with clear_and_catch_warnings(modules=(nifti1,)) as warns:
warnings.simplefilter('always')
assert_array_almost_equal(img.header.get_zooms(units='norm'),
(1000, 1000, 1000, 1))
Expand All @@ -1232,7 +1232,7 @@ def test_zooms_edge_cases(self):
(0.001, 0.001, 0.001, 1))

img.header.set_xyzt_units(t='sec')
with clear_and_catch_warnings() as warns:
with clear_and_catch_warnings(modules=(nifti1,)) as warns:
warnings.simplefilter('always')
assert_array_equal(img.header.get_zooms(units='norm'),
(1, 1, 1, 1))
Expand Down Expand Up @@ -1277,7 +1277,7 @@ def test_zooms_edge_cases(self):

# Non-temporal t units are not transformed
img.header.set_zooms((1, 1, 1, 1.5), units=('mm', 'ppm'))
with clear_and_catch_warnings() as warns:
with clear_and_catch_warnings(modules=(nifti1,)) as warns:
warnings.simplefilter('always')
assert_array_almost_equal(img.header.get_zooms(units='norm'),
(1, 1, 1, 1.5))
Expand All @@ -1287,7 +1287,7 @@ def test_zooms_edge_cases(self):

# Non-temporal t units are not normalized
img.header.set_zooms((2, 2, 2, 3.5), units='norm')
with clear_and_catch_warnings() as warns:
with clear_and_catch_warnings(modules=(nifti1,)) as warns:
warnings.simplefilter('always')
assert_array_almost_equal(img.header.get_zooms(units='norm'),
(2, 2, 2, 3.5))
Expand All @@ -1310,7 +1310,7 @@ def test_zooms_edge_cases(self):
units='badparam')

def test_no_finite_values(self):
with clear_and_catch_warnings() as warns:
with clear_and_catch_warnings(modules=(nifti1,)) as warns:
warnings.filterwarnings('ignore', 'get_zooms', FutureWarning)
warnings.filterwarnings('ignore', 'set_zooms', FutureWarning)
warnings.filterwarnings('ignore', 'Unknown (spatial|time) units',
Expand Down
0