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
FSL
fslpy
Commits
276c2695
Commit
276c2695
authored
Jan 28, 2020
by
Paul McCarthy
🚵
Browse files
BF: MGH imagesmay have zooms which don't match their vox2ras affine - make
sure the MGHImage class preserves this.
parent
d3f83647
Changes
1
Hide whitespace changes
Inline
Side-by-side
fsl/data/mghimage.py
View file @
276c2695
...
...
@@ -38,7 +38,7 @@ class MGHImage(fslimage.Image):
- http://nipy.org/nibabel/reference/nibabel.freesurfer.html
"""
def
__init__
(
self
,
image
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
image
,
**
kwargs
):
"""Create a ``MGHImage``.
:arg image: Name of MGH file, or a
...
...
@@ -57,13 +57,32 @@ class MGHImage(fslimage.Image):
data
=
np
.
asanyarray
(
image
.
dataobj
)
xform
=
image
.
affine
pixdim
=
image
.
header
.
get_zooms
()
vox2surf
=
image
.
header
.
get_vox2ras_tkr
()
# the image may have an affine which
# transforms the data into some space
# with a scaling that is different to
# the pixdims. So we create a header
# object with both the affine and the
# pixdims, so they are both preserved.
#
# Note that we have to set the zooms
# after the s/qform, otherwise nibabel
# will clobber them with zooms gleaned
# fron the affine.
header
=
nib
.
nifti1
.
Nifti1Header
()
header
.
set_data_shape
(
data
.
shape
)
header
.
set_sform
(
xform
)
header
.
set_qform
(
xform
)
header
.
set_zooms
(
pixdim
)
fslimage
.
Image
.
__init__
(
self
,
data
,
xform
=
xform
,
header
=
header
,
name
=
name
,
dataSource
=
filename
)
dataSource
=
filename
,
**
kwargs
)
if
filename
is
not
None
:
self
.
setMeta
(
'mghImageFile'
,
filename
)
...
...
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