0001 function [p] = elec_write_brainstorm(p)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 tic;
0023
0024 fprintf('\nELEC_WRITE_BRAINSTORM...\n');
0025 fprintf('...Converting to brainstorm structure.\n');
0026
0027 Ee = p.elec.data.label;
0028 Xe = p.elec.data.x;
0029 Ye = p.elec.data.y;
0030 Ze = p.elec.data.z;
0031
0032 Eref = 'Ref';
0033 Xref = p.elec.data.ref(1);
0034 Yref = p.elec.data.ref(2);
0035 Zref = p.elec.data.ref(3);
0036
0037 for i=1:length(Xe),
0038 Channel(i).Loc = [[Xe(i) Ye(i) Ze(i)]',[Xref Yref Zref]'];
0039 Channel(i).Orient = [];
0040 Channel(i).Weight = 1;
0041 Channel(i).Type = 'EEG';
0042 Channel(i).Name = char(Ee(i));
0043 Channel(i).Comment = '';
0044 end
0045 Channel(i+1).Loc = [[Xref Yref Zref]',[Xref Yref Zref]'];
0046 Channel(i+1).Orient = [];
0047 Channel(i+1).Weight = 1;
0048 Channel(i+1).Type = 'EEG';
0049 Channel(i+1).Name = char(Eref);
0050 Channel(i+1).Comment = 'EEG REF';
0051
0052
0053 [path,name,ext] = fileparts(strcat(p.elec.path,filesep,p.elec.file));
0054 name = sprintf('%s_channel',name);
0055 ext = '.mat';
0056 file = fullfile(path,[name ext]);
0057
0058 fprintf('...saving BrainStorm channel data to:\n\t%s\n',file);
0059 save(file, 'Channel');
0060
0061
0062
0063
0064
0065 t = toc; fprintf('...done (%6.2f sec).\n\n',t);
0066
0067 return