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
0431b85c
Commit
0431b85c
authored
7 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Additions to freesurfer module - can now load vertex data.
parent
28cde67e
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/freesurfer.py
+46
-10
46 additions, 10 deletions
fsl/data/freesurfer.py
with
46 additions
and
10 deletions
fsl/data/freesurfer.py
+
46
−
10
View file @
0431b85c
...
...
@@ -20,10 +20,11 @@ The following functions are also available:
import
os.path
as
op
import
glob
import
nibabel
as
nib
import
nibabel
.freesurfer
as
nib
fs
import
fsl.utils.path
as
fslpath
import
fsl.data.mesh
as
fslmesh
import
fsl.utils.path
as
fslpath
import
fsl.data.mghimage
as
fslmgh
import
fsl.data.mesh
as
fslmesh
GEOMETRY_EXTENSIONS
=
[
'
.pial
'
,
...
...
@@ -45,8 +46,14 @@ EXTENSION_DESCRIPTIONS = [
"""
A description for each extension in :attr:`GEOMETRY_EXTENSIONS`.
"""
VERTEX_DATA_EXTENSIONS
=
[
''
]
VERTEX_DATA_EXTENSIONS
=
[
'
.curv
'
,
'
.crv
'
,
'
.area
'
,
'
.thickness
'
,
'
.volume
'
,
'
.mgh
'
,
'
.mgz
'
]
"""
File extensions which are interpreted as Freesurfer vertex data files.
"""
class
FreesurferMesh
(
fslmesh
.
Mesh
):
...
...
@@ -68,7 +75,7 @@ class FreesurferMesh(fslmesh.Mesh):
loaded as additional vertex sets.
"""
vertices
,
indices
,
meta
,
comment
=
nib
.
freesurfer
.
read_geometry
(
vertices
,
indices
,
meta
,
comment
=
nib
fs
.
read_geometry
(
filename
,
read_metadata
=
True
,
read_stamp
=
True
)
...
...
@@ -93,18 +100,47 @@ class FreesurferMesh(fslmesh.Mesh):
allFiles
=
relatedFiles
(
filename
,
ftypes
=
GEOMETRY_EXTENSIONS
)
for
f
in
allFiles
:
verts
,
idxs
=
nib
.
freesurfer
.
read_geometry
(
f
)
verts
,
idxs
=
nib
fs
.
read_geometry
(
f
)
self
.
addVertices
(
verts
,
f
,
select
=
False
)
def
loadVertexData
(
self
,
infile
,
key
=
None
):
"""
Overrides :meth:`.Mesh.loadVertexData`. If the given ``infile``
looks like a Freesurfer file, it is loaded via the
:func:`loadFreesurferVertexFile` function. Otherwise, it is passed
through to the base-class function.
"""
"""
pass
if
not
fslpath
.
hasExt
(
infile
,
VERTEX_DATA_EXTENSIONS
):
return
fslmesh
.
loadVertexData
(
infile
,
key
)
infile
=
op
.
abspath
(
infile
)
if
key
is
None
:
key
=
infile
vdata
=
loadFreesurferVertexFile
(
infile
)
self
.
addVertexData
(
key
,
vdata
)
return
vdata
def
loadFreesurferVertexFile
(
infile
):
pass
"""
Loads the given Freesurfer file, assumed to contain vertex-wise data.
"""
# morphometry file
morphexts
=
[
'
.curv
'
,
'
.crv
'
,
'
.area
'
,
'
.thickness
'
,
'
.volume
'
]
if
fslpath
.
hasExt
(
infile
,
morphexts
):
vdata
=
nibfs
.
read_morph_data
(
infile
)
# MGH image file
elif
fslpath
.
hasExt
(
infile
,
fslmgh
.
ALLOWED_EXTENSIONS
):
vdata
=
fslmgh
.
MGHImage
(
infile
)[:].
squeeze
()
return
vdata
def
relatedFiles
(
fname
,
ftypes
=
None
):
...
...
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