Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
FSL
fslpy
Commits
66eb47f4
Commit
66eb47f4
authored
Jan 23, 2018
by
Paul McCarthy
🚵
Browse files
Freesurfer checks label and stats directories for vertex data
files. Adjustment to gifti.relatedFiles.
parent
f8a52e27
Changes
2
Hide whitespace changes
Inline
Side-by-side
fsl/data/freesurfer.py
View file @
66eb47f4
...
...
@@ -93,7 +93,6 @@ VERTEX_DATA_FILES = ['?h.thickness',
'?h.curv'
,
'?h.area'
,
'?h.sulc'
,
'?h.*.stats'
,
'.mgh'
,
'.mgz'
]
"""File patterns which are interpreted as Freesurfer vertex data files,
...
...
@@ -225,7 +224,7 @@ class FreesurferMesh(fslmesh.Mesh):
self
.
addVertexData
(
key
,
vdata
)
if
isv
label
:
if
isv
annot
:
self
.
__luts
[
key
]
=
lut
,
names
,
lut
return
vdata
...
...
@@ -368,9 +367,20 @@ def relatedVertexDataFiles(fname):
fpats
=
VERTEX_DATA_FILES
+
VERTEX_LABEL_FILES
+
VERTEX_ANNOT_FILES
fpats
=
[
hemi
+
p
[
1
:]
if
p
.
startswith
(
'?h'
)
else
p
for
p
in
fpats
]
related
=
[
glob
.
glob
(
op
.
join
(
dirname
,
p
))
for
p
in
fpats
]
basedir
=
op
.
dirname
(
dirname
)
searchDirs
=
set
([
dirname
,
op
.
join
(
basedir
,
'surf'
),
op
.
join
(
basedir
,
'stats'
),
op
.
join
(
basedir
,
'label'
)])
searchPats
=
it
.
product
(
searchDirs
,
fpats
)
related
=
[]
for
sdir
,
spat
in
searchPats
:
related
.
extend
(
glob
.
glob
(
op
.
join
(
sdir
,
spat
)))
return
list
(
it
.
chain
(
*
related
))
return
related
def
findReferenceImage
(
fname
):
...
...
fsl/data/gifti.py
View file @
66eb47f4
...
...
@@ -77,6 +77,7 @@ class GiftiMesh(fslmesh.Mesh):
surfimg
,
vertices
,
indices
=
loadGiftiMesh
(
infile
)
fslmesh
.
Mesh
.
__init__
(
self
,
indices
,
name
=
name
,
...
...
@@ -278,35 +279,35 @@ def relatedFiles(fname, ftypes=None):
# directory which have the following name:
#
# [
prefix
].*[ftype]
# [
subj].[hemi].[type
].*
.
[ftype]
#
# where
# - prefix is the file prefix, and which
# may include periods.
# - [subj] is the subject ID, and matches fname
#
# -
we don't ca
re a
bout the middl
e
# -
[hemi] is the hemisphe
re
,
a
nd matches fnam
e
#
# -
suffix is func, shape, label, time, or `ftype`
# -
[type] defines the file contents
#
# - suffix is func, shape, label, time, or `ftype`
# We determine the unique prefix of the
# given file, and back-up to the most
# recent period. Then search for other
# files which have that same (non-unique)
# prefix.
prefix
=
fslpath
.
uniquePrefix
(
fname
)
lastdot
=
prefix
.
rfind
(
'.'
)
prefix
=
prefix
[:
lastdot
]
path
=
op
.
abspath
(
fname
)
dirname
,
fname
=
op
.
split
(
path
)
if
lastdot
==
-
1
:
# get the [subj].[hemi] prefix
try
:
subj
,
hemi
,
_
=
fname
.
split
(
'.'
,
2
)
prefix
=
'.'
.
join
((
subj
,
hemi
))
except
Exception
:
return
[]
related
=
[]
for
ftype
in
ftypes
:
related
+=
list
(
glob
.
glob
(
'{}*{}'
.
format
(
prefix
,
ftype
)))
related
.
extend
(
glob
.
glob
(
op
.
join
(
dirname
,
'{}*{}'
.
format
(
prefix
,
ftype
))))
return
[
r
for
r
in
related
if
r
!=
fname
]
return
[
r
for
r
in
related
if
r
!=
path
]
class
GiftiSurface
(
fslmesh
.
TriangleMesh
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment