%% 9hz
chStart = 188;
chEnd = chStart+3;
sessionA = pop_loadset('filename','sbj5_session_A8.set','filepath','/data/projects/yute/SSVEP/subject5/');
sessionAdata = sessionA.data(chStart:chEnd,:,1:6);
sessionB = pop_loadset('filename','sbj5_session_B6.set','filepath','/data/projects/yute/SSVEP/subject5/');
sessionBdata = sessionB.data;
sessionBdata = sessionB.data(chStart:chEnd,:,1:6);
sessionC = pop_loadset('filename','sbj5_session_C10.set','filepath','/data/projects/yute/SSVEP/subject5/');
sessionCdata = sessionC.data;
sessionCdata = sessionC.data(chStart:chEnd,:,1:6);
sessionD = pop_loadset('filename','sbj5_session_D7.set','filepath','/data/projects/yute/SSVEP/subject5/');
sessionDdata = sessionD.data;
sessionDdata = sessionD.data(chStart:chEnd,:,1:6);

ch1 = mean([sessionAdata(1,:,:);sessionBdata(1,:,:);sessionCdata(1,:,:);sessionDdata(1,:,:)],1);
ch1_9hz = reshape(ch1,1,1024*6);
ch2 = mean([sessionAdata(2,:,:);sessionBdata(2,:,:);sessionCdata(2,:,:);sessionDdata(2,:,:)],1);
ch2_9hz = reshape(ch2,1,1024*6);
ch3 = mean([sessionAdata(3,:,:);sessionBdata(3,:,:);sessionCdata(3,:,:);sessionDdata(3,:,:)],1);
ch3_9hz = reshape(ch3,1,1024*6);
ch4 = mean([sessionAdata(4,:,:);sessionBdata(4,:,:);sessionCdata(4,:,:);sessionDdata(4,:,:)],1);
ch4_9hz = reshape(ch4,1,1024*6);

%% 10hz
sessionA = pop_loadset('filename','sbj5_session_A1.set','filepath','/data/projects/yute/SSVEP/subject5/');
sessionAdata = sessionA.data(chStart:chEnd,:,1:6);
sessionB = pop_loadset('filename','sbj5_session_B8.set','filepath','/data/projects/yute/SSVEP/subject5/');
sessionBdata = sessionB.data;
sessionBdata = sessionB.data(chStart:chEnd,:,1:6);
sessionC = pop_loadset('filename','sbj5_session_C6.set','filepath','/data/projects/yute/SSVEP/subject5/');
sessionCdata = sessionC.data;
sessionCdata = sessionC.data(chStart:chEnd,:,1:6);
sessionD = pop_loadset('filename','sbj5_session_D4.set','filepath','/data/projects/yute/SSVEP/subject5/');
sessionDdata = sessionD.data;
sessionDdata = sessionD.data(chStart:chEnd,:,1:6);

ch1 = mean([sessionAdata(1,:,:);sessionBdata(1,:,:);sessionCdata(1,:,:);sessionDdata(1,:,:)],1);
ch1_10hz = reshape(ch1,1,1024*6);
ch2 = mean([sessionAdata(2,:,:);sessionBdata(2,:,:);sessionCdata(2,:,:);sessionDdata(2,:,:)],1);
ch2_10hz = reshape(ch2,1,1024*6);
ch3 = mean([sessionAdata(3,:,:);sessionBdata(3,:,:);sessionCdata(3,:,:);sessionDdata(3,:,:)],1);
ch3_10hz = reshape(ch3,1,1024*6);
ch4 = mean([sessionAdata(4,:,:);sessionBdata(4,:,:);sessionCdata(4,:,:);sessionDdata(4,:,:)],1);
ch4_10hz = reshape(ch4,1,1024*6);

%% 11hz
sessionA = pop_loadset('filename','sbj5_session_A6.set','filepath','/data/projects/yute/SSVEP/subject5/');
sessionAdata = sessionA.data(chStart:chEnd,:,1:6);
sessionB = pop_loadset('filename','sbj5_session_B1.set','filepath','/data/projects/yute/SSVEP/subject5/');
sessionBdata = sessionB.data;
sessionBdata = sessionB.data(chStart:chEnd,:,1:6);
sessionC = pop_loadset('filename','sbj5_session_C8.set','filepath','/data/projects/yute/SSVEP/subject5/');
sessionCdata = sessionC.data;
sessionCdata = sessionC.data(chStart:chEnd,:,1:6);
sessionD = pop_loadset('filename','sbj5_session_D3.set','filepath','/data/projects/yute/SSVEP/subject5/');
sessionDdata = sessionD.data;
sessionDdata = sessionD.data(chStart:chEnd,:,1:6);

ch1 = mean([sessionAdata(1,:,:);sessionBdata(1,:,:);sessionCdata(1,:,:);sessionDdata(1,:,:)],1);
ch1_11hz = reshape(ch1,1,1024*6);
ch2 = mean([sessionAdata(2,:,:);sessionBdata(2,:,:);sessionCdata(2,:,:);sessionDdata(2,:,:)],1);
ch2_11hz = reshape(ch2,1,1024*6);
ch3 = mean([sessionAdata(3,:,:);sessionBdata(3,:,:);sessionCdata(3,:,:);sessionDdata(3,:,:)],1);
ch3_11hz = reshape(ch3,1,1024*6);
ch4 = mean([sessionAdata(4,:,:);sessionBdata(4,:,:);sessionCdata(4,:,:);sessionDdata(4,:,:)],1);
ch4_11hz = reshape(ch4,1,1024*6);

%% 12hz
sessionA = pop_loadset('filename','sbj5_session_A9.set','filepath','/data/projects/yute/SSVEP/subject5/');
sessionAdata = sessionA.data(chStart:chEnd,:,1:6);
sessionB = pop_loadset('filename','sbj5_session_B7.set','filepath','/data/projects/yute/SSVEP/subject5/');
sessionBdata = sessionB.data;
sessionBdata = sessionB.data(chStart:chEnd,:,1:6);
sessionC = pop_loadset('filename','sbj5_session_C2.set','filepath','/data/projects/yute/SSVEP/subject5/');
sessionCdata = sessionC.data;
sessionCdata = sessionC.data(chStart:chEnd,:,1:6);
sessionD = pop_loadset('filename','sbj5_session_D8.set','filepath','/data/projects/yute/SSVEP/subject5/');
sessionDdata = sessionD.data;
sessionDdata = sessionD.data(chStart:chEnd,:,1:6);

ch1 = mean([sessionAdata(1,:,:);sessionBdata(1,:,:);sessionCdata(1,:,:);sessionDdata(1,:,:)],1);
ch1_12hz = reshape(ch1,1,1024*6);
ch2 = mean([sessionAdata(2,:,:);sessionBdata(2,:,:);sessionCdata(2,:,:);sessionDdata(2,:,:)],1);
ch2_12hz = reshape(ch2,1,1024*6);
ch3 = mean([sessionAdata(3,:,:);sessionBdata(3,:,:);sessionCdata(3,:,:);sessionDdata(3,:,:)],1);
ch3_12hz = reshape(ch3,1,1024*6);
ch4 = mean([sessionAdata(4,:,:);sessionBdata(4,:,:);sessionCdata(4,:,:);sessionDdata(4,:,:)],1);
ch4_12hz = reshape(ch4,1,1024*6);

%% 13hz
sessionA = pop_loadset('filename','sbj5_session_A5.set','filepath','/data/projects/yute/SSVEP/subject5/');
sessionAdata = sessionA.data(chStart:chEnd,:,1:6);
sessionB = pop_loadset('filename','sbj5_session_B9.set','filepath','/data/projects/yute/SSVEP/subject5/');
sessionBdata = sessionB.data;
sessionBdata = sessionB.data(chStart:chEnd,:,1:6);
sessionC = pop_loadset('filename','sbj5_session_C7.set','filepath','/data/projects/yute/SSVEP/subject5/');
sessionCdata = sessionC.data;
sessionCdata = sessionC.data(chStart:chEnd,:,1:6);
sessionD = pop_loadset('filename','sbj5_session_D9.set','filepath','/data/projects/yute/SSVEP/subject5/');
sessionDdata = sessionD.data;
sessionDdata = sessionD.data(chStart:chEnd,:,1:6);

ch1 = mean([sessionAdata(1,:,:);sessionBdata(1,:,:);sessionCdata(1,:,:);sessionDdata(1,:,:)],1);
ch1_13hz = reshape(ch1,1,1024*6);
ch2 = mean([sessionAdata(2,:,:);sessionBdata(2,:,:);sessionCdata(2,:,:);sessionDdata(2,:,:)],1);
ch2_13hz = reshape(ch2,1,1024*6);
ch3 = mean([sessionAdata(3,:,:);sessionBdata(3,:,:);sessionCdata(3,:,:);sessionDdata(3,:,:)],1);
ch3_13hz = reshape(ch3,1,1024*6);
ch4 = mean([sessionAdata(4,:,:);sessionBdata(4,:,:);sessionCdata(4,:,:);sessionDdata(4,:,:)],1);
ch4_13hz = reshape(ch4,1,1024*6);

dataset = [ch1_10hz,ch1_12hz,ch1_11hz,ch1_9hz,ch1_13hz;
           ch2_10hz,ch2_12hz,ch2_11hz,ch2_9hz,ch2_13hz;
           ch3_10hz,ch3_12hz,ch3_11hz,ch3_9hz,ch3_13hz;
           ch4_10hz,ch4_12hz,ch4_11hz,ch4_9hz,ch4_13hz;];
       

% plot(dataset');
% figure;pwelch(dataset(1,:),[],0,length(dataset),256);
% figure;pwelch(dataset(1,:),[],0,length(dataset),256);
% figure;pwelch(dataset(1,:),[],0,length(dataset),256);
% figure;pwelch(dataset(1,:),[],0,length(dataset),256);