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 11"""Reading functions for freesurfer files
22"""
33
4- from .io import read_geometry , read_morph_data , \
4+ from .io import read_geometry , read_morph_data , write_morph_data , \
55 read_annot , read_label , write_geometry , write_annot
66from .mghformat import load , save , MGHImage
Original file line number Diff line number Diff line change @@ -160,6 +160,25 @@ def read_morph_data(filepath):
160160 return curv
161161
162162
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+
163182def read_annot (filepath , orig_ids = False ):
164183 """Read in a Freesurfer annotation from a .annot file.
165184
You can’t perform that action at this time.
0 commit comments