diff --git a/tests/test_gifti.py b/tests/test_gifti.py index 6d23e665e105f24e4756148ec896ea6c86436ff4..9266e86d98ee3804cdbaf3f7e3da0229270bad4f 100644 --- a/tests/test_gifti.py +++ b/tests/test_gifti.py @@ -381,3 +381,21 @@ def test_GiftiMesh_needsFixing(): surf = gifti.GiftiMesh(fname, fixWinding=True) 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) diff --git a/tests/test_mesh.py b/tests/test_mesh.py index f5ae5ead39be0dc3621a847c2083636cbf23e6a7..3a3ff94b87dd8ea5ad55423290050f2b304d5f08 100644 --- a/tests/test_mesh.py +++ b/tests/test_mesh.py @@ -234,6 +234,13 @@ def test_normals(): -fnormals, fslmesh.calcFaceNormals(verts, triangles_cw))) assert np.all(np.isclose( 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( -vnormals, fslmesh.calcVertexNormals(verts, triangles_cw, -fnormals))) assert np.all(np.isclose(