@@ -79,6 +79,16 @@ def read_geometry(filepath, read_metadata=False, read_stamp=False):
79
79
Path to surface file
80
80
read_metadata : bool
81
81
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,)
82
92
read_stamp : bool
83
93
Return the comment from the file
84
94
@@ -94,7 +104,7 @@ def read_geometry(filepath, read_metadata=False, read_stamp=False):
94
104
If read_stamp is true, the comment added by the program that saved
95
105
the file
96
106
"""
97
- volume_info = None
107
+ volume_info = OrderedDict ()
98
108
99
109
with open (filepath , "rb" ) as fobj :
100
110
magic = _fread3 (fobj )
@@ -164,6 +174,17 @@ def write_geometry(filepath, coords, faces, create_stamp=None,
164
174
User/time stamp (default: "created by <user> on <ctime>")
165
175
volume_info : dict-like or None
166
176
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
+
167
188
"""
168
189
magic_bytes = np .array ([255 , 255 , 254 ], dtype = np .uint8 )
169
190
@@ -187,6 +208,9 @@ def write_geometry(filepath, coords, faces, create_stamp=None,
187
208
188
209
for key , val in volume_info .items ():
189
210
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." )
190
214
np .array (val , dtype = '>i4' ).tofile (fobj )
191
215
elif key in ('valid' , 'filename' ):
192
216
fobj .write ('{0} = {1}\n ' .format (key , val ).encode ('utf-8' ))
0 commit comments