0001 function reject_channel_meg(p)
0002
0003
0004
0005
0006
0007 disp(mfilename);
0008
0009
0010 threshold = 2*10^(-12);
0011 sleep_ch={'38','260'};
0012
0013
0014 data_file = fullfile(p.proj_root, p.meg_dirname, p.trial_dirname, 'i_all.info.mat');
0015
0016
0017 save_file = fullfile(p.proj_root, p.meg_dirname, p.trial_dirname, 'ri_all.info.mat');
0018
0019
0020 [data, ch_info] = vb_load_meg_data(data_file);
0021 load(data_file, 'fileinfo', 'Measurement')
0022 load(fileinfo.filename{1}, 'MEGinfo')
0023
0024
0025 ix_sleep_ch = zeros(1, length(sleep_ch));
0026 for c = 1:length(ch_info.ID)
0027 if strcmp(ch_info.Name{c}, sleep_ch{1})
0028 ix_sleep_ch(1) = c;
0029 elseif strcmp(ch_info.Name{c}, sleep_ch{2})
0030 ix_sleep_ch(2) = c;
0031 end
0032 end
0033
0034
0035 [Nch, Nsample, Ntr]=size(data);
0036 data2 = reshape(data, [Nch, Nsample*Ntr]);
0037 bad_ch = [find(max(abs(data2), [], 2) > threshold)' ix_sleep_ch];
0038 fileinfo.ActiveChannel(bad_ch) = 0;
0039
0040 disp([num2str(length(bad_ch)) ' channels are rejected.'])
0041
0042
0043 save(save_file, 'fileinfo', 'Measurement')
0044
0045
0046 data = vb_load_meg_data(save_file);
0047 if max(abs(data(:))) > threshold
0048 error(['Bad channels still remain.'])
0049 end
0050