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
25865a2a
Commit
25865a2a
authored
5 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
ENH: New voxToSurfMat, for generating a freesurfer affine for any image.
parent
328cd4ef
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
+27
-0
27 additions, 0 deletions
fsl/data/mghimage.py
with
27 additions
and
0 deletions
fsl/data/mghimage.py
+
27
−
0
View file @
25865a2a
...
@@ -128,3 +128,30 @@ class MGHImage(fslimage.Image):
...
@@ -128,3 +128,30 @@ class MGHImage(fslimage.Image):
coordinates into the surface coordinate system for this image.
coordinates into the surface coordinate system for this image.
"""
"""
return
self
.
__worldToSurfMat
return
self
.
__worldToSurfMat
def
voxToSurfMat
(
img
):
"""
Generate an affine which can transform the voxel coordinates of
the given image into a corresponding Freesurfer surface coordinate
system (known as
"
Torig
"
, or
"
vox2ras-tkr
"
).
See https://surfer.nmr.mgh.harvard.edu/fswiki/CoordinateSystems
:arg img: An :class:`.Image` object.
:return: A ``(4, 4)`` matrix encoding an affine transformation from the
image voxel coordinate system to the corresponding Freesurfer
surface coordinate system.
"""
zooms
=
np
.
array
(
img
.
pixdim
[:
3
])
dims
=
img
.
shape
[
:
3
]
*
zooms
/
2
xform
=
np
.
zeros
((
4
,
4
),
dtype
=
np
.
float32
)
xform
[
0
,
0
]
=
-
zooms
[
0
]
xform
[
1
,
2
]
=
zooms
[
2
]
xform
[
2
,
1
]
=
-
zooms
[
1
]
xform
[
3
,
3
]
=
1
xform
[:
3
,
3
]
=
[
dims
[
0
],
-
dims
[
2
],
dims
[
1
]]
return
xform
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