0001 function mne_write_label_file(filename,label)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 me='MNE:mne_write_label_file';
0028 if(nargin ~= 2)
0029 error(me,'usage: mne_read_label_file(filename, label)');
0030 end
0031
0032 if length(label.vertices) ~= length(label.values) || length(label.vertices) ~= size(label.pos,1) || size(label.pos,2) ~= 3
0033 error(me,'fields of the label structure have conflicting or incorrect dimensions');
0034 end
0035
0036 [fid,message] = fopen(filename,'w');
0037 if (fid < 0)
0038 error(me,'Cannot open file %s (%s)', filename,message);
0039 end;
0040
0041 if ~isempty(label.comment)
0042 fprintf(fid,'# %s\n',label.comment);
0043 else
0044 fprintf(fid,'# label file written with mne_write_label\n');
0045 end
0046 fprintf(fid,'%d\n',length(label.vertices));
0047 for k = 1:length(label.vertices)
0048 fprintf(fid,'%d %.2f %.2f %.2f %f\n',label.vertices(k),1000*label.pos(k,:),label.values(k));
0049 end
0050 fclose(fid);
0051
0052