File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change 1
1
from __future__ import with_statement
2
2
3
3
import numpy as np
4
-
4
+ import os
5
+ import time
5
6
6
7
def _fread3 (fobj ):
7
8
"""Read a 3-byte int from an open binary file object
@@ -92,21 +93,25 @@ def read_geometry(filepath):
92
93
coords = coords .astype (np .float ) # XXX: due to mayavi bug on mac 32bits
93
94
return coords , faces
94
95
95
- def write_geometry (filepath , create_stamp , coords , faces ):
96
+ def write_geometry (filepath , coords , faces , create_stamp = None ):
96
97
"""Write a triangular format Freesurfer surface mesh.
97
98
98
99
Parameters
99
100
----------
100
101
filepath : str
101
102
Path to surface file
102
- create_stamp : str
103
- User/time stamp
104
103
coords : numpy array
105
104
nvtx x 3 array of vertex (x, y, z) coordinates
106
105
faces : numpy array
107
106
nfaces x 3 array of defining mesh triangles
107
+ create_stamp : str
108
+ User/time stamp (default: "created by <user> on <ctime>")
108
109
"""
109
110
magic_bytes = np .array ([255 ,255 ,254 ],dtype = np .uint8 )
111
+
112
+ if create_stamp is None :
113
+ create_stamp = "created by %s on %s" % (os .getlogin (), time .ctime ())
114
+
110
115
with open (filepath , 'wb' ) as fobj :
111
116
magic_bytes .tofile (fobj )
112
117
fobj .write ("%s\n \n " % create_stamp )
Original file line number Diff line number Diff line change @@ -44,7 +44,6 @@ def test_geometry():
44
44
ntf .close ()
45
45
46
46
surf_path = ntf .name
47
- create_stamp = "created by %s on %s" % (os .getlogin (), time .ctime ())
48
47
write_geometry (surf_path , create_stamp , coords , faces )
49
48
50
49
coords2 , faces2 = read_geometry (surf_path )
You can’t perform that action at this time.
0 commit comments