mne_write_w_file(filename, w) writes a binary 'w' file filename - name of file to write to w - a structure with the following fields: vertices - vector of vertex indices (0-based) data - vector of data values
0001 function err = mne_write_w_file(filename, w) 0002 % mne_write_w_file(filename, w) 0003 % 0004 % writes a binary 'w' file 0005 % 0006 % filename - name of file to write to 0007 % w - a structure with the following fields: 0008 % 0009 % vertices - vector of vertex indices (0-based) 0010 % data - vector of data values 0011 % 0012 0013 % 0014 % Author : Matti Hamalainen, MGH Martinos Center 0015 % License : BSD 3-clause 0016 % 0017 % Revision 1.5 2006/04/23 15:29:41 msh 0018 % Added MGH to the copyright 0019 % 0020 % Revision 1.4 2006/04/10 23:26:54 msh 0021 % Added fiff reading routines 0022 % 0023 % Revision 1.3 2005/12/05 20:23:21 msh 0024 % Added fiff_save_evoked. Improved error handling. 0025 % 0026 % Revision 1.2 2005/11/21 03:19:12 msh 0027 % Improved error handling 0028 % 0029 % Revision 1.1 2005/11/21 02:15:51 msh 0030 % Added more routines 0031 % 0032 0033 me='MNE:mne_write_w_file'; 0034 if(nargin ~= 2) 0035 error(me,'usage: mne_write_w_file(filename, w)'); 0036 return; 0037 end 0038 0039 vnum = length(w.vertices) ; 0040 0041 % open it as a big-endian file 0042 [fid,message] = fopen(filename, 'wb', 'b') ; 0043 if(fid == -1) 0044 error(me,message); 0045 end 0046 0047 fwrite(fid, 0, 'int16') ; 0048 mne_fwrite3(fid, uint32(vnum)) ; 0049 for i=1:vnum 0050 mne_fwrite3(fid, w.vertices(i)) ; % vertex number (0-based) 0051 fwrite(fid, w.data(i), 'float') ; % vertex value 0052 end 0053 0054 fclose(fid) ; 0055 0056 return;