| |
|
|
| |
| |
| |
| |
|
|
|
|
| clear all; clc |
| homedir='Y:\EEG_Data\PDDys\PD 4 PREDICT\'; |
| datalocation=[homedir,'\PROCESSED EEG DATA\']; % Data are here |
| savepath = [datalocation,'CLEAN\']; |
| cd(datalocation); |
| |
| load([homedir,'VV_Behavior.mat']); % Aggregate behavior files output from Matlab Psychtoolbox |
| load([homedir,'ONOFF.mat']); % 3 columns: subject, session, [ON=1 OFF=0] |
| load([homedir,'BV_Chanlocs_60.mat']); |
| %************************************* |
| |
| MEASURES = xlsread([homedir,'MEASURES']); % Subj symptom measures taken in ON session |
| %************************ |
| % COLUMN LABELS |
| % MEASURES(:,1) = PD IDx |
| % MEASURES(:,2) = NAART Scores |
| % MEASURES(:,3) = BDI Ratings |
| % MEASURES(:,4) = MMSE Scores |
| % MEASURES(:,5) = UPDRS Ratings |
| % MEASURES(:,6) = Years Since Diagnosis (Rank Ordered) |
| % MEASURES(:,7) = Levadopa Equivalent Dose (LED) |
| % MEASURES(:,8) = Accelerometer hand placement: 1 = Left Hand // 2 = Right hand |
| %************************ |
| |
| % Subject Numbers |
| PDsx=[801:811,813:829]; |
| CTLsx=[8010,8070,8060,890:914]; |
| |
| |
| %% MAKE ERPs |
| for subj=[PDsx,CTLsx] |
| for session=1:2; |
| if (subj>850 && session==1) || subj<850 % If not CTL, do session 2 (CTL did not have a session 2) |
| |
| load([num2str(subj),'_Session_',num2str(session),'_PDDys_VV_withcueinfo.mat'],'EEG','bad_chans','bad_epochs','bad_ICAs'); |
| |
| for ai=1:size(EEG.epoch,2) |
| VECTOR(ai,1)=EEG.epoch(ai).FB; |
| VECTOR(ai,2)=EEG.epoch(ai).Resp; |
| VECTOR(ai,3)=EEG.epoch(ai).Resptime; |
| VECTOR(ai,4)=EEG.epoch(ai).Stim; |
| VECTOR(ai,5)=EEG.epoch(ai).Stimtime; |
| VECTOR(ai,6)=EEG.epoch(ai).Cie; |
| VECTOR(ai,7)=EEG.epoch(ai).Cuetime; |
| VECTOR(ai,8)=EEG.epoch(ai).RT; |
| VECTOR(ai,9)=EEG.epoch(ai).BEHCondi; |
| VECTOR(ai,10)=EEG.epoch(ai).BEHOptimal; |
| VECTOR(ai,11)=EEG.epoch(ai).BEHRT; |
| VECTOR(ai,12)=EEG.epoch(ai).BEHFB; |
| end |
| % Remove practice trials |
| VECTOR(isnan(VECTOR(:,9)),:)=NaN; |
| % Add this for later: FB-parsed by condi |
| for vvi=1:length(VECTOR), |
| if VECTOR(vvi,1)==0, VECTOR(vvi,13)=VECTOR(vvi,9); |
| elseif VECTOR(vvi,1)==1, VECTOR(vvi,13)=4+VECTOR(vvi,9); |
| end |
| end |
| |
| % Remove the bad ICAs identified by APPLE: |
| bad_ICAs_To_Remove=bad_ICAs{2}; |
| EEG = pop_subcomp( EEG, bad_ICAs_To_Remove, 0); |
| |
| % low-pass filter for display |
| dims=size(EEG.data); |
| EEG.data=eegfilt(EEG.data,500,[],20); |
| EEG.data=reshape(EEG.data,dims(1),dims(2),dims(3)); |
| |
| % Set times |
| tx=-6000:2:1998; |
| b1=find(tx==-200); b2=find(tx==0); |
| t1=find(tx==-500); t2=find(tx==1000); % For ERPs |
| r1=find(tx==250); r2=find(tx==450); % For Topos |
| tx2disp=-500:2:1000; |
| |
| % Accelerometer was worn on the non-dominant hand |
| % Aggregate accelerometer data |
| EEG.X=EEG.X-repmat(mean(EEG.X),4000,1); |
| EEG.Y=EEG.Y-repmat(mean(EEG.Y),4000,1); |
| EEG.Z=EEG.Z-repmat(mean(EEG.Z),4000,1); |
| % Add to EEG.data as 61st channel - but not the rejected trials |
| EEG.data(61,:,:)=(EEG.X(:,bad_epochs{1}~=1).^2)+(EEG.Y(:,bad_epochs{1}~=1).^2)+(EEG.Z(:,bad_epochs{1}~=1).^2); |
| dims=size(EEG.data); |
| |
| % Basecor your ERPs here so they are pretty. |
| BASE1=squeeze( mean(EEG.data(:,b1:b2,:),2) ); |
| for chani=1:dims(1)-1 % don't basecor the tremor data |
| DATA(chani,:,:)=squeeze(EEG.data(chani,:,:))-repmat( BASE1(chani,:),dims(2),1 ); |
| end |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| for ai=1:8 |
| ERP(:,ai,:)=mean(DATA(:,t1:t2,VECTOR(:,13)==ai),3); |
| TOPO(:,ai) = squeeze(mean(mean(DATA(:,r1:r2,VECTOR(:,13)==ai),2),3)); |
| end |
|
|
| |
| save([savepath,num2str(subj),'_Session_',num2str(session),'_PDDys_VV_withcueinfo_ALL_THE_GOODS.mat'],'ERP','TOPO','VECTOR'); |
| |
| clc; |
| disp(['AND PARTICPANT ',num2str(subj),' HAS BEEN SAVED']); |
| |
| clearvars -except datalocation ONOFF VV_Behavior BV_Chanlocs_60 PDsx CTLsx session subj savepath; |
| close all; |
| |
| end |
| end |
| end |
|
|
| |
|
|
| site = [21,36]; |
| tx=-500:2:1000; |
| time1 = 250; time2 = 450; |
| t1=find(tx==time1); t2=find(tx==time2); |
| TIME = time2-time1; |
| tx2disp=-500:2:1000; |
| COLS={'r','b','g','k'}; |
|
|
| BigN=size(ONOFF,1)./2; |
|
|
| row=1; |
| for mi=1:size(ONOFF,1) |
| disp([num2str(ONOFF(mi,1)),'_Session_',num2str(ONOFF(mi,2)),'_PDDys_VV_withcueinfo_ALL_THE_GOODS.mat']); |
| load([savepath,num2str(ONOFF(mi,1)),'_Session_',num2str(ONOFF(mi,2)),'_PDDys_VV_withcueinfo_ALL_THE_GOODS.mat']); |
| |
| if ONOFF(mi,3)==1 |
| ON.ID(floor(row))=ONOFF(mi,1); |
| ON.Session(floor(row))=ONOFF(mi,2); |
| ON.VECTOR=VECTOR; |
| ON.ERPs(floor(row),:,:)=squeeze(mean(ERP(site,:,:),1)); |
| ON.Topos(floor(row),:,:)=TOPO(:,:); |
| elseif ONOFF(mi,3)==0 |
| OFF.ID(floor(row))=ONOFF(mi,1); |
| OFF.Session(floor(row))=ONOFF(mi,2); |
| OFF.VECTOR=VECTOR; |
| OFF.ERPs(floor(row),:,:)=squeeze(mean(ERP(site,:,:),1)); |
| OFF.Topos(floor(row),:,:)=TOPO(:,:); |
| end |
| row=row+.5; |
| clear ERPs VECTOR; |
| end |
|
|
| row=1; |
| for CTLi=[8010,8060,8070,890:914]; |
| disp([num2str(CTLi),'_Session_1_PDDys_VV_withcueinfo_ALL_THE_GOODS.mat']); |
| load([savepath,num2str(CTLi),'_Session_1_PDDys_VV_withcueinfo_ALL_THE_GOODS.mat']); |
| CTL.ID(floor(row))=CTLi; |
| CTL.Session(floor(row))=1; |
| CTL.VECTOR=VECTOR; |
| CTL.ERPs(floor(row),:,:)=squeeze(mean(ERP(site,:,:),1)); |
| CTL.Topos(floor(row),:,:)=TOPO(:,:); |
| |
| row=row+1; |
| clear ERPs VECTOR; |
| end |
| CtlN=row-1; |
|
|
| |
| |
| |
| TOPO_CON = (CTL.Topos(:,:,5)+CTL.Topos(:,:,6)+CTL.Topos(:,:,7)+CTL.Topos(:,:,8) )/4; |
| TOPO_ON = (ON.Topos(:,:,5)+ON.Topos(:,:,6)+ON.Topos(:,:,7)+ON.Topos(:,:,8) )/4; |
| TOPO_OFF = (OFF.Topos(:,:,5)+OFF.Topos(:,:,6)+OFF.Topos(:,:,7)+OFF.Topos(:,:,8) )/4; |
|
|
| figure; hold on |
|
|
| |
| subplot(1,3,1) |
| topoplot(mean(TOPO_CON,1),BV_Chanlocs_60); |
| title('CONTROL'); |
| set(gca,'clim',[-3 3]); |
|
|
| |
| subplot(1,3,2) |
| topoplot(mean(TOPO_ON,1),BV_Chanlocs_60); |
| title('ON'); |
| set(gca,'clim',[-3 3]); |
|
|
| |
| subplot(1,3,3) |
| topoplot(mean(TOPO_OFF,1),BV_Chanlocs_60); |
| title('OFF'); |
| set(gca,'clim',[-3 3]); |
| cbar |
|
|
| |
| |
| |
| |
| win_CON = (CTL.ERPs(:,5,:)+CTL.ERPs(:,6,:)+CTL.ERPs(:,7,:)+CTL.ERPs(:,8,:))/4; |
| win_ON = (ON.ERPs(:,5,:)+ON.ERPs(:,6,:)+ON.ERPs(:,7,:)+ON.ERPs(:,8,:))/4; |
| win_OFF = (OFF.ERPs(:,5,:)+OFF.ERPs(:,6,:)+OFF.ERPs(:,7,:)+OFF.ERPs(:,8,:))/4; |
|
|
| lose_CON = (CTL.ERPs(:,:,1)+CTL.ERPs(:,:,2)+CTL.ERPs(:,:,3)+CTL.ERPs(:,:,4))/4; |
| lose_ON = (ON.ERPs(:,:,1)+ON.ERPs(:,:,2)+ON.ERPs(:,:,3)+ON.ERPs(:,:,4))/4; |
| lose_OFF = (OFF.ERPs(:,:,1)+OFF.ERPs(:,:,2)+OFF.ERPs(:,:,3)+OFF.ERPs(:,:,4))/4; |
|
|
| figure;hold on; |
| rectangle('Position',[time1,0,TIME,3],'Curvature',0.1,'FaceColor',[.9 .9 .9]) |
| plot(tx2disp,squeeze(nanmean(win_CON,1)),COLS{1}); |
| plot(tx2disp,squeeze(nanmean(win_ON,1)),COLS{2}); |
| plot(tx2disp,squeeze(nanmean(win_OFF,1)),COLS{3}); |
| shadedErrorBar(tx2disp, squeeze(nanmean(win_CON,1)), nanstd(squeeze(win_CON)) ./sqrt(28),COLS{1}) |
| shadedErrorBar(tx2disp, squeeze(nanmean(win_ON,1)), nanstd(squeeze(win_ON)) ./sqrt(28),COLS{2}) |
| shadedErrorBar(tx2disp, squeeze(nanmean(win_OFF,1)), nanstd(squeeze(win_OFF)) ./sqrt(28),COLS{3}) |
| plot(tx2disp,squeeze(nanmean(win_CON,1)),COLS{1},'LineWidth',4); |
| plot(tx2disp,squeeze(nanmean(win_ON,1)),COLS{2},'LineWidth',4); |
| plot(tx2disp,squeeze(nanmean(win_OFF,1)),COLS{3},'LineWidth',4); |
|
|
| title('ERPs FOR WINS'); |
| h_legend=legend({'HC','ON','OFF'}); |
| set(h_legend,'FontSize',12); |
| plot([0 0],[-6 6],'k:'); |
| set(gca,'ylim',[-1 4],'xlim',[-100 1000]) |
| pcrit=.05; |
| [H,P,CI,STATS]=ttest(win_CON,win_ON); |
| P(P>pcrit)=NaN; P(P<=pcrit)=1; |
| plot(tx2disp,-.5*squeeze(P),'k','linewidth',3); clear H P CI STATS; |
| [H,P,CI,STATS]=ttest(win_CON,win_OFF); |
| P(P>pcrit)=NaN; P(P<=pcrit)=1; |
| plot(tx2disp,-.7*squeeze(P),'r','linewidth',3); clear H P CI STATS; |
|
|
| CONTROL_ERP = squeeze(mean(win_CON(:,:,t1:t2),3)); |
| ON_ERP = squeeze(mean(win_ON(:,:,t1:t2),3)); |
| OFF_ERP = squeeze(mean(win_OFF(:,:,t1:t2),3)); |
|
|
| [H,P,CI,STATS]=ttest(CONTROL_ERP,ON_ERP) |
| text(.7,3.5,['CONTROL v. ON t= ',num2str(STATS.tstat),' p= ',num2str(P)]) |
| [H,P,CI,STATS]=ttest(CONTROL_ERP,OFF_ERP) |
| text(.7,3.3,['CONTROL v. OFF t= ',num2str(STATS.tstat),' p= ',num2str(P)]) |
| [H,P,CI,STATS]=ttest(ON_ERP,OFF_ERP) |
| text(.7,3.1,['ON v. OFF t= ',num2str(STATS.tstat),' p= ',num2str(P)]) |
|
|
| |
| |
| |
| |
| |
| for condi=1:8 |
| SPSS_CONT(:,condi)= squeeze(nanmean(CTL.ERPs(:,condi,t1:t2),3)); |
| SPSS_ON(:,condi)= squeeze(nanmean(ON.ERPs(:,condi,t1:t2),3)); |
| SPSS_OFF(:,condi)= squeeze(nanmean(OFF.ERPs(:,condi,t1:t2),3)); |
| end |
|
|
| |
| REWP_ON = [SPSS_ON(:,5),SPSS_ON(:,6),SPSS_ON(:,7),SPSS_ON(:,8)]; |
| REWP_OFF = [SPSS_OFF(:,5),SPSS_OFF(:,6),SPSS_OFF(:,7),SPSS_OFF(:,8)]; |
|
|
| ALL_REWP_ON = mean(REWP_ON,2); |
| ALL_REWP_OFF = mean(REWP_OFF,2); |
|
|
| |
| |
| |
| YrsDx=tiedrank(MEASURES(:,6),1); |
|
|
| figure; |
| hold on; |
| subplot(2,1,1) |
| scatter(YrsDx,ALL_REWP_ON,'MarkerEdgeColor',[0 .5 .5],... |
| 'MarkerFaceColor',[0 .7 .7],... |
| 'LineWidth',1.5) |
| lsline |
| title('ON: REW-P v. YRS DIAGNOSED ') |
| set(gca,'ylim',[-2 5]) |
| [RHO,PVAL] = corr(ALL_REWP_ON,MEASURES(:,6),'TYPE','Spearman'); |
| text(.7,4,['r= ',num2str(RHO),' p= ',num2str(PVAL)]) |
|
|
| subplot(2,1,2) |
| hold on; |
| scatter(YrsDx,ALL_REWP_OFF,'MarkerEdgeColor',[0 .5 .5],... |
| 'MarkerFaceColor',[0 .7 .7],... |
| 'LineWidth',1.5) |
| lsline |
| title('OFF: REW-P v. YRS DIAGNOSED ') |
| set(gca,'ylim',[-2 5]) |
| [RHO,PVAL] = corr(ALL_REWP_OFF,MEASURES(:,6),'TYPE','Spearman'); |
| text(.7,4,['r= ',num2str(RHO),' p= ',num2str(PVAL)]) |
|
|
| |
|
|
|
|