Skip to content

ENH: Add NIFTI_XFORM_TEMPLATE_OTHER xform code #743

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

Merged
merged 1 commit into from
Mar 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion nibabel/nifti1.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@
(1, 'scanner', "NIFTI_XFORM_SCANNER_ANAT"),
(2, 'aligned', "NIFTI_XFORM_ALIGNED_ANAT"),
(3, 'talairach', "NIFTI_XFORM_TALAIRACH"),
(4, 'mni', "NIFTI_XFORM_MNI_152")), fields=('code', 'label', 'niistring'))
(4, 'mni', "NIFTI_XFORM_MNI_152"),
(5, 'template', "NIFTI_XFORM_TEMPLATE_OTHER"),
), fields=('code', 'label', 'niistring'))

# unit codes
unit_codes = Recoder(( # code, label
Expand Down
15 changes: 15 additions & 0 deletions nibabel/tests/test_nifti1.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,21 @@ def test_nifti_qsform_checks(self):
assert_equal(message,
'sform_code -1 not valid; setting to 0')

def test_nifti_xform_codes(self):
# Verify that all xform codes can be set in both qform and sform
hdr = self.header_class()
affine = np.eye(4)
for code in nifti1.xform_codes.keys():
hdr.set_qform(affine, code)
assert_equal(hdr['qform_code'], nifti1.xform_codes[code])
hdr.set_sform(affine, code)
assert_equal(hdr['sform_code'], nifti1.xform_codes[code])

# Raise KeyError on unknown code
for bad_code in (-1, 6, 10):
assert_raises(KeyError, hdr.set_qform, affine, bad_code)
assert_raises(KeyError, hdr.set_sform, affine, bad_code)

def test_magic_offset_checks(self):
# magic and offset
HC = self.header_class
Expand Down