0001 function vb_make_ascii(bemfile,brainfile,megfile,Nreduce)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 if ~isempty(brainfile)
0021 load(brainfile,'V','F','xx','xxF');
0022
0023
0024 xx = vb_mean_normal_vector_1(1:size(V,1),F,V,xx);
0025
0026 xx= vb_mean_normal_vector_4(1:size(V,1),F,V,xx,xxF);
0027
0028 V0 = [V xx];
0029
0030
0031 filename = strrep(brainfile,'.brain.mat','.V0.brain.mat');
0032 save('-ascii',filename,'V0');
0033 fprintf('''%s'' is created.\n',filename);
0034 end
0035
0036
0037
0038
0039 if ~isempty(bemfile)
0040 load(bemfile,'Vhead','Fhead','XXhead');
0041 if exist('Nreduce') & Nreduce<size(Vhead,1)
0042 [Fnew,Vnew] = vb_reducepatch(Fhead,Vhead,Nreduce/size(Vhead,1));
0043 ix = vb_find_match_point(Vhead,Vnew,10);
0044 XXhead = XXhead(ix,:);
0045 Vhead = Vnew;
0046 Fhead = Fnew;
0047 end
0048 Fhead = Fhead-1;
0049
0050
0051 if exist('Nreduce') & Nreduce~=1
0052 filename = strrep(bemfile,'.head.mat',...
0053 sprintf('_%d.Vhead.head.mat',Nreduce));
0054 save('-ascii',filename,'Vhead');
0055 fprintf('''%s'' is created.\n',filename);
0056 filename = strrep(bemfile,'.head.mat',...
0057 sprintf('_%d.Fhead.head.mat',Nreduce));
0058 save('-ascii',filename,'Fhead');
0059 fprintf('''%s'' is created.\n',filename);
0060 filename = strrep(bemfile,'.head.mat',...
0061 sprintf('_%d.XXhead.head.mat',Nreduce));
0062 save('-ascii',filename,'XXhead');
0063 fprintf('''%s'' is created.\n',filename);
0064 else
0065 filename = strrep(bemfile,'.head.mat','.Vhead.head.mat');
0066 save('-ascii',filename,'Vhead');
0067 fprintf('''%s'' is created.\n',filename);
0068 filename = strrep(bemfile,'.head.mat','.Fhead.head.mat');
0069 save('-ascii',filename,'Fhead');
0070 fprintf('''%s'' is created.\n',filename);
0071 filename = strrep(bemfile,'.head.mat','.XXhead.head.mat');
0072 save('-ascii',filename,'XXhead');
0073 fprintf('''%s'' is created.\n',filename);
0074 end
0075 end
0076
0077
0078
0079
0080 if ~isempty(megfile)
0081 load(megfile,'pick');
0082 filename = strrep(megfile,'.meg.mat','.pick.meg.mat');
0083 save('-ascii',filename,'pick');
0084 fprintf('''%s'' is created.\n',filename);
0085 end