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

check_removing_eog_from_eeg

PURPOSE ^

Check the result of removing EOG components from EEG data

SYNOPSIS ^

function check_removing_eog_from_eeg(p)

DESCRIPTION ^

 Check the result of removing EOG components 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 check_removing_eog_from_eeg(p)
0002 % Check the result of removing EOG components from EEG data
0003 %
0004 % Copyright (C) 2011, ATR All Rights Reserved.
0005 % License : New BSD License(see VBMEG_LICENSE.txt)
0006 
0007 % Set parameters
0008 file = 3;% First run of visual task
0009 
0010 % Set input files
0011 original_file = fullfile(p.proj_root, p.eeg_dirname, p.trial_dirname, [p.file_list{file} '.eeg.mat']);
0012 removed_file = fullfile(p.proj_root, p.eeg_dirname, p.trial_dirname, ['r_' p.file_list{file} '.eeg.mat']);
0013 
0014 % Load EEG data
0015 [o, ~, time_info] = vb_load_meg_data(original_file);
0016 r = vb_load_meg_data(removed_file);
0017 
0018 % Load positions of channels
0019 [pos, channel_info] = vb_load_channel(original_file);
0020 
0021 % Calculate power
0022 po=sum(sum(o.^2,2),3);
0023 pr=sum(sum(r.^2,2),3);
0024 dp=po-pr;
0025 
0026 % Get minimum and maximum values of power
0027 ma=max(po(:));
0028 mi=min(pr(:));
0029 
0030 % Show power of original EEG data
0031 h = figure;
0032 subplot(2, 2, 1)
0033 vb_plot_sensor_2d(pos, po, [mi ma]);
0034 vb_plot_sensor_2d_head_plot_add(gca);
0035 axis square off
0036 colorbar
0037 title('Power (before)')
0038 
0039 % Show power of EOG-removed EEG data
0040 subplot(2, 2, 2)
0041 vb_plot_sensor_2d(pos, pr, [mi ma]);
0042 vb_plot_sensor_2d_head_plot_add(gca);
0043 axis square off
0044 colorbar
0045 title('Power (after)')
0046 
0047 % Show an example of original and EOG-removed EEG data
0048 [~, ch] = max(dp);% Select channel
0049 d = squeeze(o(ch,:,:)-r(ch,:,:));
0050 pd = sum(d.^2, 1);
0051 [~, tr] = max(pd);% Select trial
0052 
0053 subplot(2,2,3)
0054 plot(time_info.time, [o(ch, :, tr)', r(ch, :, tr)'])
0055 xlim([time_info.time(1) time_info.time(end)])
0056 legend('Before','After')
0057 xlabel('Time [s]')
0058 ylabel('Potential {V}')
0059 title([channel_info.Name{ch} ', Trial ' num2str(tr)])
0060 
0061 % Show location of selected channel
0062 subplot(2,2,4)
0063 x = zeros(size(pos, 1), 1);
0064 x(ch) = 1;
0065 vb_plot_sensor_2d(pos, x);
0066 vb_plot_sensor_2d_head_plot_add(gca);
0067 axis square off
0068 title(channel_info.Name{ch})
0069 
0070 % Make directory to save figures
0071 save_dir = fullfile(p.fig_root, mfilename);
0072 if exist(save_dir, 'dir') ~= 7
0073     vb_mkdir(save_dir);
0074 end
0075 
0076 % Save figure
0077 vb_savefig_as_shown(h, fullfile(save_dir, p.sub))

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