%% generate figure 7A. Decoding brain region ID without PCA % code from David Ottenheimer 04/19/2018 %get the data clear all close all load('Rearlytraining_light.mat') Xaxis1=[-0.25 0.25]; Ishow=find(Tm>=Xaxis1(1) & Tm<=Xaxis1(2)); for i=4:13 %loop thru ACQ session DLSselection=Ses(i).Coord(:,4)==10 & Ses(i).Celltype(:,1)==1; DMSselection=Ses(i).Coord(:,4)==20 & Ses(i).Celltype(:,1)==1; DLSconcat_ACQ=[];DMSconcat_ACQ=[]; DLSconcat_ACQ = cat(2,DLSconcat_ACQ,Ses(i).Ev(7).Meanz(DLSselection,1)); DMSconcat_ACQ = cat(2,DMSconcat_ACQ,Ses(i).Ev(7).Meanz(DMSselection,1)); for j=1:5 DLSconcat_ACQ = cat(2,DLSconcat_ACQ,Ses(i).Ev(j).MeanzPRE(DLSselection,1)); DLSconcat_ACQ = cat(2,DLSconcat_ACQ,Ses(i).Ev(j).Meanz(DLSselection,1)); DMSconcat_ACQ = cat(2,DMSconcat_ACQ,Ses(i).Ev(j).MeanzPRE(DMSselection,1)); DMSconcat_ACQ = cat(2,DMSconcat_ACQ,Ses(i).Ev(j).Meanz(DMSselection,1)); end DLSconcat_ACQ = cat(2,DLSconcat_ACQ,Ses(i).Ev(6).MeanzPRE(DLSselection,1)); DMSconcat_ACQ = cat(2,DMSconcat_ACQ,Ses(i).Ev(6).MeanzPRE(DMSselection,1)); PSTHzDecodeACQ(i-3).DLS=DLSconcat_ACQ(~isnan(mean(DLSconcat_ACQ,2)),:); PSTHzDecodeACQ(i-3).DMS=DMSconcat_ACQ(~isnan(mean(DMSconcat_ACQ,2)),:); end clear Ses load('Rextendedtraining_light.mat'); load('Celltype_extendedTraining.mat'); DLSselection=Coord(:,4)==10 & Celltype(:,1)==1; DMSselection=Coord(:,4)==20 & Celltype(:,1)==1; DLSconcat_OT = Ev(7).Meanz(DLSselection,1); DMSconcat_OT = Ev(7).Meanz(DMSselection,1); for i=1:5 DLSconcat_OT = cat(2,DLSconcat_OT,Ev(i).MeanzPRE(DLSselection,1)); DLSconcat_OT = cat(2,DLSconcat_OT,Ev(i).Meanz(DLSselection,1)); DMSconcat_OT = cat(2,DMSconcat_OT,Ev(i).MeanzPRE(DMSselection,1)); DMSconcat_OT = cat(2,DMSconcat_OT,Ev(i).Meanz(DMSselection,1)); end DLSconcat_OT = cat(2,DLSconcat_OT,Ev(6).MeanzPRE(DLSselection,1)); DMSconcat_OT = cat(2,DMSconcat_OT,Ev(6).MeanzPRE(DMSselection,1)); MeanzDecodeOT.DLS=DLSconcat_OT; MeanzDecodeOT.DMS=DMSconcat_OT; save('MeanzDecodeACQ','MeanzDecodeOT') %% ACQ PCcomponents Comparison sessions. %PCA first %first do PCA on an equal number of neurons in each region nbsession=0; for k=1:10 clear rep countRep=0; PSTHzDecode.DLS=PSTHzDecodeACQ(k).DLS; PSTHzDecode.DMS=PSTHzDecodeACQ(k).DMS; if length(PSTHzDecode.DLS(:,1))diff)+1)/(length(shuffdiff)+1); end %% overtraining for i=1:length(PCADecodeAccOT) allsamples=cat(1,PCADecodeAccOT{1,i},PCADecodeAccShOT{1,i}); for p=1:10000 shuffsamples=allsamples(randperm(length(allsamples))); shuffdiff(p,1)=abs(mean(shuffsamples(1:length(allsamples)/2))-mean(shuffsamples(length(allsamples)/2+1:end))); end diff=abs(nanmean(PCADecodeAccOT{1,i})-nanmean(PCADecodeAccShOT{1,i})); OTpval(1,i)=(sum(shuffdiff>diff)+1)/(length(shuffdiff)+1); end