%% Generate figure 06 and S07 % decoding using PCA; Up left, compare 3 early training sessions across PCs % Up right, compare different ensemble size of extended training across PCs % code from David Ottenheimer 04/19/2018 % decode region % first I'll try just classifying individual neurons as DMS or DLS %if ~exist('PSTHzDecode') %if you haven't already collected all the psth data for the decoding 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).PSTHz(DLSselection,Ishow)); DMSconcat_ACQ = cat(2,DMSconcat_ACQ,Ses(i).Ev(7).PSTHz(DMSselection,Ishow)); for j=1:6 DLSconcat_ACQ = cat(2,DLSconcat_ACQ,Ses(i).Ev(j).PSTHz(DLSselection,Ishow)); DMSconcat_ACQ = cat(2,DMSconcat_ACQ,Ses(i).Ev(j).PSTHz(DMSselection,Ishow)); end 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).PSTHz(DLSselection,Ishow); DMSconcat_OT = Ev(7).PSTHz(DMSselection,Ishow); for i=1:6 DLSconcat_OT = cat(2,DLSconcat_OT,Ev(i).PSTHz(DLSselection,Ishow)); DMSconcat_OT = cat(2,DMSconcat_OT,Ev(i).PSTHz(DMSselection,Ishow)); end PSTHzDecodeOT.DLS=DLSconcat_OT; PSTHzDecodeOT.DMS=DMSconcat_OT; save('PSTHzDecodeACQ','PSTHzDecodeOT') %% ACQ PCcomponents Comparison sessions. %PCA first %first do PCA on an equal number of neurons in each region nbsession=0; for k=1:3:10 countRep=0; nbsession=nbsession+1; PSTHzDecode.DLS=PSTHzDecodeACQ(k).DLS; PSTHzDecode.DMS=PSTHzDecodeACQ(k).DMS; if length(PSTHzDecode.DLS(:,1))diff)+1)/(length(shuffdiff)+1); end %% overtraining figure; for i=1:size(PCADecodeAccOT,2) allsamples=cat(1,PCADecodeAccOT{3,i},PCADecodeAccShOT{3,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); subplot(5,1,i) hist(shuffdiff); hold on; plot([diff diff],[0 4000]); end