Home > vbmeg > demo > tutorial_for_vbmeg2 > easy_VBMEG > remove_noise_ic_eeg.m

remove_noise_ic_eeg

PURPOSE ^

Remove noise ICs from EEG data

SYNOPSIS ^

function remove_noise_ic_eeg(p)

DESCRIPTION ^

 Remove noise ICs from EEG data

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function remove_noise_ic_eeg(p)
0002 % Remove noise ICs from EEG data
0003 %
0004 % Copyright (C) 2011, ATR All Rights Reserved.
0005 % License : New BSD License(see VBMEG_LICENSE.txt)
0006 
0007 disp(mfilename);
0008 
0009 % Classification program
0010 correct_ic_prog = 'correct_classify_ic_eeg';
0011 
0012 % Set paremeters
0013 prefix = 'i';% Prefix of denoised EEG data
0014 
0015 % Load EEG data and EEGinfo
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 % Load ICA result
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 % Make denoising filter
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     % Load EEG data
0035     load(data_file)
0036     
0037     % Obtain indices of channels
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     % Denoise
0044     for tr = 1:size(eeg_data, 3)
0045         eeg_data(IA, :, tr) = denoise*eeg_data(IA, :, tr);
0046     end
0047     
0048     % Save denoised EEG data
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

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005