Singh2018 / scripts /FigureS3_ITPC.m
jalauer's picture
Add files using upload-large-folder tool
d7989aa verified
%% ITPC Plots
clear; clc; close all;
savedir='D:\Project_EEG_CC\CC_Results_step2_AllChannels_NEW\'; % Main Data are here
cd(savedir);
load('D:\Project_EEG_CC\mFiles\ONOFF.mat','ONOFF')
load('D:\Project_EEG_CC\mFiles\BV_Chanlocs_60.mat');
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
ITPC=NaN(size_ITPC);
else
load([savedir,num2str(ONOFF(mi,1)),'_Session_',num2str(ONOFF(mi,2)),'_PDDys_CC_ALL_GOODS.mat']);
size_ITPC=size(ITPC);
end
if ONOFF(mi,3)==1 % ON
ON.ID(floor(row))=ONOFF(mi,1);
ON.Session(floor(row))=ONOFF(mi,2);
ON.ITPC(floor(row),:,:,:,:,:)=ITPC;
elseif ONOFF(mi,3)==0 % OFF
OFF.ID(floor(row))=ONOFF(mi,1);
OFF.Session(floor(row))=ONOFF(mi,2);
OFF.ITPC(floor(row),:,:,:,:,:)=ITPC;
end
row=row+.5;
clear ITPC;
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
ITPC=NaN(size_ITPC);
else
load([savedir,num2str(CTLi),'_Session_1_PDDys_CC_ALL_GOODS.mat']);
end
CTL.ID(floor(row))=CTLi;
CTL.Session(floor(row))=1;
CTL.ITPC(floor(row),:,:,:,:,:)=ITPC;
row=row+1;
clear ERPs VECTOR Model_Output POWER ITPC;
end
CtlN=row-1;
%% #############################################################################
clearvars -except CTL ON OFF
tx2disp=-500:2:1000;
frex=logspace(.01,1.7,50);
CHANI=21; % channel Cz
EVENT=1; % CUE, RESP
%%%%%%%%%%%%%%%%%%%%%%%%% %%% figure for PD OFF/ON - Control
OFF_Conf2 = OFF.ITPC(:,CHANI,:,:,2,EVENT); OFF_Conf1 = OFF.ITPC(:,CHANI,:,:,1,EVENT);
ON_Conf2 = ON.ITPC(:,CHANI,:,:,2,EVENT); ON_Conf1 = ON.ITPC(:,CHANI,:,:,1,EVENT);
CTL_Conf2 = CTL.ITPC(:,CHANI,:,:,2,EVENT); CTL_Conf1 = CTL.ITPC(:,CHANI,:,:,1,EVENT);
OFF_Conf21 = squeeze( nanmean(OFF_Conf2,1)) - squeeze( nanmean(OFF_Conf1,1));
ON_Conf21 = squeeze( nanmean(ON_Conf2,1)) - squeeze( nanmean(ON_Conf1,1));
CTL_Conf21 = squeeze( nanmean(CTL_Conf2,1)) - squeeze( nanmean(CTL_Conf1,1));
% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CONTOL and PD ON %%%%%%%%%%%%%%%%%%%%
%%% CTL-PD ON
subplot(331);
imagesc( tx2disp,[], squeeze(nanmean(CTL_Conf1)) - squeeze(nanmean(ON_Conf1)) ); axis xy; hold on; colormap jet
[Corrected_P] = Run_Thresh_2D( squeeze(ON_Conf1), squeeze(CTL_Conf1), 'between' ) ;
contour(tx2disp,1:50,Corrected_P,'k','linewidth',2); clear Corrected_P;
plot([0 0],[1 50],'k:')
set(gca,'clim',[-0.1 0.1],'xlim',[-500,1000],'ylim',[1 50],'YTick',1:4:length(frex),'YTickLabel',round(frex(1:4:end)));title('Cue:CTL-ON (Cong)');hold off; colormap jet
subplot(332);
imagesc( tx2disp,[], squeeze(nanmean(CTL_Conf2)) - squeeze(nanmean(ON_Conf2)) ); axis xy; hold on; colormap jet
[Corrected_P] = Run_Thresh_2D( squeeze(ON_Conf2), squeeze(CTL_Conf2), 'between' ) ;
contour(tx2disp,1:50,Corrected_P,'k','linewidth',2); clear Corrected_P;
plot([0 0],[1 50],'k:')
set(gca,'clim',[-0.1 0.1],'xlim',[-500,1000],'ylim',[1 50],'YTick',1:4:length(frex),'YTickLabel',round(frex(1:4:end)));title('Cue:CTL-ON (Incong)');hold off; colormap jet
subplot(333);
imagesc(tx2disp,[], CTL_Conf21 - ON_Conf21); axis xy; hold on; colormap jet
[Corrected_P] = Run_Thresh_2D(squeeze(ON_Conf2)- squeeze(ON_Conf1), squeeze(CTL_Conf2)- squeeze(CTL_Conf1), 'between') ;
contour(tx2disp,1:50,Corrected_P,'k','linewidth',2); clear Corrected_P;
plot([0 0],[1 50],'k:')
set(gca,'clim',[-0.1 0.1],'xlim',[-500,1000],'ylim',[1 50],'YTick',1:4:length(frex),'YTickLabel',round(frex(1:4:end)));hold off; title('Cue:Control - PD ON (Incong-Cong)'); colormap jet
% % %%%%% Response-LOCKED
clearvars -except CTL ON OFF
tx2disp=-500:2:1000;
frex=logspace(.01,1.7,50);
CHANI=21; % channel Cz
EVENT=2; % CUE, RESP
%%%%%%%%%%%%%%%%%%%%%%%%% %%% figure for PD OFF/ON - Control
OFF_Conf2 = OFF.ITPC(:,CHANI,:,:,2,EVENT); OFF_Conf1 = OFF.ITPC(:,CHANI,:,:,1,EVENT);
ON_Conf2 = ON.ITPC(:,CHANI,:,:,2,EVENT); ON_Conf1 = ON.ITPC(:,CHANI,:,:,1,EVENT);
CTL_Conf2 = CTL.ITPC(:,CHANI,:,:,2,EVENT); CTL_Conf1 = CTL.ITPC(:,CHANI,:,:,1,EVENT);
OFF_Conf21 = squeeze( nanmean(OFF_Conf2,1)) - squeeze( nanmean(OFF_Conf1,1));
ON_Conf21 = squeeze( nanmean(ON_Conf2,1)) - squeeze( nanmean(ON_Conf1,1));
CTL_Conf21 = squeeze( nanmean(CTL_Conf2,1)) - squeeze( nanmean(CTL_Conf1,1));
% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CONTOL and PD ON %%%%%%%%%%%%%%%%%%%%
%%% CTL-PD ON
subplot(334);
imagesc( tx2disp,[], squeeze(nanmean(CTL_Conf1)) - squeeze(nanmean(ON_Conf1)) ); axis xy; hold on; colormap jet
[Corrected_P] = Run_Thresh_2D( squeeze(ON_Conf1), squeeze(CTL_Conf1), 'between' ) ;
contour(tx2disp,1:50,Corrected_P,'k','linewidth',2); clear Corrected_P;
plot([0 0],[1 50],'k:')
set(gca,'clim',[-0.2 0.2],'xlim',[-500,1000],'ylim',[1 50],'YTick',1:4:length(frex),'YTickLabel',round(frex(1:4:end)));title('Resp:CTL-ON (Correct)');hold off; colormap jet
subplot(335);
imagesc( tx2disp,[], squeeze(nanmean(CTL_Conf2)) - squeeze(nanmean(ON_Conf2)) ); axis xy; hold on; colormap jet
[Corrected_P] = Run_Thresh_2D( squeeze(ON_Conf2), squeeze(CTL_Conf2), 'between' ) ;
contour(tx2disp,1:50,Corrected_P,'k','linewidth',2); clear Corrected_P;
plot([0 0],[1 50],'k:')
set(gca,'clim',[-0.2 0.2],'xlim',[-500,1000],'ylim',[1 50],'YTick',1:4:length(frex),'YTickLabel',round(frex(1:4:end)));title('Resp:CTL-ON (Error)');hold off; colormap jet
subplot(336);
imagesc(tx2disp,[], CTL_Conf21 - ON_Conf21); axis xy; hold on; colormap jet
[Corrected_P] = Run_Thresh_2D(squeeze(ON_Conf2)- squeeze(ON_Conf1), squeeze(CTL_Conf2)- squeeze(CTL_Conf1), 'between') ;
contour(tx2disp,1:50,Corrected_P,'k','linewidth',2); clear Corrected_P;
plot([0 0],[1 50],'k:')
set(gca,'clim',[-0.2 0.2],'xlim',[-500,1000],'ylim',[1 50],'YTick',1:4:length(frex),'YTickLabel',round(frex(1:4:end)));hold off; title('Resp:Control - PD ON (Error-Correct)'); colormap jet
%% for PostCorrect and PostError ITPC Results
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')
load('D:\Project_EEG_CC\CC_Project_PostError\BV_Chanlocs_60.mat');
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
ITPC=NaN(size_ITPC);
else
load([savedir,num2str(ONOFF(mi,1)),'_Session_',num2str(ONOFF(mi,2)),'_PDDys_CC_ALL_GOODS.mat']);
size_ITPC=size(ITPC);
end
if ONOFF(mi,3)==1 % ON
ON.ID(floor(row))=ONOFF(mi,1);
ON.Session(floor(row))=ONOFF(mi,2);
ON.ITPC(floor(row),:,:,:,:,:)=ITPC;
elseif ONOFF(mi,3)==0 % OFF
OFF.ID(floor(row))=ONOFF(mi,1);
OFF.Session(floor(row))=ONOFF(mi,2);
OFF.ITPC(floor(row),:,:,:,:,:)=ITPC;
end
row=row+.5;
clear ITPC;
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
ITPC=NaN(size_ITPC);
else
load([savedir,num2str(CTLi),'_Session_1_PDDys_CC_ALL_GOODS.mat']);
end
CTL.ID(floor(row))=CTLi;
CTL.Session(floor(row))=1;
CTL.ITPC(floor(row),:,:,:,:,:)=ITPC;
row=row+1;
clear ERPs VECTOR Model_Output POWER ITPC;
end
CtlN=row-1;
% ##########################################
tx2disp=-500:2:1000;
frex=logspace(.01,1.7,50);
CHANI=21; % channel Cz
EVENT=2; % CUE, RESP
%%%%%%%%%%%%%%%%%%%%%%%%% %%% figure for PD OFF/ON - Control
OFF_Conf2 = OFF.ITPC(:,CHANI,:,:,2,EVENT); OFF_Conf1 = OFF.ITPC(:,CHANI,:,:,1,EVENT);
ON_Conf2 = ON.ITPC(:,CHANI,:,:,2,EVENT); ON_Conf1 = ON.ITPC(:,CHANI,:,:,1,EVENT);
CTL_Conf2 = CTL.ITPC(:,CHANI,:,:,2,EVENT); CTL_Conf1 = CTL.ITPC(:,CHANI,:,:,1,EVENT);
OFF_Conf21 = squeeze( nanmean(OFF_Conf2,1)) - squeeze( nanmean(OFF_Conf1,1));
ON_Conf21 = squeeze( nanmean(ON_Conf2,1)) - squeeze( nanmean(ON_Conf1,1));
CTL_Conf21 = squeeze( nanmean(CTL_Conf2,1)) - squeeze( nanmean(CTL_Conf1,1));
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CONTOL and PD ON %%%%%%%%%%%%%%%%%%%%
%%% CTL-PD ON
subplot(337);
imagesc( tx2disp,[], squeeze(nanmean(CTL_Conf1)) - squeeze(nanmean(ON_Conf1)) ); axis xy; hold on; colormap jet
[Corrected_P] = Run_Thresh_2D (squeeze(ON_Conf1), squeeze(CTL_Conf1), 'between') ;
contour(tx2disp,1:50,Corrected_P,'k','linewidth',2); clear Corrected_P ;
plot([0 0],[1 50],'k:')
set(gca,'clim',[-0.2 0.2],'xlim',[-500,1000],'ylim',[1 50],'YTick',1:4:length(frex),'YTickLabel',round(frex(1:4:end)));title('PEC:CTL-ON (Post-Correct)');hold off; colormap jet
subplot(338);
imagesc( tx2disp,[], squeeze(nanmean(CTL_Conf2)) - squeeze(nanmean(ON_Conf2)) ); axis xy; hold on; colormap jet
[Corrected_P] = Run_Thresh_2D( squeeze(ON_Conf2), squeeze(CTL_Conf2), 'between' ) ;
contour(tx2disp,1:50,Corrected_P,'k','linewidth',2); clear Corrected_P;
plot([0 0],[1 50],'k:')
set(gca,'clim',[-0.2 0.2],'xlim',[-500,1000],'ylim',[1 50],'YTick',1:4:length(frex),'YTickLabel',round(frex(1:4:end)));title('PEC:CTL-ON (Post-Error)');hold off; colormap jet
subplot(339);
imagesc(tx2disp,[], CTL_Conf21 - ON_Conf21); axis xy; hold on; colormap jet
[Corrected_P] = Run_Thresh_2D(squeeze(ON_Conf2)- squeeze(ON_Conf1), squeeze(CTL_Conf2)- squeeze(CTL_Conf1), 'between') ;
contour(tx2disp,1:50,Corrected_P,'k','linewidth',2); clear Corrected_P;
plot([0 0],[1 50],'k:')
set(gca,'clim',[-0.2 0.2],'xlim',[-500,1000],'ylim',[1 50],'YTick',1:4:length(frex),'YTickLabel',round(frex(1:4:end)));hold off; title('PEC:Control - PD ON (PostError-PostCorrect)'); colormap jet
suptitle ('ITPC: Control - PD ON');