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
2aaf5fa9
Commit
2aaf5fa9
authored
6 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
RF: Fixes to support loading of multiple vertex sets and data from one gifti file
parent
99cc593f
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/gifti.py
+18
-10
18 additions, 10 deletions
fsl/data/gifti.py
with
18 additions
and
10 deletions
fsl/data/gifti.py
+
18
−
10
View file @
2aaf5fa9
...
@@ -35,13 +35,13 @@ import fsl.data.constants as constants
...
@@ -35,13 +35,13 @@ import fsl.data.constants as constants
import
fsl.data.mesh
as
fslmesh
import
fsl.data.mesh
as
fslmesh
ALLOWED_EXTENSIONS
=
[
'
.gii
'
]
ALLOWED_EXTENSIONS
=
[
'
.surf.gii
'
,
'
.gii
'
]
"""
List of file extensions that a file containing Gifti surface data
"""
List of file extensions that a file containing Gifti surface data
is expected to have.
is expected to have.
"""
"""
EXTENSION_DESCRIPTIONS
=
[
'
GIFTI file
'
]
EXTENSION_DESCRIPTIONS
=
[
'
GIFTII surface file
'
,
'
GIFTI file
'
]
"""
A description for each of the :data:`ALLOWED_EXTENSIONS`.
"""
"""
A description for each of the :data:`ALLOWED_EXTENSIONS`.
"""
...
@@ -83,8 +83,10 @@ class GiftiMesh(fslmesh.Mesh):
...
@@ -83,8 +83,10 @@ class GiftiMesh(fslmesh.Mesh):
name
=
name
,
name
=
name
,
dataSource
=
infile
)
dataSource
=
infile
)
for
v
in
vertices
:
for
i
,
v
in
enumerate
(
vertices
):
self
.
addVertices
(
v
,
infile
,
fixWinding
=
fixWinding
)
if
i
==
0
:
key
=
infile
else
:
key
=
'
{} [{}]
'
.
format
(
infile
,
i
)
self
.
addVertices
(
v
,
key
,
select
=
(
i
==
0
),
fixWinding
=
fixWinding
)
self
.
setMeta
(
infile
,
surfimg
)
self
.
setMeta
(
infile
,
surfimg
)
if
vdata
is
not
None
:
if
vdata
is
not
None
:
...
@@ -95,18 +97,21 @@ class GiftiMesh(fslmesh.Mesh):
...
@@ -95,18 +97,21 @@ class GiftiMesh(fslmesh.Mesh):
# as the specfiied one.
# as the specfiied one.
if
loadAll
:
if
loadAll
:
nvertices
=
vertices
.
shape
[
0
]
nvertices
=
vertices
[
0
]
.
shape
[
0
]
surfFiles
=
relatedFiles
(
infile
,
ALLOWED_EXTENSIONS
)
surfFiles
=
relatedFiles
(
infile
,
ALLOWED_EXTENSIONS
)
for
sfile
in
surfFiles
:
for
sfile
in
surfFiles
:
surfimg
,
vertices
,
_
=
loadGiftiMesh
(
sfile
)
try
:
surfimg
,
_
,
vertices
,
_
=
loadGiftiMesh
(
sfile
)
except
Exception
:
continue
if
vertices
.
shape
[
0
]
!=
nvertices
:
if
vertices
[
0
]
.
shape
[
0
]
!=
nvertices
:
continue
continue
self
.
addVertices
(
vertices
,
sfile
,
select
=
False
)
self
.
addVertices
(
vertices
[
0
]
,
sfile
,
select
=
False
)
self
.
setMeta
(
sfile
,
surfimg
)
self
.
setMeta
(
sfile
,
surfimg
)
def
loadVertices
(
self
,
infile
,
key
=
None
,
*
args
,
**
kwargs
):
def
loadVertices
(
self
,
infile
,
key
=
None
,
*
args
,
**
kwargs
):
...
@@ -126,7 +131,7 @@ class GiftiMesh(fslmesh.Mesh):
...
@@ -126,7 +131,7 @@ class GiftiMesh(fslmesh.Mesh):
if
key
is
None
:
if
key
is
None
:
key
=
infile
key
=
infile
surfimg
,
vertices
,
_
=
loadGiftiMesh
(
infile
)
surfimg
,
_
,
vertices
,
_
=
loadGiftiMesh
(
infile
)
vertices
=
self
.
addVertices
(
vertices
,
key
,
*
args
,
**
kwargs
)
vertices
=
self
.
addVertices
(
vertices
,
key
,
*
args
,
**
kwargs
)
...
@@ -229,6 +234,9 @@ def loadGiftiVertexData(filename):
...
@@ -229,6 +234,9 @@ def loadGiftiVertexData(filename):
def
prepareGiftiVertexData
(
darrays
,
filename
=
None
):
def
prepareGiftiVertexData
(
darrays
,
filename
=
None
):
"""
Prepares vertex data from the given list of GIFTI data arrays.
"""
Prepares vertex data from the given list of GIFTI data arrays.
All of the data arrays are concatenated into one ``(M, N)`` array,
containing ``N`` data points for ``M`` vertices.
It is assumed that the given file does not contain any
It is assumed that the given file does not contain any
``NIFTI_INTENT_POINTSET`` or ``NIFTI_INTENT_TRIANGLE`` data arrays, and
``NIFTI_INTENT_POINTSET`` or ``NIFTI_INTENT_TRIANGLE`` data arrays, and
which contains either:
which contains either:
...
...
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