0001 function [label] = mne_read_label_file(filename)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 me='MNE:mne_read_label_file';
0025 if(nargin ~= 1)
0026 error(me,'usage: mne_read_label_file(filename)');
0027 end
0028
0029 [fid,message] = fopen(filename,'r');
0030 if (fid < 0)
0031 error(me,'Cannot open file %s (%s)', filename,message);
0032 end
0033
0034 comment = fgets(fid) ;
0035 line = fgets(fid) ;
0036 nv = sscanf(line, '%d') ;
0037 data = fscanf(fid, '%d %f %f %f %f\n') ;
0038 data = reshape(data, 5, nv);
0039
0040 for k = 2:length(comment)
0041 if comment(k) ~= ' '
0042 break;
0043 end
0044 end
0045 if comment(length(comment)) == 10
0046 comment = comment(1:end-1);
0047 end
0048 label.comment = comment(k:end);
0049 label.vertices = int32(data(1,:));
0050 label.pos = 1e-3*data(2:4,:)';
0051 label.values = data(5,:);
0052 fclose(fid);
0053
0054