File size: 11,797 Bytes
d7989aa |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
%% SFFT Topoplots of REST and PRE-CUE data
clear; clc; close all;
datalocation = ('D:\Project_EEG_CC\SFFT_TopoFigure\Data_Topo_new\');
cd(datalocation)
savedirOFF='D:\Project_EEG_CC\SFFT_TopoFigure\Data_Topo_new\OFF\'; % OFF Data are here
savedirON='D:\Project_EEG_CC\SFFT_TopoFigure\Data_Topo_new\ON\'; % ON Data are here
savedirCTL='D:\Project_EEG_CC\SFFT_TopoFigure\Data_Topo_new\Control\'; % Control Data are here
load('D:\Project_EEG_CC\mFiles\ONOFF.mat','ONOFF')
BigN=size(ONOFF,1)./2;
off = [2 1 1 2 2 1 1 1 2 2 2 1 2 2 1 1 2 1 1 2 2 1 1 2 2 1 1 1];
on = [ 1 2 2 1 1 2 2 2 1 1 1 2 1 1 2 2 1 2 2 1 1 2 1 1 1 2 2 2];
%%%%% OFF and Control data
for mi=1:28
%%%%%%%%%% OFF data %%%%%%%%%%%%%%%%%%%%%%%
PDsx=[801:811,813:829];
load([savedirOFF,num2str(PDsx(1,mi)),'_Session_',num2str(off(1,mi)),'_PDDys_CC_ALL_TOPO.mat']);
mData_Cue_OFF = cell2mat(mData_Cue);
CueDataOFF{mi,:} = mData_Cue_OFF;
mData_REST_OFF = cell2mat(mData_REST);
RESTDataOFF{mi,:} = mData_REST_OFF;
clear mData_Cue mData_Cue_OFF mData_REST mData_REST_OFF
%%%%%%%%%%%% ON data %%%%%%%%%%%%%%%%%%%%%% for 824 off= on
%%%%%%%%%%%%
load([savedirON,num2str(PDsx(1,mi)),'_Session_',num2str(on(1,mi)),'_PDDys_CC_ALL_TOPO.mat']);
mData_Cue_ON = cell2mat(mData_Cue);
CueDataON{mi,:} = mData_Cue_ON;
mData_REST_ON = cell2mat(mData_REST);
RESTDataON{mi,:} = mData_REST_ON;
clear mData_Cue mData_Cue_ON mData_REST mData_REST_ON
%%%%%%%%%%%%% Control %%%%%%%%%%%%%%%%%%%%%%%%%
CTLsx=[8010,8070,8060,890:914];
load([savedirCTL,num2str(CTLsx(1,mi)),'_Session_1','_PDDys_CC_ALL_TOPO.mat']);
mData_Cue_CTL = cell2mat(mData_Cue);
CueDataCTL{mi,:} = mData_Cue_CTL;
mData_REST_CTL = cell2mat(mData_REST);
RESTDataCTL{mi,:} = mData_REST_CTL;
clear mData_Cue mData_Cue_CTL mData_REST mData_REST_CTL
end
clearvars -except CueDataOFF RESTDataOFF CueDataON RESTDataON CueDataCTL RESTDataCTL
tx2disp =-1500:2:4998;
%% #############################%%%%%%%%%%%%% REST DATA %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fs = 500;
% define analysis parameters
xlen = length(RESTDataOFF{1,:}(:,1)); % length of the signal
wlen = 128; % window length (recomended to be power of 2)
nop = []; % hop size (recomended to be power of 2)
nfft = 256; % number of fft points (recomended to be power of 2)
for n=1:28
for ch = 1:60
[sNr,fyr,txr] = spectrogram(RESTDataON {n,:}(:,ch),wlen,nop,nfft,fs, 'yaxis'); sON_All_Rt {n,:}.sub{ch,:} = abs(sNr).^2; %
[sCr,fyr,txr] = spectrogram(RESTDataCTL{n,:}(:,ch),wlen,nop,nfft,fs, 'yaxis'); sCTL_All_Rt{n,:}.sub{ch,:} = abs(sCr).^2; %
end
end
clear sFr sNr sCr
% % %%%%%%%%%%%%%%%%%%%%% For REST Data 0-50 Hz frequncy band %%%%%%%%%%%%%%%%%%%%%
band1= (find(fyr==0)); band2 = find(fyr<51, 1, 'last' ); %
ch = 21; % channel Cz
for n = 1:28
%%%%%%%%%%%%%%%% ON %%%%%%%%%%%%%%%%
ONbandRt(n,:).band = sON_All_Rt{n, 1}.sub{ch, 1}(band1:band2,:) ;
%%%%%%%%%%%%%%%% CONTROL %%%%%%%%%%%%%%%%
CTLbandRt(n,:).band = sCTL_All_Rt{n, 1}.sub{ch, 1}(band1:band2,:) ;
end
% %
for n = 1:28
%%%%%%%%%%%%%%%% ON %%%%%%%%%%%%%%%%
ONRt_fband{n} = double(mean(ONbandRt(n).band,2));
%%%%%%%%%%%%%%%% CONTROL %%%%%%%%%%%%%%%%
CTLRt_fband{n} = double(mean(CTLbandRt(n).band,2));
end
%
ONRt_fband = cell2mat(ONRt_fband);
CTLRt_fband = cell2mat(CTLRt_fband);
fyL2 = round (double(fyr(band1:band2)) );
tnR = size(ONRt_fband,2);
sONRt = double(log10(ONRt_fband));
sCTLRt = double(log10(CTLRt_fband));
subplot(2,4,[1 5])
shadedErrorBar(fyL2,mean(sCTLRt,2),std(sCTLRt,0,2)/sqrt(tnR),'k',1); hold on;
shadedErrorBar(fyL2,mean(sONRt,2), std(sONRt,0,2)/sqrt(tnR), 'r',1); hold on;
% %% T test for FFT data
TEMP_ON = ONRt_fband';
TEMP_CTL = CTLRt_fband';
%%%% ON vs CTL
[~,P1,~,STATS1]=ttest2(TEMP_ON,TEMP_CTL);
P1(P1>=.05)=NaN; P1(P1<.05)=1;
plot(fyL2,log10(15*P1),'*b','MarkerSize',5); hold off; clear TEMP_ON TEMP_CTL
xlim([0 50]); box off; ylim([0 5]);
xlabel('Frequency (Hz)'); ylabel('Log power(\muV^2)'); title ('REST(Black=CTL; Red = PD ON)');
% % %%% for TOPO REST data
Thr1= min(find(fyr>4)); Thr2 = max(find(fyr<8)); % Theta
Alr1= min(find(fyr>8)); Alr2 = max(find(fyr<13)); % Alpha
for n = 1:28
for ch = 1:60
%%%%%%%%%%%%%%%% ON %%%%%%%%%%%%%%%%
ONfreqbandRt{n,ch}.Theta = double( mean2(sON_All_Rt{n, 1}.sub{ch, 1}(Thr1:Thr2, :)) ) ;
ONfreqbandRt{n,ch}.Alpha = double( mean2(sON_All_Rt{n, 1}.sub{ch, 1}(Alr1:Alr2, :)) ) ;
%%%%%%%%%%%%%%%% CONTROL %%%%%%%%%%%%%%%%
CTLfreqbandRt{n,ch}.Theta = double( mean2(sCTL_All_Rt{n, 1}.sub{ch, 1}(Thr1:Thr2, :)) ) ;
CTLfreqbandRt{n,ch}.Alpha = double( mean2(sCTL_All_Rt{n, 1}.sub{ch, 1}(Alr1:Alr2, :)) ) ;
end
end
%% ############################################# Pre-Cue Data ###########################################################
fs = 500;
% define analysis parameters
xlen = length(CueDataOFF{1,:}(:,1)); % length of the signal
wlen = 128; % window length (recomended to be power of 2)
nop = []; % hop size (recomended to be power of 2)
nfft = 256; % number of fft points (recomended to be power of 2)
for n=1:28
for ch = 1:60
%%%%%%%%%%%%% Pre Cue Data
[sF,fy,tx] = spectrogram(CueDataOFF{n,:}(:,ch),wlen,nop,nfft,fs, 'yaxis'); sOFF_All{n,:}.sub{ch,:} = abs(sF).^2; % in power
[sN,fy,tx] = spectrogram(CueDataON{n,:} (:,ch),wlen,nop,nfft,fs, 'yaxis'); sON_All {n,:}.sub{ch,:} = abs(sN).^2; %
[sC,fy,tx] = spectrogram(CueDataCTL{n,:}(:,ch),wlen,nop,nfft,fs, 'yaxis'); sCTL_All{n,:}.sub{ch,:} = abs(sC).^2; %
end
end
clearvars sF sN sC
% % %%%%%%%%%%%%%%%%%%%%% For Pre-Cue Data 0-50 Hz frequncy band: -0.5 to 0 ms %%%%%%%%%%%%%%%%%%%%%
band1= (find(fy==0)); band2 = find(fy<51, 1, 'last' ); %
xp1 = max(find(tx<1.0)); xp2 = find(tx==1.5 | tx < 1.6, 1, 'last' ); %%% for Pre-Cue Data
ch = 21; % channel Cz
for n = 1:28
%%%%%%%%%%%%%%%% ON %%%%%%%%%%%%%%%%
ONbandPC(n,:).band = sON_All{n, 1}.sub{ch, 1}(band1:band2, xp1:xp2) ;
%%%%%%%%%%%%%%%% CONTROL %%%%%%%%%%%%%%%%
CTLbandPC(n,:).band = sCTL_All{n, 1}.sub{ch, 1}(band1:band2, xp1:xp2) ;
end
for n = 1:28
%%%%%%%%%%%%%%%% ON %%%%%%%%%%%%%%%%
ONPC_fband{n} = nanmean(ONbandPC(n).band,2);
%%%%%%%%%%%%%%%% CONTROL %%%%%%%%%%%%%%%%
CTLPC_fband{n} = nanmean(CTLbandPC(n).band,2);
end
ONPC_fband = cell2mat(ONPC_fband);
CTLPC_fband = cell2mat(CTLPC_fband);
fyL = round (double(fy(band1:band2)) );
tnP = size(ONPC_fband,2);
sONPC = double(log10(ONPC_fband));
sCTLPC = double(log10(CTLPC_fband));
subplot(2,4,[3 7])
shadedErrorBar(fyL,mean(sCTLPC,2),std(sCTLPC,0,2)/sqrt(tnP),'k',1); hold on;
shadedErrorBar(fyL,mean(sONPC,2), std(sONPC,0,2)/sqrt(tnP), 'r',1); hold on;
% %% T test for FFT data
TEMP_ON = ONPC_fband';
TEMP_CTL = CTLPC_fband';
%%%% ON vs CTL
[~,P2,~,STATS2]=ttest2(TEMP_ON,TEMP_CTL);
P2(P2>=.05)=NaN; P2(P2<.05)=1;
plot(fyL2,log10(10*P2),'*b','MarkerSize',5); hold off; clear TEMP_ON TEMP_CTL
xlim([0 50]); box off; ylim([-1 5]);
xlabel('Frequency (Hz)'); ylabel('Log power(\muV^2)'); title ('Pre-Cue -500 -0(Black=CTL; Red = PD ON)');
%%%%% Get Frequency bands info for PreCue for TOPO
Th1= min(find(fy>4)); Th2 = max(find(fy<8)); % Theta
Al1= min(find(fy>8)); Al2 = max(find(fy<13)); % Alpha
%%%%%%%%%%%%%%%%%%%%%%% For Pre-Cue Data %%%%%%%%%%%%%%%%%%%%%
for n = 1:28
for ch = 1:60
%%%%%%%%%%%%%%%% ON %%%%%%%%%%%%%%%%
ONfreqbandPC{n,ch}.Theta = double( mean2(sON_All{n, 1}.sub{ch, 1}(Th1:Th2, xp1:xp2)) ) ;
ONfreqbandPC{n,ch}.Alpha = double( mean2(sON_All{n, 1}.sub{ch, 1}(Al1:Al2, xp1:xp2)) ) ;
%%%%%%%%%%%%%%%% CONTROL %%%%%%%%%%%%%%%%
CTLfreqbandPC{n,ch}.Theta = double( mean2(sCTL_All{n, 1}.sub{ch, 1}(Th1:Th2, xp1:xp2)) ) ;
CTLfreqbandPC{n,ch}.Alpha = double( mean2(sCTL_All{n, 1}.sub{ch, 1}(Al1:Al2, xp1:xp2)) ) ;
end
end
%% FOR TOPO
% clearvars -except OFFfreqbandPC ONfreqbandPC CTLfreqbandPC OFFfreqbandRs ONfreqbandRs CTLfreqbandRs OFFfreqbandRt ONfreqbandRt CTLfreqbandRt
% % Export data according to the band
for n = 1:28
for ch = 1:60
%%%%%%%%% CONTROL %%%%%%%%%%%%%%%%%%%%
%%%%% PreCue
CTL.Theta.PC(n,ch) = CTLfreqbandPC{n, ch}.Theta;
CTL.Alpha.PC(n,ch) = CTLfreqbandPC{n, ch}.Alpha;
%%%% REST
CTL.Theta.Rt(n,ch) = CTLfreqbandRt{n, ch}.Theta;
CTL.Alpha.Rt(n,ch) = CTLfreqbandRt{n, ch}.Alpha;
%%%%%%%%%%%%%% ON %%%%%%%%%%%%%%
%%%%% PreCue
ON.Theta.PC(n,ch) = ONfreqbandPC{n, ch}.Theta;
ON.Alpha.PC(n,ch) = ONfreqbandPC{n, ch}.Alpha;
%%%% REST
ON.Theta.Rt(n,ch) = ONfreqbandRt{n, ch}.Theta;
ON.Alpha.Rt(n,ch) = ONfreqbandRt{n, ch}.Alpha;
end
end
%% statistics analysis for REST and Pre Cue...Theta and Alpha bands
ch = 21; % channel Cz
[~,Prt,~,STATSrt]=ttest2(CTL.Theta.Rt(:,ch), ON.Theta.Rt(:,ch)); Theta_state_RT = ['Theta REST: t value = ',num2str(STATSrt.tstat ),'; p value = ' num2str(Prt)]; disp(Theta_state_RT);
[~,Pra,~,STATSra]=ttest2(CTL.Alpha.Rt(:,ch), ON.Alpha.Rt(:,ch)); Alpha_state_RT = ['Alpha REST: t value = ',num2str(STATSra.tstat ),'; p value = ' num2str(Pra)]; disp(Alpha_state_RT);
[~,Ppt,~,STATSpt]=ttest2(CTL.Theta.PC(:,ch), ON.Theta.PC(:,ch)); Theta_state_PC = ['Theta PreCue: t value = ',num2str(STATSpt.tstat ),'; p value = ' num2str(Ppt)]; disp(Theta_state_PC);
[~,Ppa,~,STATSpa]=ttest2(CTL.Alpha.PC(:,ch), ON.Alpha.PC(:,ch)); Alpha_state_PC = ['Alpha PreCue: t value = ',num2str(STATSpa.tstat ),'; p value = ' num2str(Ppa)]; disp(Alpha_state_PC);
%% plot topo
load('D:\Project_EEG_CC\mFiles\BV_Chanlocs_60.mat'); chanlocs = BV_Chanlocs_60;
%%%% CONTROL - ON
% %%%%%%%% for REST data
cad =[-100000 100000]; cat =[-5000 5000]; caa = [-500 500]; cab = [-40 40]; cag = [-20 20];
subplot(242);[~,P,~,~]=ttest2(CTL.Theta.Rt, ON.Theta.Rt); P(P>=.05)=NaN; P(P<.05)=1; P(isnan(P))=0;
topoplot((mean(CTL.Theta.Rt)- mean(ON.Theta.Rt)),chanlocs,'maplimits',[-3 3],'emarker2', {find(P),'d','k',5,1}); clear P; title ('REST:Theta (CTL-PD ON)');caxis(cat);colormap jet;
subplot(246);[~,P,~,~]=ttest2(CTL.Alpha.Rt, ON.Alpha.Rt); P(P>=.05)=NaN; P(P<.05)=1; P(isnan(P))=0;
topoplot((mean(CTL.Alpha.Rt)- mean(ON.Alpha.Rt)),chanlocs,'maplimits',[-3 3],'emarker2', {find(P),'d','k',5,1}); clear P; title ('REST:Alpha (CTL-PD ON)');caxis(caa);colormap jet;
% %%%%%%%% for Pre-Cue data
cad =[-20000 20000]; cat =[-500 500]; caa = [-30 30]; cab = [-20 20]; cag = [-10 10];
subplot(244);[~,P,~,~]=ttest2(CTL.Theta.PC, ON.Theta.PC); P(P>=.05)=NaN; P(P<.05)=1; P(isnan(P))=0;
topoplot((mean(CTL.Theta.PC)- mean(ON.Theta.PC)),chanlocs,'maplimits',[-3 3],'emarker2', {find(P),'d','k',5,1}); clear P; title ('PreCue:Theta (CTL-PD ON)');caxis(cat);colormap jet;
subplot(248);[~,P,~,~]=ttest2(CTL.Alpha.PC, ON.Alpha.PC); P(P>=.05)=NaN; P(P<.05)=1; P(isnan(P))=0;
topoplot((mean(CTL.Alpha.PC)- mean(ON.Alpha.PC)),chanlocs,'maplimits',[-3 3],'emarker2', {find(P),'d','k',5,1}); clear P; title ('PreCue:Alpha (CTL-PD ON)');caxis(caa);colormap jet;
suptitle ('Control and PD ON')
|