0001 function check_removing_eog_from_eeg(p)
0002
0003
0004
0005
0006
0007
0008 file = 3;
0009
0010
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
0015 [o, ~, time_info] = vb_load_meg_data(original_file);
0016 r = vb_load_meg_data(removed_file);
0017
0018
0019 [pos, channel_info] = vb_load_channel(original_file);
0020
0021
0022 po=sum(sum(o.^2,2),3);
0023 pr=sum(sum(r.^2,2),3);
0024 dp=po-pr;
0025
0026
0027 ma=max(po(:));
0028 mi=min(pr(:));
0029
0030
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
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
0048 [~, ch] = max(dp);
0049 d = squeeze(o(ch,:,:)-r(ch,:,:));
0050 pd = sum(d.^2, 1);
0051 [~, tr] = max(pd);
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
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
0071 save_dir = fullfile(p.fig_root, mfilename);
0072 if exist(save_dir, 'dir') ~= 7
0073 vb_mkdir(save_dir);
0074 end
0075
0076
0077 vb_savefig_as_shown(h, fullfile(save_dir, p.sub))