0001 function mne_write_surface(fname,verts,faces,comment)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 me='MNE:mne_write_surface';
0023
0024 if nargin < 4
0025 comment = 'Triangle file written with MNE Matlab tools';
0026 end
0027
0028
0029
0030 fid = fopen(fname,'wb','ieee-be');
0031
0032 if (fid < 0)
0033 error(me,'Cannot open file %s', fname);
0034 end
0035
0036
0037
0038
0039 TRIANGLE_FILE_MAGIC_NUMBER = 16777214 ;
0040
0041 mne_fwrite3(fid,TRIANGLE_FILE_MAGIC_NUMBER) ;
0042 fprintf(fid,'%s\n\n',comment);
0043 fwrite(fid, size(verts,1), 'int32') ;
0044 fwrite(fid, size(faces,1), 'int32') ;
0045 fwrite(fid, 1000.0*reshape(verts',1,numel(verts)), 'float32') ;
0046 fwrite(fid, reshape(faces',1,numel(faces)) - 1, 'int32') ;
0047 fclose(fid) ;
0048 fprintf(1,'\tWrote the surface file %s with %d vertices and %d triangles\n',fname,size(verts,1),size(faces,1));
0049
0050 return;