File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 1
1
"""Reading functions for freesurfer files
2
2
"""
3
3
4
- from .io import read_geometry , read_morph_data , \
4
+ from .io import read_geometry , read_morph_data , write_morph_data , \
5
5
read_annot , read_label , write_geometry , write_annot
6
6
from .mghformat import load , save , MGHImage
Original file line number Diff line number Diff line change @@ -160,6 +160,25 @@ def read_morph_data(filepath):
160
160
return curv
161
161
162
162
163
+ def write_morph_data (filename , values ):
164
+ '''
165
+ '''
166
+ with open (filename , 'wb' ) as f :
167
+
168
+ # magic number
169
+ np .array ([255 ], dtype = '>u1' ).tofile (f )
170
+ np .array ([255 ], dtype = '>u1' ).tofile (f )
171
+ np .array ([255 ], dtype = '>u1' ).tofile (f )
172
+
173
+ # vertices number and two un-used int4
174
+ np .array ([len (values )], dtype = '>i4' ).tofile (f )
175
+ np .array ([0 ], dtype = '>i4' ).tofile (f )
176
+ np .array ([1 ], dtype = '>i4' ).tofile (f )
177
+
178
+ # now the data
179
+ np .array (values , dtype = '>f4' ).tofile (f )
180
+
181
+
163
182
def read_annot (filepath , orig_ids = False ):
164
183
"""Read in a Freesurfer annotation from a .annot file.
165
184
You can’t perform that action at this time.
0 commit comments