Skip to content

Commit d090cfc

Browse files
committed
NF: Write capabilities for freesurfer triangle files
Validate byte order and that user timestamp is written properly
1 parent 36bf5b7 commit d090cfc

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

nibabel/freesurfer/tests/test_io.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,28 @@ def test_geometry():
4444
ntf.close()
4545

4646
surf_path = ntf.name
47-
write_geometry(surf_path, create_stamp, coords, faces)
47+
create_stamp = "created by %s on %s" % (os.getlogin(), time.ctime())
48+
write_geometry(surf_path, coords, faces, create_stamp)
4849

4950
coords2, faces2 = read_geometry(surf_path)
5051

52+
with open(surf_path,'rb') as fobj:
53+
magic = np.fromfile(fobj, ">u1", 3)
54+
read_create_stamp = fobj.readline().rstrip('\n')
55+
5156
# Remove temporary file
5257
os.unlink(surf_path)
5358

54-
assert_equal(coords, coords2)
55-
assert_equal(faces, faces2)
59+
assert_equal(create_stamp, read_create_stamp)
60+
61+
np.testing.assert_array_equal(coords, coords2)
62+
np.testing.assert_array_equal(faces, faces2)
63+
64+
# Validate byte ordering
65+
coords_swapped = coords.byteswap().newbyteorder()
66+
faces_swapped = faces.byteswap().newbyteorder()
67+
np.testing.assert_array_equal(coords_swapped, coords)
68+
np.testing.assert_array_equal(faces_swapped, faces)
5669

5770
@freesurfer_test
5871
def test_morph_data():

0 commit comments

Comments
 (0)