Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Michiel Cottaar
fslpy
Commits
1b7dee30
Commit
1b7dee30
authored
7 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Added extra properties to MGHImage giving access to surface coordinate system
affines
parent
495d8629
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
+45
-9
45 additions, 9 deletions
fsl/data/mghimage.py
with
45 additions
and
9 deletions
fsl/data/mghimage.py
+
45
−
9
View file @
1b7dee30
...
...
@@ -6,11 +6,6 @@
#
"""
This module provides the :class:`MGHImage` class, which can be used to load
Freesurfer ``mgh``/``mgz`` image files.
.. autosummary::
:nosignatures:
looksLikeMGHImage
"""
...
...
@@ -19,8 +14,9 @@ import os.path as op
import
six
import
nibabel
as
nib
import
fsl.utils.path
as
fslpath
import
fsl.data.image
as
fslimage
import
fsl.utils.path
as
fslpath
import
fsl.utils.transform
as
transform
import
fsl.data.image
as
fslimage
ALLOWED_EXTENSIONS
=
[
'
.mgz
'
,
'
.mgh
'
]
...
...
@@ -58,8 +54,9 @@ class MGHImage(fslimage.Image):
name
=
'
MGH image
'
filename
=
None
data
=
image
.
get_data
()
affine
=
image
.
affine
data
=
image
.
get_data
()
affine
=
image
.
affine
vox2surf
=
image
.
header
.
get_vox2ras_tkr
()
fslimage
.
Image
.
__init__
(
self
,
data
,
...
...
@@ -70,6 +67,11 @@ class MGHImage(fslimage.Image):
if
filename
is
not
None
:
self
.
setMeta
(
'
mghImageFile
'
,
filename
)
self
.
__voxToSurfMat
=
vox2surf
self
.
__surfToVoxMat
=
transform
.
invert
(
vox2surf
)
self
.
__surfToWorldMat
=
transform
.
concat
(
affine
,
self
.
__surfToVoxMat
)
self
.
__worldToSurfMat
=
transform
.
invert
(
self
.
__surfToWorldMat
)
def
save
(
self
,
filename
=
None
):
"""
Overrides :meth:`.Image.save`. If a ``filename`` is not provided,
...
...
@@ -90,3 +92,37 @@ class MGHImage(fslimage.Image):
name. Otherwise returns ``None``.
"""
return
self
.
getMeta
(
'
mghImageFile
'
,
None
)
@property
def
voxToSurfMat
(
self
):
"""
Returns an affine which can be used to transform voxel
coordinates into the surface coordinate system for this image.
See: https://surfer.nmr.mgh.harvard.edu/fswiki/CoordinateSystems
"""
return
self
.
__voxToSurfMat
@property
def
surfToVoxMat
(
self
):
"""
Returns an affine which can be used to transform surface
coordinates into the voxel coordinate system for this image.
"""
return
self
.
__surfToVoxMat
@property
def
surfToWorldMat
(
self
):
"""
Returns an affine which can be used to transform surface
coordinates into the world coordinate system for this image.
"""
return
self
.
__surfToWorldMat
@property
def
worldToSurfMat
(
self
):
"""
Returns an affine which can be used to transform world
coordinates into the surface coordinate system for this image.
"""
return
self
.
__worldToSurfMat
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