Singh2018 / scripts /Figure3_Cue_ERP_TF_TOPO.m
jalauer's picture
Add files using upload-large-folder tool
d7989aa verified
%% Cue-locked figure: Conf1 = Congruent ; Conf2 = Incongruent
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')
load('D:\Project_EEG_CC\mFiles\BV_Chanlocs_60.mat');
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);
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 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);
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 VECTOR POWER ;
end
CtlN=row-1;
%% ################################## ERPs......Cue-locked #############
tx2disp=-500:2:1000;
frex=logspace(.01,1.7,50);
CHAN=21; % Cz
paneli = 1; % Cue
figure;
%%%% for Control
subplot(341)
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 3]);
%%%% for PD ON
subplot(345)
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 3]);
% % &&&&&&&&&&&&&&&&&&&&& Time Frequnecy &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
tx2disp=-500:2:1000;
frex=logspace(.01,1.7,50);
Bidx=1; % 1 is pre-cue baseline
CHANI=21; % channel 21 Cz
%%%%%%%%%%%%%%%%%%%%%%%%% %%% figure for PD OFF/ON - Control
CTL_Conf2 = CTL.POWER{Bidx}(:,CHANI,:,:,2,paneli); CTL_Conf1 = CTL.POWER{Bidx}(:,CHANI,:,:,1,paneli);
ON_Conf2 = ON.POWER{Bidx}(:,CHANI,:,:,2,paneli); ON_Conf1 = ON.POWER{Bidx}(:,CHANI,:,:,1,paneli);
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 %%%%%%%%%%%%%%%%%%%%
%%% Control
subplot(342);
imagesc(tx2disp,[], CTL_Conf12); axis xy; hold on;colormap jet
plot([0 0],[1 50],'k:')
set(gca,'clim',[-4 4],'xlim',[-500,1000],'ylim',[1 50],'YTick',1:4:length(frex),'YTickLabel',round(frex(1:4:end)));hold off ; title ('CTL:Avg of Cong and Incong');
subplot(343);
imagesc(tx2disp,[], CTL_Conf21); axis xy; hold on; colormap jet
[Corrected_P] = Run_Thresh_2D(squeeze(CTL_Conf2 ) , squeeze(CTL_Conf1), 'within');
contour(tx2disp,1:50,Corrected_P,'k','linewidth',2); clear Corrected_P;
plot([0 0],[1 50],'k:')
set(gca,'clim',[-1 1],'xlim',[-500,1000],'ylim',[1 50],'YTick',1:4:length(frex),'YTickLabel',round(frex(1:4:end)));hold off; title ('CTL:Incong-Cong');
%%% PD ON
subplot(346);
imagesc(tx2disp,[],PD_ON_Conf12); axis xy; hold on;colormap jet
plot([0 0],[1 50],'k:')
set(gca,'clim',[-4 4],'xlim',[-500,1000],'ylim',[1 50],'YTick',1:4:length(frex),'YTickLabel',round(frex(1:4:end)));hold off; title ('PD ON: Avg of Cong and Incong');
subplot(347);
imagesc(tx2disp,[],PD_ON_Conf21); axis xy; hold on; colormap jet
[Corrected_P] = Run_Thresh_2D(squeeze(ON_Conf2 ) , squeeze(ON_Conf1), 'within');
contour(tx2disp,1:50,Corrected_P,'k','linewidth',2); clear Corrected_P;
plot([0 0],[1 50],'k:')
set(gca,'clim',[-1 1],'xlim',[-500,1000],'ylim',[1 50],'YTick',1:4:length(frex),'YTickLabel',round(frex(1:4:end)));hold off; title ('PD ON: Incong-Cong');
%%% CTL-PD ON
subplot(3,4,10);
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 Cong and Incong)');hold off; %colorbar;
subplot(3,4,11);
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 ;
plot([0 0],[1 50],'k:');
% plot ROI in blue Color
rectangle('Position',[400 18 100 9],'EdgeColor','b','LineWidth', 3)
set(gca,'clim',[-0.5 0.5],'xlim',[-500,1000],'ylim',[1 50],'YTick',1:4:length(frex),'YTickLabel',round(frex(1:4:end)));hold off; title('CTL-ON (Incong-Cong)');
% % ############################ TOPO ################################## ####################### TOPO ######################################
tx1 = find (tx2disp==400); tx2 = find (tx2disp==500);
% fq1 = min(find(frex>3)); fq2 = min(find(frex>6)); %%% older
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);
load('D:\Project_EEG_CC\mFiles\BV_Chanlocs_60.mat');chanlocs = BV_Chanlocs_60;
CTL_IncongCong = (IncongruentCTL - CongruentCTL);
ON_IncongCong = (IncongruentON - CongruentON);
% figure
[~,P1,~,~]=ttest(IncongruentCTL, CongruentCTL); P1(P1>=.05)=NaN; P1(P1<.05)=1; P1(isnan(P1))=0;
subplot(344); topoplot(nanmean(IncongruentCTL-CongruentCTL,1),chanlocs,'maplimits',[-1 1],'emarker2', {find(P1),'d','k',5,1}); title ('Control: Incong-Cong');colormap jet; clear P1
[~,P2,~,~]=ttest(IncongruentON, CongruentON); P2(P2>=.05)=NaN; P2(P2<.05)=1; P2(isnan(P2))=0;
subplot(348); topoplot(nanmean(IncongruentON-CongruentON,1),chanlocs,'maplimits',[-1 1],'emarker2', {find(P2),'d','k',5,1}); title ('PD');colormap jet; clear P2
[~,P3,~,~]=ttest2(CTL_IncongCong,ON_IncongCong); P3(P3>=.05)=NaN; P3(P3<.05)=1; P3(isnan(P3))=0;
subplot(3,4,12); 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 ('Cue-locked ERPs-TF-TOPO: Incong and Cong')