Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Michiel Cottaar
fslpy
Commits
d635bdae
Commit
d635bdae
authored
Nov 07, 2017
by
Paul McCarthy
🚵
Browse files
If an xform and header are provided, make sure they are consistent.
parent
7b9768fa
Changes
1
Hide whitespace changes
Inline
Side-by-side
fsl/data/image.py
View file @
d635bdae
...
...
@@ -753,7 +753,9 @@ class Image(Nifti):
coordinates. If not provided, and a ``header`` is
provided, the transformation in the header is used.
If neither a ``xform`` nor a ``header`` are provided,
an identity matrix is used.
an identity matrix is used. If both a ``xform`` and a
``header`` are provided, the ``xform`` is used in
preference to the header transformation.
:arg loadData: If ``True`` (the default) the image data is loaded
in to memory. Otherwise, only the image header
...
...
@@ -799,6 +801,17 @@ class Image(Nifti):
if
header
is
not
None
:
header
=
header
.
copy
()
# if a header and xform are provided,
# make sure the xform gets used. Does
# not apply to ANALYZE images,
if
header
is
not
None
and
\
xform
is
not
None
and
\
isinstance
(
header
,
nib
.
nifti1
.
Nifti1Header
):
sform
=
int
(
header
.
get_sform
(
True
)[
1
])
qform
=
int
(
header
.
get_qform
(
True
)[
1
])
header
.
set_sform
(
xform
,
code
=
sform
)
header
.
set_qform
(
xform
,
code
=
qform
)
# The image parameter may be the name of an image file
if
isinstance
(
image
,
six
.
string_types
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment