[w] = mne_read_w_file(filename) Reads a binary w file into the structure w with the following fields vertices - vector of vertex indices (0-based) data - vector of data values
0001 function [w] = mne_read_w_file(filename) 0002 % 0003 % [w] = mne_read_w_file(filename) 0004 % 0005 % Reads a binary w file into the structure w with the following fields 0006 % 0007 % vertices - vector of vertex indices (0-based) 0008 % data - vector of data values 0009 % 0010 0011 % 0012 % Author : Matti Hamalainen, MGH Martinos Center 0013 % License : BSD 3-clause 0014 % 0015 % 0016 % $Id: mne_read_w_file.m 8776 2013-11-14 09:04:48Z roboos $ 0017 % 0018 % Revision 1.6 2006/04/23 15:29:41 msh 0019 % Added MGH to the copyright 0020 % 0021 % Revision 1.5 2006/04/10 23:26:54 msh 0022 % Added fiff reading routines 0023 % 0024 % Revision 1.4 2005/12/05 20:23:21 msh 0025 % Added fiff_save_evoked. Improved error handling. 0026 % 0027 % Revision 1.3 2005/11/21 03:19:12 msh 0028 % Improved error handling 0029 % 0030 % Revision 1.2 2005/11/21 02:15:51 msh 0031 % Added more routines 0032 % 0033 % Revision 1.1 2005/11/21 01:41:57 msh 0034 % Introduced structures and start all function names with mne_ 0035 % 0036 % 0037 me='MNE:mne_read_w_file'; 0038 if(nargin ~= 1) 0039 error(me,'usage: [w] = mne_read_w_file(filename)'); 0040 end 0041 0042 % open it as a big-endian file 0043 [fid,message] = fopen(filename, 'rb', 'b') ; 0044 if (fid < 0) 0045 error(me,message); 0046 end 0047 0048 fread(fid, 1, 'int16') ; 0049 vnum = mne_fread3(fid) ; 0050 w.data = zeros(vnum,1) ; 0051 w.vertices = zeros(vnum,1) ; 0052 for i=1:vnum 0053 w.vertices(i) = mne_fread3(fid) ; % vertex number (0-based) 0054 w.data(i) = fread(fid, 1, 'float') ; % vertex value 0055 end 0056 w.vertices = uint32(w.vertices); 0057 0058 fclose(fid) ; 0059 return; 0060 0061 0062 0063 0064 0065