0001 function remove_noise_ic_eeg(p)
0002
0003
0004
0005
0006
0007 disp(mfilename);
0008
0009
0010 correct_ic_prog = 'correct_classify_ic_eeg';
0011
0012
0013 prefix = 'i';
0014
0015
0016 data_file = fullfile(p.proj_root, p.eeg_dirname, p.trial_dirname, 'br_s1.eeg.mat');
0017 [eeg, ch_info] = vb_load_meg_data(data_file);
0018 [Nch, Nt, Ntr] = size(eeg);
0019
0020
0021 ica_dir = fullfile(p.proj_root, p.eeg_dirname, p.ica_dirname);
0022 ica_result = fullfile(ica_dir, [correct_ic_prog '.mat']);
0023 load(ica_result,'unmix','mix','brain_ic')
0024
0025
0026 g = zeros(Nch);
0027 for ic = 1:length(brain_ic)
0028 g(brain_ic(ic), brain_ic(ic)) = 1;
0029 end
0030 denoise = mix*g*unmix;
0031
0032
0033
0034
0035 load(data_file)
0036
0037
0038 clear IA
0039 for ii = 1 : length(ch_info.ID)
0040 IA(ii) = find(EEGinfo.ChannelID == ch_info.ID(ii));
0041 end
0042
0043
0044 for tr = 1:size(eeg_data, 3)
0045 eeg_data(IA, :, tr) = denoise*eeg_data(IA, :, tr);
0046 end
0047
0048
0049 new_file = fullfile(p.proj_root, p.eeg_dirname, p.trial_dirname, 'ibr_s1.eeg.mat');
0050 copyfile(data_file, new_file);
0051 vb_save(new_file, 'eeg_data');
0052
0053
0054
0055