@@ -79,6 +79,16 @@ def read_geometry(filepath, read_metadata=False, read_stamp=False):
7979 Path to surface file
8080 read_metadata : bool
8181 Read metadata as key-value pairs
82+ Valid keys:
83+ 'head' : array of int
84+ 'valid' : str
85+ 'filename' : str
86+ 'volume' : array of int, shape (3,)
87+ 'voxelsize' : array of float, shape (3,)
88+ 'xras' : array of float, shape (3,)
89+ 'yras' : array of float, shape (3,)
90+ 'zras' : array of float, shape (3,)
91+ 'cras' : array of float, shape (3,)
8292 read_stamp : bool
8393 Return the comment from the file
8494
@@ -94,7 +104,7 @@ def read_geometry(filepath, read_metadata=False, read_stamp=False):
94104 If read_stamp is true, the comment added by the program that saved
95105 the file
96106 """
97- volume_info = None
107+ volume_info = OrderedDict ()
98108
99109 with open (filepath , "rb" ) as fobj :
100110 magic = _fread3 (fobj )
@@ -164,6 +174,17 @@ def write_geometry(filepath, coords, faces, create_stamp=None,
164174 User/time stamp (default: "created by <user> on <ctime>")
165175 volume_info : dict-like or None
166176 Key-value pairs to encode at the end of the file
177+ Valid keys:
178+ 'head' : array of int
179+ 'valid' : str
180+ 'filename' : str
181+ 'volume' : array of int, shape (3,)
182+ 'voxelsize' : array of float, shape (3,)
183+ 'xras' : array of float, shape (3,)
184+ 'yras' : array of float, shape (3,)
185+ 'zras' : array of float, shape (3,)
186+ 'cras' : array of float, shape (3,)
187+
167188 """
168189 magic_bytes = np .array ([255 , 255 , 254 ], dtype = np .uint8 )
169190
@@ -187,6 +208,9 @@ def write_geometry(filepath, coords, faces, create_stamp=None,
187208
188209 for key , val in volume_info .items ():
189210 if key == 'head' :
211+ if not (np .array_equal (val , [20 ]) or np .array_equal (
212+ val , [2 , 0 , 20 ])):
213+ warnings .warn ("Unknown extension code." )
190214 np .array (val , dtype = '>i4' ).tofile (fobj )
191215 elif key in ('valid' , 'filename' ):
192216 fobj .write ('{0} = {1}\n ' .format (key , val ).encode ('utf-8' ))
0 commit comments