%% Control and PD OFF: Statistics for POWER ROIs close all;clear;clc; %%%% get the data savedir='D:\Project_EEG_CC\CC_Results_step2_AllChannels_NEW\'; cd(savedir); load('D:\Project_EEG_CC\CC_Project_PostError\ONOFF.mat','ONOFF') PDsx=[801:811,813:829]; % 824 S2 CC is bad (mange here) CTLsx=[8010,8070,8060,890:914]; % 911 S1 CC is bad (mange 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 POWER=NaN(size_power); else load([savedir,num2str(ONOFF(mi,1)),'_Session_',num2str(ONOFF(mi,2)),'_PDDys_CC_ALL_GOODS.mat']); 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.POWER{1}(floor(row),:,:,:,:,:)=POWER; elseif ONOFF(mi,3)==0 % OFF OFF.ID(floor(row))=ONOFF(mi,1); OFF.Session(floor(row))=ONOFF(mi,2); OFF.POWER{1}(floor(row),:,:,:,:,:)=POWER; end row=row+.5; clear 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 POWER=NaN(size_power);POWER_REST=NaN(size_power); else load([savedir,num2str(CTLi),'_Session_1_PDDys_CC_ALL_GOODS.mat']); end CTL.ID(floor(row))=CTLi; CTL.Session(floor(row))=1; CTL.POWER{1}(floor(row),:,:,:,:,:)=POWER; row=row+1; clear POWER; end CtlN=row-1; %% %% Cue-locked Data Correct and Error response: POWER ROI %############# get the POWER of region of interest and ANOVA-ResponseLocked tx2disp=-500:2:1000; frex=logspace(.01,1.7,50); CHANI = 21; %%% channel Cz Bidx=1; % 1 is pre-cue baseline EVENT=1; % cue % Cue-locked t1 = find (tx2disp==400); t2 = find (tx2disp==500); fq1 = min(find(frex>3.8)); fq2 = min(find(frex>7.8)); for i = 1:28 ROI_Pow_CTL_1(i,:) = mean( squeeze(nanmean(CTL.POWER{Bidx}(i,CHANI,fq1:fq2,t1:t2,1,EVENT) ))); ROI_Pow_OFF_1(i,:) = mean( squeeze(nanmean(OFF.POWER{Bidx} (i,CHANI,fq1:fq2,t1:t2,1,EVENT) ))); ROI_Pow_CTL_2(i,:) = mean( squeeze(nanmean(CTL.POWER{Bidx}(i,CHANI,fq1:fq2,t1:t2,2,EVENT) ))); ROI_Pow_OFF_2(i,:) = mean( squeeze(nanmean(OFF.POWER{Bidx} (i,CHANI,fq1:fq2,t1:t2,2,EVENT) ))); end %%% replace NaN with mean value ROI_Pow_OFF_2(isnan(ROI_Pow_OFF_2))=nanmean(ROI_Pow_OFF_2); ROI_Pow_OFF_1(isnan(ROI_Pow_OFF_1))=nanmean(ROI_Pow_OFF_1); % ANOVA ROI_CTL_CI = [ROI_Pow_CTL_1 ROI_Pow_CTL_2 ]; ROI_OFF_CI = [ROI_Pow_OFF_1 ROI_Pow_OFF_2 ]; p = anova_rm({ROI_CTL_CI ROI_OFF_CI}); clear p; %% Response-locked Data Correct and Error response: POWER ROI %############# get the POWER of region of interest and ANOVA-ResponseLocked clearvars -except OFF ON CTL tx2disp=-500:2:1000; frex=logspace(.01,1.7,50); CHANI = 21; %%% channel Cz Bidx=1; % 1 is pre-cue baseline EVENT=2; % RESP % %%%%%%%% RESPONSE-LOCKED % Response-locked t1 = find (tx2disp==-200); t2 = find (tx2disp==50); fq1 = min(find(frex>3.8)); fq2 = min(find(frex>7.8)); for i = 1:28 ROI_Pow_CTL_1(i,:) = mean( squeeze(nanmean(CTL.POWER{Bidx}(i,CHANI,fq1:fq2,t1:t2,1,EVENT) ))); ROI_Pow_OFF_1(i,:) = mean( squeeze(nanmean(OFF.POWER{Bidx} (i,CHANI,fq1:fq2,t1:t2,1,EVENT) ))); ROI_Pow_CTL_2(i,:) = mean( squeeze(nanmean(CTL.POWER{Bidx}(i,CHANI,fq1:fq2,t1:t2,2,EVENT) ))); ROI_Pow_OFF_2(i,:) = mean( squeeze(nanmean(OFF.POWER{Bidx} (i,CHANI,fq1:fq2,t1:t2,2,EVENT) ))); end %%% replace NaN with mean value ROI_Pow_OFF_2(isnan(ROI_Pow_OFF_2))=nanmean(ROI_Pow_OFF_2); ROI_Pow_OFF_1(isnan(ROI_Pow_OFF_1))=nanmean(ROI_Pow_OFF_1); % ANOVA ROI_CTL_CE = [ROI_Pow_CTL_1 ROI_Pow_CTL_2 ]; ROI_OFF_CE = [ROI_Pow_OFF_1 ROI_Pow_OFF_2 ]; p = anova_rm({ROI_CTL_CE ROI_OFF_CE}); clear p ; %% CORRECT only : Cong and Incong close all;clear;clc; %%%% get the data savedir='D:\Project_EEG_CC\CC_Results_step2_CORRECT_NEW\'; cd(savedir); load('D:\Project_EEG_CC\CC_Project_PostError\ONOFF.mat','ONOFF') PDsx=[801:811,813:829]; % 824 S2 CC is bad (mange here) CTLsx=[8010,8070,8060,890:914]; % 911 S1 CC is bad (mange 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 POWER=NaN(size_power); else load([savedir,num2str(ONOFF(mi,1)),'_Session_',num2str(ONOFF(mi,2)),'_PDDys_CC_ALL_GOODS.mat']); 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.POWER{1}(floor(row),:,:,:,:,:)=POWER; elseif ONOFF(mi,3)==0 % OFF OFF.ID(floor(row))=ONOFF(mi,1); OFF.Session(floor(row))=ONOFF(mi,2); OFF.POWER{1}(floor(row),:,:,:,:,:)=POWER; end row=row+.5; clear 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 POWER=NaN(size_power); else load([savedir,num2str(CTLi),'_Session_1_PDDys_CC_ALL_GOODS.mat']); end CTL.ID(floor(row))=CTLi; CTL.Session(floor(row))=1; CTL.POWER{1}(floor(row),:,:,:,:,:)=POWER; row=row+1; clear POWER end CtlN=row-1; % % tx2disp=-500:2:1000; frex=logspace(.01,1.7,50); CHANI = 21; %%% channel Cz Bidx=1; % 1 is pre-cue baseline % %%%%%%%% RESPONSE-LOCKED % Response-locked t1 = find (tx2disp==-200); t2 = find (tx2disp==50); fq1 = min(find(frex>3.8)); fq2 = min(find(frex>7.8)); for i = 1:28 ROI_Pow_CTL_1(i,:) = mean( squeeze(nanmean(CTL.POWER{Bidx}(i,CHANI,fq1:fq2,t1:t2,1) ))); ROI_Pow_OFF_1(i,:) = mean( squeeze(nanmean(OFF.POWER{Bidx} (i,CHANI,fq1:fq2,t1:t2,1) ))); ROI_Pow_CTL_2(i,:) = mean( squeeze(nanmean(CTL.POWER{Bidx}(i,CHANI,fq1:fq2,t1:t2,2) ))); ROI_Pow_OFF_2(i,:) = mean( squeeze(nanmean(OFF.POWER{Bidx} (i,CHANI,fq1:fq2,t1:t2,2) ))); end %%% replace NaN with mean value ROI_Pow_OFF_2(isnan(ROI_Pow_OFF_2))=nanmean(ROI_Pow_OFF_2); ROI_Pow_OFF_1(isnan(ROI_Pow_OFF_1))=nanmean(ROI_Pow_OFF_1); % ANOVA ROI_CTL_CI = [ROI_Pow_CTL_1 ROI_Pow_CTL_2 ]; ROI_OFF_CI = [ROI_Pow_OFF_1 ROI_Pow_OFF_2 ]; p = anova_rm({ROI_CTL_CI ROI_OFF_CI}); clear p; %% Post Correct and Post Error Data: POWER ROI close all; clear; clc; %%%% get the data savedir='D:\Project_EEG_CC\CC_Project_PostError\PostError_step2_Data_NEW\'; % Main Data are here cd(savedir); load('D:\Project_EEG_CC\CC_Project_PostError\ONOFF.mat','ONOFF') PDsx=[801:811,813:829]; % 824 S2 CC is bad (mange here) CTLsx=[8010,8070,8060,890:914]; % 911 S1 CC is bad (mange 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 POWER=NaN(size_power); else load([savedir,num2str(ONOFF(mi,1)),'_Session_',num2str(ONOFF(mi,2)),'_PDDys_CC_ALL_GOODS.mat']); 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.POWER{1}(floor(row),:,:,:,:,:)=POWER; elseif ONOFF(mi,3)==0 % OFF OFF.ID(floor(row))=ONOFF(mi,1); OFF.Session(floor(row))=ONOFF(mi,2); OFF.POWER{1}(floor(row),:,:,:,:,:)=POWER; end row=row+.5; clear 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 POWER=NaN(size_power);POWER_REST=NaN(size_power); else load([savedir,num2str(CTLi),'_Session_1_PDDys_CC_ALL_GOODS.mat']); end CTL.ID(floor(row))=CTLi; CTL.Session(floor(row))=1; CTL.POWER{1}(floor(row),:,:,:,:,:)=POWER; row=row+1; clear POWER end CtlN=row-1; % % ############# get the POWER of region of interest and ANOVA-ResponseLocked tx2disp=-500:2:1000; frex=logspace(.01,1.7,50); CHANI = 21; %%% channel Cz Bidx=1; % 1 is pre-cue baseline EVENT=2; % RESP % %%%%%%%% RESPONSE-LOCKED % Response-locked t1 = find (tx2disp==-200); t2 = find (tx2disp==50); fq1 = min(find(frex>3.8)); fq2 = min(find(frex>7.8)); for i = 1:28 ROI_Pow_CTL_1(i,:) = mean( squeeze(nanmean(CTL.POWER{Bidx}(i,CHANI,fq1:fq2,t1:t2,1,EVENT) ))); ROI_Pow_OFF_1(i,:) = mean( squeeze(nanmean(OFF.POWER{Bidx} (i,CHANI,fq1:fq2,t1:t2,1,EVENT) ))); ROI_Pow_CTL_2(i,:) = mean( squeeze(nanmean(CTL.POWER{Bidx}(i,CHANI,fq1:fq2,t1:t2,2,EVENT) ))); ROI_Pow_OFF_2(i,:) = mean( squeeze(nanmean(OFF.POWER{Bidx} (i,CHANI,fq1:fq2,t1:t2,2,EVENT) ))); end %%% replace NaN with mean value ROI_Pow_OFF_2(isnan(ROI_Pow_OFF_2))=nanmean(ROI_Pow_OFF_2); ROI_Pow_OFF_1(isnan(ROI_Pow_OFF_1))=nanmean(ROI_Pow_OFF_1); % ANOVA ROI_CTL_PCE = [ROI_Pow_CTL_1 ROI_Pow_CTL_2 ]; ROI_OFF_PCE = [ROI_Pow_OFF_1 ROI_Pow_OFF_2 ]; p = anova_rm({ROI_CTL_PCE ROI_OFF_PCE}); clear p ;