Singh2018 / scripts /Figure5_Resp_ERPs_TF_TOPO.m
jalauer's picture
Add files using upload-large-folder tool
d7989aa verified
%% ERPs
clear ;
clc;
close all;
savedir='D:\Project_EEG_CC\CC_Results_step2_AllChannels_NEW\';
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];
CTLsx=[8010,8070,8060,890:914];
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);
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;
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.ERPs(floor(row),:,:,:,:)=ERPs;
OFF.POWER{1}(floor(row),:,:,:,:,:)=POWER;
end
row=row+.5;
clear ERPs Model_Output POWER 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
VECTOR=NaN; ERPs=NaN(size_erp); 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.ERPs(floor(row),:,:,:,:)=ERPs;
CTL.POWER{1}(floor(row),:,:,:,:,:)=POWER;
row=row+1;
clear ERPs Model_Output POWER;
end
CtlN=row-1;
%% % ######################## Response - locked ERPs #################
tx2disp=-500:2:1000;
CHAN=21; % Cz
paneli = 2; % response
%%%% for Control
subplot(321)
shadedErrorBar2(tx2disp,squeeze(nanmean(CTL.ERPs(:,CHAN,:,1,paneli),1)),squeeze(nanstd(CTL.ERPs(:,CHAN,:,1,paneli),1))./sqrt(28),'lineprops','b');hold on
plot(tx2disp,squeeze(nanmean(CTL.ERPs(:,CHAN,:,1,paneli),1)),'b','linewidth',2); hold on
shadedErrorBar2(tx2disp,squeeze(nanmean(CTL.ERPs(:,CHAN,:,2,paneli),1)),squeeze(nanstd(CTL.ERPs(:,CHAN,:,2,paneli),1))./sqrt(28),'lineprops','c');hold on
plot(tx2disp,squeeze(nanmean(CTL.ERPs(:,CHAN,:,2,paneli),1)),'c','linewidth',2); hold on
plot([0 0],[-5 10],'k:'); title(' Control: Cz');hold off; box off; ylim([-3 8]);
%%%% for PD ON
subplot(323)
shadedErrorBar2(tx2disp,squeeze(nanmean(ON.ERPs(:,CHAN,:,1,paneli),1)),squeeze(nanstd(ON.ERPs(:,CHAN,:,1,paneli),1))./sqrt(28),'lineprops','r');hold on
plot(tx2disp,squeeze(nanmean(ON.ERPs(:,CHAN,:,1,paneli),1)),'r','linewidth',2); hold on
shadedErrorBar2(tx2disp,squeeze(nanmean(ON.ERPs(:,CHAN,:,2,paneli),1)),squeeze(nanstd(ON.ERPs(:,CHAN,:,2,paneli),1))./sqrt(28),'lineprops','m');hold on
plot(tx2disp,squeeze(nanmean(ON.ERPs(:,CHAN,:,2,paneli),1)),'m','linewidth',2); hold on
plot([0 0],[-5 10],'k:'); title('PD ON: Cz');hold off; box off; ylim([-3 8]);
% % % ################## Time Frequency #####################
tx2disp=-500:2:1000;
frex=logspace(.01,1.7,50);
Bidx=1; % 1 is pre-cue baseline
CHANI=21; % Cz
EVENT=2; % RESP
%%%%%%%%%%%%%%%%%%%%%%%%% %%% figure for PD OFF/ON - Control
CTL_Conf2 = CTL.POWER{Bidx}(:,CHANI,:,:,2,EVENT); CTL_Conf1 = CTL.POWER{Bidx}(:,CHANI,:,:,1,EVENT);
ON_Conf2 = ON.POWER{Bidx}(:,CHANI,:,:,2,EVENT); ON_Conf1 = ON.POWER{Bidx}(:,CHANI,:,:,1,EVENT);
CTL_Conf12 = (squeeze( nanmean(CTL_Conf2,1)) + squeeze( nanmean(CTL_Conf1,1)))/2;
PD_ON_Conf12 = (squeeze( nanmean(ON_Conf2,1)) + squeeze( nanmean(ON_Conf1,1)))/2;
CTL_Conf21 = squeeze( nanmean(CTL_Conf2,1)) - squeeze( nanmean(CTL_Conf1,1));
PD_ON_Conf21 = squeeze( nanmean(ON_Conf2,1)) - squeeze( nanmean(ON_Conf1,1));
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CONTOL and PD ON %%%%%%%%%%%%%%%%%%%%
%%% CTL-PD ON
subplot(322);
imagesc( tx2disp,[], (CTL_Conf12) - (PD_ON_Conf12) ); axis xy; hold on; colormap jet
[Corrected_P] = Run_Thresh_2D( (squeeze(ON_Conf1)+squeeze(ON_Conf2))/2, (squeeze(CTL_Conf1)+ squeeze(CTL_Conf2))/2, 'between') ;
contour(tx2disp,1:50,Corrected_P,'k','linewidth',2); clear Corrected_P;
plot([0 0],[1 50],'k:')
set(gca,'clim',[-2 2],'xlim',[-500,1000],'ylim',[1 50],'YTick',1:4:length(frex),'YTickLabel',round(frex(1:4:end)));title('CTL-ON (Avg of Correct and Error)');hold off; %colorbar;
subplot(324);
imagesc(tx2disp,[], CTL_Conf21 - PD_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;
rectangle('Position',[-200 18 250 9],'EdgeColor','b','LineWidth', 3);
plot([0 0],[1 50],'k:')
set(gca,'clim',[-2 2],'xlim',[-500,1000],'ylim',[1 50],'YTick',1:4:length(frex),'YTickLabel',round(frex(1:4:end)));hold off; title('CTL-ON (Error-Correct)');
% % % ####################### TOPO ######################################
tx1 = find (tx2disp==-200); tx2 = find (tx2disp==50);
% fq1 = min(find(frex>3)); fq2 = min(find(frex>5));
fq1 = min(find(frex>3.8)); fq2 = min(find(frex>7.8));
for n = 1:28
for Chanl = 1:60
CTL_PowCg = CTL.POWER{1}(n,Chanl,(fq1:fq2),(tx1:tx2),1,paneli); ON_PowCg = ON.POWER{1} (n,Chanl,(fq1:fq2),(tx1:tx2),1,paneli);
CTL_PowIncg = CTL.POWER{1}(n,Chanl,(fq1:fq2),(tx1:tx2),2,paneli); ON_PowIncg = ON.POWER{1} (n,Chanl,(fq1:fq2),(tx1:tx2),2,paneli);
%%%% Incong and Cong ....
IngPow_CTL = squeeze(nanmean(CTL_PowIncg)); CogPow_CTL = squeeze(nanmean(CTL_PowCg));
IngPow_ON = squeeze(nanmean(ON_PowIncg)); CogPow_ON = squeeze(nanmean(ON_PowCg));
IncongCTL(n).chans{Chanl,1} = nanmean(IngPow_CTL); CongCTL(n).chans{Chanl,1} = nanmean(CogPow_CTL);
IncongON(n).chans{Chanl,1} = nanmean(IngPow_ON); CongON(n).chans{Chanl,1} = nanmean(CogPow_ON);
end
end
IncongruentCTL = cell(28,60);CongruentCTL = cell(28,60);
IncongruentON = cell(28,60);CongruentON = cell(28,60);
for n = 1:28
IncongruentCTL(n,:) = IncongCTL(n).chans ;
CongruentCTL(n,:) = CongCTL(n).chans ;
IncongruentON(n,:) = IncongON(n).chans ;
CongruentON(n,:) = CongON(n).chans ;
end
IncongruentCTL = cell2mat(IncongruentCTL); CongruentCTL = cell2mat(CongruentCTL);
IncongruentON = cell2mat(IncongruentON); CongruentON = cell2mat(CongruentON);
chanlocs = BV_Chanlocs_60;
CTL_IncongCong = (IncongruentCTL - CongruentCTL);
ON_IncongCong = (IncongruentON - CongruentON);
% figure
[~,P3,~,~]=ttest2(CTL_IncongCong,ON_IncongCong); P3(P3>=.05)=NaN; P3(P3<.05)=1; P3(isnan(P3))=0;
subplot(326); topoplot(nanmean(CTL_IncongCong-ON_IncongCong),chanlocs,'maplimits',[-0.5 0.5],'emarker2', {find(P3),'d','k',5,1}); title ('Control-PD');colormap jet; clear P3
suptitle ('Response-locked ERPs-TF-TOPO: Conf2 and Conf1')