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
e66d14db
Commit
e66d14db
authored
Feb 23, 2021
by
Paul McCarthy
🚵
Browse files
TEST: Check gifti/mesh handling one triangle
parent
72c14d23
Changes
2
Hide whitespace changes
Inline
Side-by-side
tests/test_gifti.py
View file @
e66d14db
...
@@ -381,3 +381,21 @@ def test_GiftiMesh_needsFixing():
...
@@ -381,3 +381,21 @@ def test_GiftiMesh_needsFixing():
surf
=
gifti
.
GiftiMesh
(
fname
,
fixWinding
=
True
)
surf
=
gifti
.
GiftiMesh
(
fname
,
fixWinding
=
True
)
assert
np
.
all
(
np
.
isclose
(
surf
.
indices
,
idxs_fixed
))
assert
np
.
all
(
np
.
isclose
(
surf
.
indices
,
idxs_fixed
))
def
test_loadGiftiMesh_onetriangle
():
verts
=
np
.
array
([[
0
,
0
,
0
],
[
1
,
1
,
1
],
[
0
,
1
,
0
]])
idxs
=
np
.
array
([[
0
,
1
,
2
]])
verts
=
nib
.
gifti
.
GiftiDataArray
(
verts
,
intent
=
'NIFTI_INTENT_POINTSET'
)
idxs
=
nib
.
gifti
.
GiftiDataArray
(
idxs
,
intent
=
'NIFTI_INTENT_TRIANGLE'
)
gimg
=
nib
.
gifti
.
GiftiImage
(
darrays
=
[
verts
,
idxs
])
with
tempdir
():
fname
=
op
.
abspath
(
'test.gii'
)
gimg
.
to_filename
(
fname
)
gimg
,
tris
,
verts
,
_
=
gifti
.
loadGiftiMesh
(
'test.gii'
)
verts
=
verts
[
0
]
assert
verts
.
shape
==
(
3
,
3
)
assert
tris
.
shape
==
(
1
,
3
)
tests/test_mesh.py
View file @
e66d14db
...
@@ -234,6 +234,13 @@ def test_normals():
...
@@ -234,6 +234,13 @@ def test_normals():
-
fnormals
,
fslmesh
.
calcFaceNormals
(
verts
,
triangles_cw
)))
-
fnormals
,
fslmesh
.
calcFaceNormals
(
verts
,
triangles_cw
)))
assert
np
.
all
(
np
.
isclose
(
assert
np
.
all
(
np
.
isclose
(
fnormals
,
fslmesh
.
calcFaceNormals
(
verts
,
triangles_ccw
)))
fnormals
,
fslmesh
.
calcFaceNormals
(
verts
,
triangles_ccw
)))
# Make sure result is (1, 3) for input of (1, 3)
onetri
=
np
.
atleast_2d
(
triangles_ccw
[
0
,
:])
result
=
fslmesh
.
calcFaceNormals
(
verts
,
onetri
)
assert
result
.
shape
==
(
1
,
3
)
assert
np
.
all
(
np
.
isclose
(
fnormals
[
0
,
:],
result
))
assert
np
.
all
(
np
.
isclose
(
assert
np
.
all
(
np
.
isclose
(
-
vnormals
,
fslmesh
.
calcVertexNormals
(
verts
,
triangles_cw
,
-
fnormals
)))
-
vnormals
,
fslmesh
.
calcVertexNormals
(
verts
,
triangles_cw
,
-
fnormals
)))
assert
np
.
all
(
np
.
isclose
(
assert
np
.
all
(
np
.
isclose
(
...
...
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