Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FSL
fslpy
Commits
a127f656
Commit
a127f656
authored
5 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
BF: MGH imagesmay have zooms which don't match their vox2ras affine - make
sure the MGHImage class preserves this.
parent
25865a2a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fsl/data/mghimage.py
+22
-3
22 additions, 3 deletions
fsl/data/mghimage.py
with
22 additions
and
3 deletions
fsl/data/mghimage.py
+
22
−
3
View file @
a127f656
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment