0001 function reject_channel_eeg(p)
0002
0003
0004
0005
0006
0007 disp(mfilename);
0008
0009
0010 threshold = 5*10^(-4);
0011
0012
0013 data_file = fullfile(p.proj_root, p.eeg_dirname, p.trial_dirname, 'ibr_s1.eeg.mat');
0014
0015
0016 save_file = fullfile(p.proj_root, p.eeg_dirname, p.trial_dirname, 'ribr_s1.eeg.mat');
0017
0018
0019 data = vb_load_meg_data(data_file);
0020 [Nch, Nsample, Ntr]=size(data);
0021 data2 = reshape(data, [Nch,Nsample*Ntr]);
0022
0023
0024 bad_ch = find(max(abs(data2), [], 2) > threshold);
0025 load(data_file, 'EEGinfo');
0026 EEGinfo.ActiveChannel(bad_ch) = 0;
0027 disp([num2str(length(bad_ch)) ' channels are rejected.'])
0028
0029
0030 copyfile(data_file, save_file);
0031 vb_save(save_file,'EEGinfo');
0032
0033
0034 data = vb_load_meg_data(save_file);
0035 if max(abs(data(:))) > threshold
0036 error(['Bad channels still remain.'])
0037 end
0038