|
|
| clear ; clc;close all;
|
| savedir='D:\Project_EEG_CC\CC_Results_step2_AllChannels_NEW\'; % Data are here with baseline correction
|
| cd(savedir);
|
| load('D:\Project_EEG_CC\mFiles\ONOFF.mat','ONOFF')
|
| PDsx=[801:811,813:829]; % 824 S2 CC is bad (manage here)
|
| CTLsx=[8010,8070,8060,890:914]; % 911 S1 CC is bad (manage here)
|
| BigN=size(ONOFF,1)./2;
|
| % load PD OFF and ON data
|
| row=1;
|
| for mi=1:size(ONOFF,1)
|
| disp([num2str(ONOFF(mi,1)),'_Session_',num2str(ONOFF(mi,2)),'_PDDys_CC_ALL_GOODS.mat']);
|
| if ONOFF(mi,1)==824 && ONOFF(mi,2)==2 % Bad EEG
|
| VECTOR=NaN; ERPs=NaN(size_erp); POWER=NaN(size_power); POWER_REST=NaN(size_power); Baselines=NaN(60,50,2);
|
| else
|
| load([savedir,num2str(ONOFF(mi,1)),'_Session_',num2str(ONOFF(mi,2)),'_PDDys_CC_ALL_GOODS.mat']);
|
| size_erp=size(ERPs); size_power=size(POWER);
|
| end
|
|
|
| if ONOFF(mi,3)==1 % ON
|
| ON.ID(floor(row))=ONOFF(mi,1);
|
| ON.Session(floor(row))=ONOFF(mi,2);
|
| ON.ERPs(floor(row),:,:,:,:)=ERPs;
|
| elseif ONOFF(mi,3)==0 % OFF
|
| OFF.ID(floor(row))=ONOFF(mi,1);
|
| OFF.Session(floor(row))=ONOFF(mi,2);
|
| OFF.ERPs(floor(row),:,:,:,:)=ERPs;
|
| end
|
| row=row+.5;
|
| clear ERPs VECTOR POWER;
|
| end
|
| % load control data
|
| row=1;
|
| for CTLi=CTLsx
|
| disp([num2str(CTLi),'_Session_1_PDDys_CC_ALL_GOODS.mat']);
|
| if ONOFF(mi,1)==911 && ONOFF(mi,2)==1 % Bad EEG
|
| VECTOR=NaN; POWER=NaN(size_power); POWER_REST=NaN(size_power); Baselines=NaN(60,50,2);
|
| else
|
| load([savedir,num2str(CTLi),'_Session_1_PDDys_CC_ALL_GOODS.mat']);
|
| end
|
| CTL.ID(floor(row))=CTLi;
|
| CTL.Session(floor(row))=1;
|
| CTL.ERPs(floor(row),:,:,:,:)=ERPs;
|
| row=row+1;
|
| clear ERPs VECTOR POWER ;
|
| end
|
| CtlN=row-1;
|
|
|
| %%%%%%%%%%%%%% Cue-locked ERPs
|
| clearvars -except OFF ON CTL
|
| tx2disp=-500:2:1000;
|
| CHAN=21; % Cz
|
| paneli = 1; % 1=Cue
|
|
|
| % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FIGURE 3: Cue locked Amplitude %%%%%%%%%%%%%%%%
|
| % %% Export positive deflection: P 195 ms
|
| tsP = 195-25; teP = 195+25; % Cz
|
| t1P = find (tx2disp ==tsP );
|
| t2P = find (tx2disp ==teP );
|
|
|
| % Export Negative deflection: N315 ms
|
| tsN = 315-25; teN = 315+25; % Cz
|
| t1N = find (tx2disp ==tsN );
|
| t2N = find (tx2disp ==teN );
|
|
|
| % conflict: 1=Correct; 2=Error
|
|
|
| for i = 1:28
|
| for conflict = 1:2
|
| ERPCTL_PN(i,conflict) = abs (squeeze(nanmean(CTL.ERPs(i,CHAN,t1P:t2P,conflict,paneli)))- squeeze(nanmean(CTL.ERPs(i,CHAN,t1N:t2N,conflict,paneli))) );
|
| ERPON_PN(i,conflict) = abs (squeeze(nanmean(ON.ERPs(i,CHAN,t1P:t2P,conflict,paneli))) - squeeze(nanmean(ON.ERPs(i,CHAN,t1N:t2N,conflict,paneli ))) );
|
|
|
| end
|
| end
|
|
|
| ERPON1 = ERPON_PN(:,1); ERPON2 = ERPON_PN(:,2);
|
| ERPON1(isnan(ERPON1)) = nanmean(ERPON1);
|
| ERPON2(isnan(ERPON2)) = nanmean(ERPON2);
|
| ERPON_PN = [ERPON1 ERPON2];
|
|
|
| ERPCTL_PN(:,3) = ERPCTL_PN(:,2) - ERPCTL_PN(:,1); % Conf2-Conf1
|
| ERPON_PN(:,3) = ERPON_PN(:,2) - ERPON_PN(:,1); % Conf2-Conf1
|
|
|
| ERPCTL_m = nanmean(ERPCTL_PN);
|
| SEMCTL1 = std(ERPCTL_PN(:,1))/sqrt(length(ERPCTL_PN(:,1))); SEMCTL2 = std(ERPCTL_PN(:,2))/sqrt(length(ERPCTL_PN(:,2))); SEMCTL21 = std(ERPCTL_PN(:,3))/sqrt(length(ERPCTL_PN(:,3)));
|
|
|
| ERPON_m = nanmean(ERPON_PN);
|
| SEMON1 = std(ERPON_PN(:,1))/sqrt(length(ERPON_PN(:,1))); SEMON2 = std(ERPON_PN(:,2))/sqrt(length(ERPON_PN(:,2))); SEMON21 = std(ERPON_PN(:,3))/sqrt(length(ERPON_PN(:,3)));
|
|
|
| %%%%%%% ANOVA
|
| p = anova_rm({ERPCTL_PN(:,1:2) ERPON_PN(:,1:2)});
|
| clear p p1 p2 p21;
|
|
|
|
|
| %% RESPONSE locked
|
| close all;
|
| clearvars -except OFF ON CTL
|
| tx2disp=-500:2:1000;
|
| CHAN=21; % Cz
|
| paneli = 2; % 1=Cue ; 2=Resp
|
|
|
| %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FIGURE 5: Response locked Amplitude %%%%%%%%%%%%%%%%
|
| % %% Export positive deflection: P -55 ms
|
| tsP = -55-25; teP = -55+25; % Cz
|
| t1P = find (tx2disp ==tsP );
|
| t2P = find (tx2disp ==teP );
|
|
|
| % Export Negative deflection: N25 ms
|
| tsN = 25-25; teN = 25+25; % Cz
|
| t1N = find (tx2disp ==tsN );
|
| t2N = find (tx2disp ==teN );
|
|
|
| % conflict: 1=Correct; 2=Error
|
|
|
| for i = 1:28
|
| for conflict = 1:2
|
| ERPCTL_PN(i,conflict) = abs (squeeze(nanmean(CTL.ERPs(i,CHAN,t1P:t2P,conflict,paneli)))- squeeze(nanmean(CTL.ERPs(i,CHAN,t1N:t2N,conflict,paneli))) );
|
| ERPON_PN(i,conflict) = abs (squeeze(nanmean(ON.ERPs(i,CHAN,t1P:t2P,conflict,paneli))) - squeeze(nanmean(ON.ERPs(i,CHAN,t1N:t2N,conflict,paneli ))) );
|
|
|
| end
|
| end
|
|
|
| ERPON1 = ERPON_PN(:,1); ERPON2 = ERPON_PN(:,2);
|
| ERPON1(isnan(ERPON1)) = nanmean(ERPON1);
|
| ERPON2(isnan(ERPON2)) = nanmean(ERPON2);
|
| ERPON_PN = [ERPON1 ERPON2];
|
|
|
| ERPCTL_PN(:,3) = ERPCTL_PN(:,2) - ERPCTL_PN(:,1); % Conf2-Conf1
|
| ERPON_PN(:,3) = ERPON_PN(:,2) - ERPON_PN(:,1); % Conf2-Conf1
|
|
|
| ERPCTL_m = nanmean(ERPCTL_PN);
|
| SEMCTL1 = std(ERPCTL_PN(:,1))/sqrt(length(ERPCTL_PN(:,1))); SEMCTL2 = std(ERPCTL_PN(:,2))/sqrt(length(ERPCTL_PN(:,2))); SEMCTL21 = std(ERPCTL_PN(:,3))/sqrt(length(ERPCTL_PN(:,3)));
|
|
|
| ERPON_m = nanmean(ERPON_PN);
|
| SEMON1 = std(ERPON_PN(:,1))/sqrt(length(ERPON_PN(:,1))); SEMON2 = std(ERPON_PN(:,2))/sqrt(length(ERPON_PN(:,2))); SEMON21 = std(ERPON_PN(:,3))/sqrt(length(ERPON_PN(:,3)));
|
|
|
| %%%%%%% ANOVA
|
| p = anova_rm({ERPCTL_PN(:,1:2) ERPON_PN(:,1:2)});
|
| clear p p1 p2 p21;
|
|
|
| %% %% ################ Cong and Incong: Correct trials only ###################################################
|
|
|
| % ALL ERPs amplitude figure and ttest2
|
| clear ; clc;close all;
|
| savedir='D:\Project_EEG_CC\CC_Results_step2_CORRECT_NEW\'; % Data are here with baseline correction
|
| cd(savedir);
|
| load('D:\Project_EEG_CC\mFiles\ONOFF.mat','ONOFF')
|
| PDsx=[801:811,813:829]; % 824 S2 CC is bad (manage here)
|
| CTLsx=[8010,8070,8060,890:914]; % 911 S1 CC is bad (manage here)
|
| BigN=size(ONOFF,1)./2;
|
| % load PD OFF and ON data
|
| row=1;
|
| for mi=1:size(ONOFF,1)
|
| disp([num2str(ONOFF(mi,1)),'_Session_',num2str(ONOFF(mi,2)),'_PDDys_CC_ALL_GOODS.mat']);
|
| if ONOFF(mi,1)==824 && ONOFF(mi,2)==2 % Bad EEG
|
| VECTOR=NaN; ERPs=NaN(size_erp); POWER=NaN(size_power); POWER_REST=NaN(size_power); Baselines=NaN(60,50,2);
|
| else
|
| load([savedir,num2str(ONOFF(mi,1)),'_Session_',num2str(ONOFF(mi,2)),'_PDDys_CC_ALL_GOODS.mat']);
|
| size_erp=size(ERPs); size_power=size(POWER);
|
| end
|
|
|
| if ONOFF(mi,3)==1 % ON
|
| ON.ID(floor(row))=ONOFF(mi,1);
|
| ON.Session(floor(row))=ONOFF(mi,2);
|
| ON.ERPs(floor(row),:,:,:,:)=ERPs;
|
| elseif ONOFF(mi,3)==0 % OFF
|
| OFF.ID(floor(row))=ONOFF(mi,1);
|
| OFF.Session(floor(row))=ONOFF(mi,2);
|
| OFF.ERPs(floor(row),:,:,:,:)=ERPs;
|
| end
|
| row=row+.5;
|
| clear ERPs VECTOR POWER;
|
| end
|
| % load control data
|
| row=1;
|
| for CTLi=CTLsx
|
| disp([num2str(CTLi),'_Session_1_PDDys_CC_ALL_GOODS.mat']);
|
| if ONOFF(mi,1)==911 && ONOFF(mi,2)==1 % Bad EEG
|
| VECTOR=NaN; POWER=NaN(size_power); POWER_REST=NaN(size_power); Baselines=NaN(60,50,2);
|
| else
|
| load([savedir,num2str(CTLi),'_Session_1_PDDys_CC_ALL_GOODS.mat']);
|
| end
|
| CTL.ID(floor(row))=CTLi;
|
| CTL.Session(floor(row))=1;
|
| CTL.ERPs(floor(row),:,:,:,:)=ERPs;
|
| row=row+1;
|
| clear ERPs VECTOR POWER ;
|
| end
|
| CtlN=row-1;
|
|
|
| % % ############################### ERPs......FIGURE 4: Cue-locked
|
| clearvars -except OFF ON CTL
|
| tx2disp=-500:2:1000;
|
| CHAN=21; % Cz
|
| % CHAN=36; % FCz
|
| paneli = 2; % 1=Cue ; 2=Resp
|
|
|
| % % % Export positive deflection: P -55 ms
|
| tsP = -55-25; teP = -55+25; % Cz
|
| t1P = find (tx2disp ==tsP );
|
| t2P = find (tx2disp ==teP );
|
|
|
| % Export Negative deflection: N15 ms
|
| tsN = 15-25; teN = 15+25; % Cz
|
| t1N = find (tx2disp ==tsN );
|
| t2N = find (tx2disp ==teN );
|
|
|
| % conflict: 1=Correct; 2=Error
|
|
|
| for i = 1:28
|
| for conflict = 1:2
|
| ERPCTL_PN(i,conflict) = abs (squeeze(nanmean(CTL.ERPs(i,CHAN,t1P:t2P,conflict,paneli)))- squeeze(nanmean(CTL.ERPs(i,CHAN,t1N:t2N,conflict,paneli))) );
|
| ERPON_PN(i,conflict) = abs (squeeze(nanmean(ON.ERPs(i,CHAN,t1P:t2P,conflict,paneli))) - squeeze(nanmean(ON.ERPs(i,CHAN,t1N:t2N,conflict,paneli ))) );
|
|
|
| end
|
| end
|
|
|
| ERPON1 = ERPON_PN(:,1); ERPON2 = ERPON_PN(:,2);
|
| ERPON1(isnan(ERPON1)) = nanmean(ERPON1);
|
| ERPON2(isnan(ERPON2)) = nanmean(ERPON2);
|
| ERPON_PN = [ERPON1 ERPON2];
|
|
|
| ERPCTL_PN(:,3) = ERPCTL_PN(:,2) - ERPCTL_PN(:,1); % Conf2-Conf1
|
| ERPON_PN(:,3) = ERPON_PN(:,2) - ERPON_PN(:,1); % Conf2-Conf1
|
|
|
| ERPCTL_m = nanmean(ERPCTL_PN);
|
| SEMCTL1 = std(ERPCTL_PN(:,1))/sqrt(length(ERPCTL_PN(:,1))); SEMCTL2 = std(ERPCTL_PN(:,2))/sqrt(length(ERPCTL_PN(:,2))); SEMCTL21 = std(ERPCTL_PN(:,3))/sqrt(length(ERPCTL_PN(:,3)));
|
|
|
| ERPON_m = nanmean(ERPON_PN);
|
| SEMON1 = std(ERPON_PN(:,1))/sqrt(length(ERPON_PN(:,1))); SEMON2 = std(ERPON_PN(:,2))/sqrt(length(ERPON_PN(:,2))); SEMON21 = std(ERPON_PN(:,3))/sqrt(length(ERPON_PN(:,3)));
|
|
|
| %%%%%%% ANOVA
|
| p = anova_rm({ERPCTL_PN(:,1:2) ERPON_PN(:,1:2)});
|
| clear p p1 p2 p21;
|
|
|
|
|
| %% %% ########### Post-Error ERPs analysis ###############################
|
| clear ; clc;close all;
|
| savedir='D:\Project_EEG_CC\CC_Project_PostError\PostError_step2_Data_NEW\'; % Main Data are here
|
| cd(savedir);
|
| load('D:\Project_EEG_CC\mFiles\ONOFF.mat','ONOFF')
|
| PDsx=[801:811,813:829]; % 824 S2 CC is bad (manage here)
|
| CTLsx=[8010,8070,8060,890:914]; % 911 S1 CC is bad (manage here)
|
| BigN=size(ONOFF,1)./2;
|
| % load PD OFF and ON data
|
| row=1;
|
| for mi=1:size(ONOFF,1)
|
| disp([num2str(ONOFF(mi,1)),'_Session_',num2str(ONOFF(mi,2)),'_PDDys_CC_ALL_GOODS.mat']);
|
| if ONOFF(mi,1)==824 && ONOFF(mi,2)==2 % Bad EEG
|
| VECTOR=NaN; ERPs=NaN(size_erp); POWER=NaN(size_power); POWER_REST=NaN(size_power); Baselines=NaN(60,50,2);
|
| else
|
| load([savedir,num2str(ONOFF(mi,1)),'_Session_',num2str(ONOFF(mi,2)),'_PDDys_CC_ALL_GOODS.mat']);
|
| size_erp=size(ERPs); size_power=size(POWER);
|
| end
|
|
|
| if ONOFF(mi,3)==1 % ON
|
| ON.ID(floor(row))=ONOFF(mi,1);
|
| ON.Session(floor(row))=ONOFF(mi,2);
|
| ON.ERPs(floor(row),:,:,:,:)=ERPs;
|
| elseif ONOFF(mi,3)==0 % OFF
|
| OFF.ID(floor(row))=ONOFF(mi,1);
|
| OFF.Session(floor(row))=ONOFF(mi,2);
|
| OFF.ERPs(floor(row),:,:,:,:)=ERPs;
|
| end
|
| row=row+.5;
|
| clear ERPs VECTOR POWER;
|
| end
|
| % load control data
|
| row=1;
|
| for CTLi=CTLsx
|
| disp([num2str(CTLi),'_Session_1_PDDys_CC_ALL_GOODS.mat']);
|
| if ONOFF(mi,1)==911 && ONOFF(mi,2)==1 % Bad EEG
|
| VECTOR=NaN; POWER=NaN(size_power); POWER_REST=NaN(size_power); Baselines=NaN(60,50,2);
|
| else
|
| load([savedir,num2str(CTLi),'_Session_1_PDDys_CC_ALL_GOODS.mat']);
|
| end
|
| CTL.ID(floor(row))=CTLi;
|
| CTL.Session(floor(row))=1;
|
| CTL.ERPs(floor(row),:,:,:,:)=ERPs;
|
| row=row+1;
|
| clear ERPs VECTOR POWER ;
|
| end
|
| CtlN=row-1;
|
|
|
| close all;
|
| clearvars -except OFF ON CTL
|
| tx2disp=-500:2:1000;
|
| CHAN=21; % Cz
|
| paneli = 2; % 1=Cue ; 2=Resp
|
|
|
| % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FIGURE 6: Response locked Amplitude %%%%%%%%%%%%%%%%
|
| % %% Export positive deflection: P -25 ms
|
| tsP = -25-25; teP = -25+25; % Cz
|
| t1P = find (tx2disp ==tsP );
|
| t2P = find (tx2disp ==teP );
|
|
|
| % Export Negative deflection: N25 ms
|
| tsN = 25-25; teN = 25+25; % Cz
|
| t1N = find (tx2disp ==tsN );
|
| t2N = find (tx2disp ==teN );
|
|
|
| % conflict: 1=Correct; 2=Error
|
|
|
| for i = 1:28
|
| for conflict = 1:2
|
| ERPCTL_PN(i,conflict) = abs (squeeze(nanmean(CTL.ERPs(i,CHAN,t1P:t2P,conflict,paneli)))- squeeze(nanmean(CTL.ERPs(i,CHAN,t1N:t2N,conflict,paneli))) );
|
| ERPON_PN(i,conflict) = abs (squeeze(nanmean(ON.ERPs(i,CHAN,t1P:t2P,conflict,paneli))) - squeeze(nanmean(ON.ERPs(i,CHAN,t1N:t2N,conflict,paneli ))) );
|
|
|
| end
|
| end
|
|
|
| ERPON1 = ERPON_PN(:,1); ERPON2 = ERPON_PN(:,2);
|
| ERPON1(isnan(ERPON1)) = nanmean(ERPON1);
|
| ERPON2(isnan(ERPON2)) = nanmean(ERPON2);
|
| ERPON_PN = [ERPON1 ERPON2];
|
|
|
| ERPCTL_PN(:,3) = ERPCTL_PN(:,2) - ERPCTL_PN(:,1); % Conf2-Conf1
|
| ERPON_PN(:,3) = ERPON_PN(:,2) - ERPON_PN(:,1); % Conf2-Conf1
|
|
|
| ERPCTL_m = nanmean(ERPCTL_PN);
|
| SEMCTL1 = std(ERPCTL_PN(:,1))/sqrt(length(ERPCTL_PN(:,1))); SEMCTL2 = std(ERPCTL_PN(:,2))/sqrt(length(ERPCTL_PN(:,2))); SEMCTL21 = std(ERPCTL_PN(:,3))/sqrt(length(ERPCTL_PN(:,3)));
|
|
|
| ERPON_m = nanmean(ERPON_PN);
|
| SEMON1 = std(ERPON_PN(:,1))/sqrt(length(ERPON_PN(:,1))); SEMON2 = std(ERPON_PN(:,2))/sqrt(length(ERPON_PN(:,2))); SEMON21 = std(ERPON_PN(:,3))/sqrt(length(ERPON_PN(:,3)));
|
|
|
| %%%%%%% ANOVA
|
| p = anova_rm({ERPCTL_PN(:,1:2) ERPON_PN(:,1:2)});
|
| clear p p1 p2 p21;
|
|
|
|
|
| |