load pointing_data.mat

% pointing_left/pointing_right
% Task: EEG during movement planning of pointing to Left/Right
% sampling rate: sr=256;
% size: [121x256x300]
% Number of Channels: 121
% Duration: 256 points (1 second)
% Number of Trials: 300
% 1 second trial from t_start(-0.2s) to t_end(0.8s);
% Direction Cue: time 0; 

%% plot erp signals on left and right PPC electrodes
ch_l=26;
ch_r=55;

erp_left_lppc=squeeze(mean(pointing_left(ch_l,:,:),3));

erp_left_rppc=squeeze(mean(pointing_left(ch_r,:,:),3));

erp_right_lppc=squeeze(mean(pointing_right(ch_l,:,:),3));

erp_right_rppc=squeeze(mean(pointing_right(ch_r,:,:),3));

figure
subplot(1,2,1);
plot([1:sr]/sr+t_start,erp_left_lppc,'r');
hold on
plot([1:sr]/sr+t_start,erp_right_lppc,'b');
legend('Point to Left','Point to Right')
title('Left PPC Area')
box off
xlabel('Time (s)')
ylabel('uV')

subplot(1,2,2);
plot([1:sr]/sr+t_start,erp_left_rppc,'r');
hold on
plot([1:sr]/sr+t_start,erp_right_rppc,'b');
legend('Point to Left','Point to Right')
title('Right PPC Area')
box off
xlabel('Time (s)')
ylabel('uV')

%% Use EEGLAB to plot scalp map of difference waves (left vs. right)
erp_left_all=mean(pointing_left,3);
erp_right_all=mean(pointing_right,3);

diff_wave=erp_left_all-erp_right_all;

t1=round((0.27-t_start)*sr);
t2=round((0.29-t_start)*sr);

figure
subplot(1,3,1);
topoplot(mean(erp_left_all(:,t1:t2),2),'sub15_121chs.loc','electrodes','on');colorbar;title('Point to Left')
subplot(1,3,2);
topoplot(mean(erp_right_all(:,t1:t2),2),'sub15_121chs.loc','electrodes','on');colorbar;title('Point to Right')
subplot(1,3,3);
topoplot(mean(diff_wave(:,t1:t2),2),'sub15_121chs.loc','electrodes','on');colorbar;title('Left-Right')

%% electrode layout

figure
topoplot(0*mean(erp_left_all(:,t1:t2),2),'sub15_121chs.loc','electrodes','labels');title('Electrode Layout')

%% load index64.mat 
%index 64
%     1     3     5     7     9    11    13    15    17    19    21    23    24    25    26    27    29    31    33    35    37    39    41
%    43    45    47    48    49    51    53    55    57    58    63    64    67    70    72    74    77    80    82    84    87    88    89
%    91    94    95    98   100   101   104   105   106   108   110   112   113   114   115   117   119   121

%% load index32.mat
%index 32
%     3    11    13    17    19    23    24    27    31    39    41    47    48    49    53    57    63    67    70    72    74    80    82
%    84    94    98   100   101   104   108   110   113
