123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990 |
- addpath(genpath('../../../my-tools'));
- addpath(genpath('../../../external-tools'));
- clearvars -except subjsData poolstack* pooltw*;
- %close all; clc;
- reload=0; recomp_shLRalgn=1;
- recomputelm=1;
- Nlag=10; Nspan=200; %Nspan=200;
- Nshf=100;
- %selflag=1; %LookL during offer1 is most common
- %selflag=4; %LookR during offer2 is most common
- %selflag=2; %LookR during offer1 is less common
- %selflag=3; %LookL during offer2 is less common
- %caseflag=1; % perform analysis saccade-aligned forcing stare after first shift
- %caseflag=2; % perform analysis saccade-aligned ignoring gaze after first shift (removes data if second shifts are detected)
- %caseflag=3; % perform analysis for unilateral staring only trials
- %caseflag=4; % same as caseflag=1 but forcing offerLL/LR
- %caseflag=5; % same as caseflag=2 but forcing offerLL/LR
- %caseflag=6; % same as caseflag=3 but forcing offerLL/LR
- for selflag=[1 4]
- for caseflag=2
- clearvars -except subjsData reload recomp_shLRalgn recomputelm Nlag Nspan Nshf selflag caseflag; close all; clc;
- stareflag=(caseflag==1 | caseflag==4); %forces stare after saccade
- casesstrs={'1_shift_NOoffLR','2_shift_NOstare_NOoffLR','3_NOshift_NOoffLR','4_shift','5_shift_NOstare','6_NOshift'};
- disp(['running selflag=' num2str(selflag) '; caseflag=' num2str(caseflag) '; (' casesstrs{caseflag} ')']);
- switch selflag
- case 1
- most_recent_folder=['../../Figures/evLevR_off1L_del1LR_' casesstrs{caseflag} '/'];
- if ~exist(most_recent_folder,'dir'); mkdir(most_recent_folder); mkdir([most_recent_folder 'span' num2str(Nspan) 'ms_lag' num2str(Nlag) 'ms']); end
- selectedTimes='((ntce_ds(3,1)-46):ntce_ds(3,2))';
- %selectedCases{1}='find((cciso1LL) & (ccepx(:,tt)<0))';
- %selectedCases{2}='find((cciso1LL) & (ccepx(:,tt)>0))';
- case 2
- most_recent_folder=['../../Figures/evLevR_off1R_del1LR_' casesstrs{caseflag} '/'];
- selectedTimes='((ntce_ds(3,1)-46):ntce_ds(3,2))';
- %selectedCases{1}='find((~cciso1LL) & (ccepx(:,tt)<0))';
- %selectedCases{2}='find((~cciso1LL) & (ccepx(:,tt)>0))';
- case 3
- most_recent_folder=['../../Figures/evLevR_off2L_del2LR_' casesstrs{caseflag} '/'];
- selectedTimes='((ntce_ds(5,1)-46):ntce_ds(5,2))';
- %selectedCases{1}='find((cciso2LL) & (ccepx(:,tt)<0))';
- %selectedCases{2}='find((cciso2LL) & (ccepx(:,tt)>0))';
- case 4
- most_recent_folder=['../../Figures/evLevR_off2R_del2LR_' casesstrs{caseflag} '/'];
- if ~exist(most_recent_folder,'dir'); mkdir(most_recent_folder); mkdir([most_recent_folder 'span' num2str(Nspan) 'ms_lag' num2str(Nlag) 'ms']); end
- selectedTimes='((ntce_ds(5,1)-46):ntce_ds(5,2))';
- %selectedCases{1}='find((~cciso2LL) & (ccepx(:,tt)<0))';
- %selectedCases{2}='find((~cciso2LL) & (ccepx(:,tt)>0))';
- end
- if reload
- % if ~exist('subjsData','var')
- % subjsData(1).sbdata=getSubjectData(1);
- % subjsData(2).sbdata=getSubjectData(2);
- % end
- if ~exist('poolstackvars','var')
- load latestpoolstackvars_14feb22.mat
- % or getPoolStackVars.m
- end
- if ~exist('pooltweyepos','var')
- load latestpooltweyepos_14feb22.mat
- % or getTimewinsPoolEyePos.m
- end
- if ~exist('pooltwspksq','var')
- load latestpooltwspks_14feb22.mat
- % or getTimewinsPoolSpikeSeqs.m
- end
- twLabels={'preoffer1','offer1','delay1','offer2','delay2','refixate','choice-go','ch-hold'};
- nccs=[ 51 59 24 29 18 32 9 26];
- ntrs=arrayfun(@(xx) size(poolstackvars(xx).offer1sd,1),1:8);
- Nccs=sum(nccs);
- Ntrs12=max(ntrs);
- Ntps12=arrayfun(@(tw) size(pooltweyepos(tw).posX,3), 1:8);
- Ntps12(1)=400;
- pooloffer1sd=[]; poolofferLev=[]; poolofferRev=[]; pooloffer1ev=[]; pooloffer2ev=[]; pooloffer1rw=[]; pooloffer2rw=[]; poolofferchR=[];
- for sn=1:8
- pooloffer1sd=cat(2, pooloffer1sd, repmat(cat(1,poolstackvars(sn).offer1sd,nan(Ntrs12-ntrs(sn),1)),[1 nccs(sn)]));
- poolofferLev=cat(2, poolofferLev, repmat(cat(1,poolstackvars(sn).offerLev,nan(Ntrs12-ntrs(sn),1)),[1 nccs(sn)]));
- poolofferRev=cat(2, poolofferRev, repmat(cat(1,poolstackvars(sn).offerRev,nan(Ntrs12-ntrs(sn),1)),[1 nccs(sn)]));
- pooloffer1ev=cat(2, pooloffer1ev, repmat(cat(1,poolstackvars(sn).offer1ev,nan(Ntrs12-ntrs(sn),1)),[1 nccs(sn)]));
- pooloffer2ev=cat(2, pooloffer2ev, repmat(cat(1,poolstackvars(sn).offer2ev,nan(Ntrs12-ntrs(sn),1)),[1 nccs(sn)]));
- pooloffer1rw=cat(2, pooloffer1rw, repmat(cat(1,poolstackvars(sn).offer1rw,nan(Ntrs12-ntrs(sn),1)),[1 nccs(sn)]));
- pooloffer2rw=cat(2, pooloffer2rw, repmat(cat(1,poolstackvars(sn).offer2rw,nan(Ntrs12-ntrs(sn),1)),[1 nccs(sn)]));
- poolofferchR=cat(2, poolofferchR, repmat(cat(1,poolstackvars(sn).chooseR,nan(Ntrs12-ntrs(sn),1)),[1 nccs(sn)]));
- end
- pooleposxmat=cat(3,pooltweyepos(1).posX,pooltweyepos(2).posX,pooltweyepos(3).posX,pooltweyepos(4).posX,...
- pooltweyepos(5).posX,pooltweyepos(6).posX,pooltweyepos(7).posX,pooltweyepos(8).posX);
- poolspksqmat=cat(3,pooltwspksq(1).spkseqs,pooltwspksq(2).spkseqs,pooltwspksq(3).spkseqs,pooltwspksq(4).spkseqs,...
- pooltwspksq(5).spkseqs,pooltwspksq(6).spkseqs,pooltwspksq(7).spkseqs,pooltwspksq(8).spkseqs);
- poolspksqmat=cat(3,nan(size(pooltwspksq(1).spkseqs)),nan(size(pooltwspksq(2).spkseqs)),pooltwspksq(3).spkseqs,...
- nan(size(pooltwspksq(4).spkseqs)),pooltwspksq(5).spkseqs,nan(size(pooltwspksq(6).spkseqs)),nan(size(pooltwspksq(7).spkseqs)),nan(size(pooltwspksq(8).spkseqs)));
- poolcovhist=cat(2,pooltwspksq(1).covhist,pooltwspksq(2).covhist,pooltwspksq(3).covhist,pooltwspksq(4).covhist,...
- pooltwspksq(5).covhist,pooltwspksq(6).covhist,pooltwspksq(7).covhist,pooltwspksq(8).covhist);
- %clearvars pooltwspksq pooltweyepos
- fchg=find(poolcovhist>=.999); fchl=find(poolcovhist<.999);
- ntcv=[fchg(diff([fchg sum(Ntps12)])>1)' fchl([diff(fchl) sum(Ntps12)]>1)'];
- ntce=[[1; 401; ntcv(1:end-1,2)] [400; ntcv(:,1)]];
- vtps=ones(1,sum(Ntps12)); for jj=1:7; vtps(ntcv(jj,1):ntcv(jj,2))=nan; end
- %if sparsity==1 it means 1spike/ms that is 1000 spikes/s
- %nanmean(vectorise((nansum(poolspksqmat,3))./(nansum(poolspksqmat>=0,3))))*1000
- %nanstd(vectorise((nansum(poolspksqmat,3))./(nansum(poolspksqmat>=0,3))))*1000
- %% smooth by movmean filtering, downsample to 20ms, 50Hz resolution
- Ntps_ds=ceil(sum(Ntps12)/Nlag);
- tmax_ds=nanmovmean(1:size(pooleposxmat,3),Nlag,Nlag);
- poolspksqmat_ds=nan(Ntrs12,Nccs,length(tmax_ds));
- pooleposxmat_ds=nan(Ntrs12,Nccs,length(tmax_ds));
- for cc=1:Nccs
- poolspksqmat_ds(:,cc,:)=nanmovmean(squeeze(poolspksqmat(:,cc,:))',Nlag,[0 Nspan])';
- pooleposxmat_ds(:,cc,:)=nanmovmean(squeeze(pooleposxmat(:,cc,:))',Nlag,Nlag)';
- end
- clearvars poolspksqmat pooleposxmat
- %%
- poolcovhist_ds=nanmovmean(poolcovhist,Nlag,Nlag);
- fcgh_ds=find(poolcovhist_ds>=.999); fchl_ds=find(poolcovhist_ds<.999);
- ntcv_ds=[fcgh_ds(diff([fcgh_ds Ntps_ds])>1)' fchl_ds([diff(fchl_ds) Ntps_ds]>1)'];
- vtps_ds=ones(1,Ntps_ds); for jj=1:7; vtps_ds(ntcv_ds(jj,1):ntcv_ds(jj,2))=nan; end
- ntce_ds=[[1 ceil(400/Nlag)+1 find(vtps_ds(2:end)+isnan(vtps_ds(1:end-1))==2)+1]' [ceil(400/Nlag) find(vtps_ds(1:end-1)+isnan(vtps_ds(2:end))==2)]'];
- Nvtps_ds=sum(vtps_ds==1);
- % Apply movmean independently across time windows
- % checktps_ds=zeros(1,length(poolcovhist_ds));
- % for tw=1:8
- % tpvec=zeros(1,length(poolcovhist));
- % tpvec(ntce(tw,1):ntce(tw,2))=1;
- % tpvec_ds=zeros(1,length(poolcovhist_ds));
- % tpvec_ds(ntce_ds(tw,1):ntce_ds(tw,2))=1;
- % for cc=1:Nccs
- % nnspktemp=nanmovmean(squeeze(poolspksqmat(:,cc,tpvec==1))',Nlag,[0 Nspan])';
- % poolspksqmat_ds(:,cc,tpvec_ds==1)=nnspktemp(:,1:sum(tpvec_ds==1));
- % nnepxtemp=nanmovmean(squeeze(pooleposxmat(:,cc,tpvec==1))',Nlag,Nlag)';
- % pooleposxmat_ds(:,cc,tpvec_ds==1)=nnepxtemp(:,1:sum(tpvec_ds==1));
- % end
- % checktps_ds(tpvec_ds==1)=checktps_ds(tpvec_ds==1)+tw;
- % end
- vtmax_ds=rmnans(tmax_ds.*vtps_ds);%find(rmnans(vtps_ds));
- rtmax_ds=1:length(vtmax_ds);
- rtmes_ds=arrayfun(@(jj) length(ntce_ds(jj,1):ntce_ds(jj,2)), 1:8);
- % baseline normalization
- %poolspksqmat_ds_bln=poolspksqmat_ds-repmat(nanmean(poolspksqmat_ds(:,:,1:floor(400/Nlag)),3),[1 1 Ntps_ds]);
- %clearvars poolspksqmat_ds
- % baseline normalization
- %poolspksqmat_ds_bln=poolspksqmat_ds./repmat(nanmean(poolspksqmat_ds(:,:,1:floor(400/Nlag)),3)+eps,[1 1 Ntps_ds]);
- %poolspksqmat_ds_bln=poolspksqmat_ds-repmat(nanmean(nanmean(poolspksqmat_ds(:,:,1:floor(400/Nlag)),3),1),[Ntrs12 1 Ntps_ds]);
- % No baseline normalization
- poolspksqmat_ds_bln=poolspksqmat_ds;
- else
- load pool_all_light.mat
- % save time at run-time
- end
- %%
- off1time=ntce_ds(2,2)-(19:-1:0);
- del1time=ntce_ds(3,2)-(19:-1:0);
- off2time=ntce_ds(4,2)-(19:-1:0);
- del2time=ntce_ds(5,2)-(19:-1:0);
- %fulldel1time=(ntce_ds(3,1)):ntce_ds(3,2);
- fulldel1time=[(ntce_ds(3,1)-46):(ntce_ds(3,1)-7) ntce_ds(3,1):ntce_ds(3,2)];
- %fulldel2time=(ntce_ds(5,1)):ntce_ds(6,1)-20-2; % due to spikecount/subsampling setup
- fulldel2time=[(ntce_ds(5,1)-46):(ntce_ds(5,1)-7) ntce_ds(5,1):ntce_ds(6,1)-20-2];
- num1stshiftsL=zeros(248,1);
- num2ndshiftsR=zeros(248,1);
- num1stshiftsR=zeros(248,1);
- num2ndshiftsL=zeros(248,1);
- if recomp_shLRalgn
- if selflag<=2
- %%%%%%%%%%%%%%
- pooleposxmat_shRalgn=nan(size(pooleposxmat_ds_bln));
- pooleposxmat_shLalgn=nan(size(pooleposxmat_ds_bln));
- poolspksqmat_shRalgn=nan(size(poolspksqmat_ds_bln));
- poolspksqmat_shLalgn=nan(size(poolspksqmat_ds_bln));
- pooleposxmat_shRonly=nan(size(pooleposxmat_ds_bln));
- pooleposxmat_shLonly=nan(size(pooleposxmat_ds_bln));
- poolspksqmat_shRonly=nan(size(poolspksqmat_ds_bln));
- poolspksqmat_shLonly=nan(size(poolspksqmat_ds_bln));
- isdelSR=nan(size(poolspksqmat_ds_bln,1:2));
- isdelSL=nan(size(poolspksqmat_ds_bln,1:2));
- for cc=1:248
- % firstL offer1 - thenL delay2
- % Detect saccades
- ccepx=squeeze(pooleposxmat_ds_bln(:,cc,fulldel1time));
- ccspk=squeeze(poolspksqmat_ds_bln(:,cc,fulldel1time));
- [nuR,~,~,ishiftsR]=nanmonotonicdrifts_forward_simplified(ccepx(:,40:end),2,0,+1,1,stareflag);
- % delay2 shiftR trials have sum(xdriftsR,2)>0
- isdelSR(:,cc)=double(~isnan(ishiftsR));
- ind_delSR=find(~isnan(ishiftsR));
- % saccade R times
- %stR=arrayfun(@(xx) find(xdriftsR(xx,:)==1,1,'first'),isSR);
- stR=ishiftsR(ind_delSR);
- num1stshiftsR(cc)=sum(nuR>0);
- for jj=1:length(ind_delSR)
- shRbins=(ishiftsR(ind_delSR(jj)):length(fulldel1time));
- %removes post-shift returns
- [n2L,~,~,ishifts2L]=nanmonotonicdrifts_forward_simplified(ccepx(ind_delSR(jj),shRbins(41:end)),2,0,-1,+1,stareflag);
- if n2L>0
- shRbins((41+ishifts2L):end)=[];
- num2ndshiftsL(cc)=num2ndshiftsL(cc)+1;
- end
- pooleposxmat_shRalgn(ind_delSR(jj),cc,fulldel1time)=[ccepx(ind_delSR(jj),shRbins) nan(1,length(fulldel1time)-sum(shRbins<=length(fulldel1time)))];
- poolspksqmat_shRalgn(ind_delSR(jj),cc,fulldel1time)=[ccspk(ind_delSR(jj),shRbins) nan(1,length(fulldel1time)-sum(shRbins<=length(fulldel1time)))];
- pooleposxmat_shRonly(ind_delSR(jj),cc,fulldel1time(1)-1+shRbins)=ccepx(ind_delSR(jj),shRbins);
- poolspksqmat_shRonly(ind_delSR(jj),cc,fulldel1time(1)-1+shRbins)=ccepx(ind_delSR(jj),shRbins);
- end
- %figure(); plot(1:76,squeeze(pooleposxmat_shRalgn(:,1,fulldel1time)))
- %%
- [nuL,~,~,ishiftsL]=nanmonotonicdrifts_forward_simplified(ccepx(:,40:end),2,0,-1,1,stareflag);
- % delay2 shiftL trials
- isdelSL(:,cc)=double(~isnan(ishiftsL));
- ind_delSL=find(~isnan(ishiftsL));
- % saccade L times
- %stL=arrayfun(@(xx) find(xdriftsL(xx,:)==1,1,'first'),isSL);
- stL=ishiftsL(ind_delSL);
- num1stshiftsL(cc)=sum(nuL>0);
- for jj=1:length(ind_delSL)
- shLbins=(ishiftsL(ind_delSL(jj)):length(fulldel1time));
- %removes post-shift returns
- [n2R,~,~,ishifts2R]=nanmonotonicdrifts_forward_simplified(ccepx(ind_delSL(jj),shLbins(41:end)),2,0,+1,+1,stareflag);
- if n2R>0
- shLbins((41+ishifts2R):end)=[];
- num2ndshiftsR(cc)=num2ndshiftsR(cc)+1;
- end
- pooleposxmat_shLalgn(ind_delSL(jj),cc,fulldel1time)=[ccepx(ind_delSL(jj),shLbins) nan(1,length(fulldel1time)-sum(shLbins<=length(fulldel1time)))];
- poolspksqmat_shLalgn(ind_delSL(jj),cc,fulldel1time)=[ccspk(ind_delSL(jj),shLbins) nan(1,length(fulldel1time)-sum(shLbins<=length(fulldel1time)))];
- pooleposxmat_shLonly(ind_delSL(jj),cc,fulldel1time(1)-1+shLbins)=ccepx(ind_delSL(jj),shLbins);
- poolspksqmat_shLonly(ind_delSL(jj),cc,fulldel1time(1)-1+shLbins)=ccepx(ind_delSL(jj),shLbins);
- end
- %figure(); plot(1:76,squeeze(pooleposxmat_shLalgn(:,1,fulldel1time)))
- end
-
- %save('pool_del1_shLRalgn.mat','pooleposxmat_shRalgn','poolspksqmat_shRalgn','pooleposxmat_shLalgn','poolspksqmat_shLalgn','-v7.3')
-
- elseif selflag>2
- %%%%%%%%%%%%%%%%%%%%%%%
- pooleposxmat_shRalgn=nan(size(pooleposxmat_ds_bln));
- pooleposxmat_shLalgn=nan(size(pooleposxmat_ds_bln));
- poolspksqmat_shRalgn=nan(size(poolspksqmat_ds_bln));
- poolspksqmat_shLalgn=nan(size(poolspksqmat_ds_bln));
- pooleposxmat_shRonly=nan(size(pooleposxmat_ds_bln));
- pooleposxmat_shLonly=nan(size(pooleposxmat_ds_bln));
- poolspksqmat_shRonly=nan(size(poolspksqmat_ds_bln));
- poolspksqmat_shLonly=nan(size(poolspksqmat_ds_bln));
- isdelSR=nan(size(poolspksqmat_ds_bln,1:2));
- isdelSL=nan(size(poolspksqmat_ds_bln,1:2));
- for cc=1:248
- % firstL offer1 - thenL delay2
- % Detect saccades
- ccepx=squeeze(pooleposxmat_ds_bln(:,cc,fulldel2time));
- ccspk=squeeze(poolspksqmat_ds_bln(:,cc,fulldel2time));
- [nuR,~,~,ishiftsR]=nanmonotonicdrifts_forward_simplified(ccepx(:,40:end),2,0,+1,1,stareflag);
- % delay2 shiftR trials have sum(xdriftsR,2)>0
- isdelSR(:,cc)=double(~isnan(ishiftsR));
- ind_delSR=find(~isnan(ishiftsR));
- % saccade R times
- %stR=arrayfun(@(xx) find(xdriftsR(xx,:)==1,1,'first'),isSR);
- stR=ishiftsR(ind_delSR);
- num1stshiftsR(cc)=sum(nuR>0);
- for jj=1:length(ind_delSR)
- shRbins=(ishiftsR(ind_delSR(jj)):length(fulldel2time));
- %removes post-shift returns
- [n2L,~,~,ishifts2L]=nanmonotonicdrifts_forward_simplified(ccepx(ind_delSR(jj),shRbins(41:end)),2,0,-1,+1,stareflag);
- if n2L>0
- shRbins((41+ishifts2L):end)=[];
- num2ndshiftsL(cc)=num2ndshiftsL(cc)+1;
- end
- pooleposxmat_shRalgn(ind_delSR(jj),cc,fulldel2time)=[ccepx(ind_delSR(jj),shRbins) nan(1,length(fulldel2time)-sum(shRbins<=length(fulldel2time)))];
- poolspksqmat_shRalgn(ind_delSR(jj),cc,fulldel2time)=[ccspk(ind_delSR(jj),shRbins) nan(1,length(fulldel2time)-sum(shRbins<=length(fulldel2time)))];
- pooleposxmat_shRonly(ind_delSR(jj),cc,fulldel2time(1)-1+shRbins)=ccepx(ind_delSR(jj),shRbins);
- poolspksqmat_shRonly(ind_delSR(jj),cc,fulldel2time(1)-1+shRbins)=ccepx(ind_delSR(jj),shRbins);
- end
-
- [nuL,~,~,ishiftsL]=nanmonotonicdrifts_forward_simplified(ccepx(:,40:end),2,0,-1,1,stareflag);
- % delay2 shiftL trials
- isdelSL(:,cc)=double(~isnan(ishiftsL));
- ind_delSL=find(~isnan(ishiftsL));
- % saccade L times
- %stL=arrayfun(@(xx) find(xdriftsL(xx,:)==1,1,'first'),isSL);
- stL=ishiftsL(ind_delSL);
- num1stshiftsL(cc)=sum(nuL>0);
- for jj=1:length(ind_delSL)
- shLbins=(ishiftsL(ind_delSL(jj)):length(fulldel2time));
- %removes post-shift returns
- [n2R,~,~,ishifts2R]=nanmonotonicdrifts_forward_simplified(ccepx(ind_delSL(jj),shLbins(41:end)),2,0,+1,+1,stareflag);
- if n2R>0
- shLbins((41+ishifts2R):end)=[];
- num2ndshiftsR(cc)=num2ndshiftsR(cc)+1;
- end
- pooleposxmat_shLalgn(ind_delSL(jj),cc,fulldel2time)=[ccepx(ind_delSL(jj),shLbins) nan(1,length(fulldel2time)-sum(shLbins<=length(fulldel2time)))];
- poolspksqmat_shLalgn(ind_delSL(jj),cc,fulldel2time)=[ccspk(ind_delSL(jj),shLbins) nan(1,length(fulldel2time)-sum(shLbins<=length(fulldel2time)))];
- pooleposxmat_shLonly(ind_delSL(jj),cc,fulldel2time(1)-1+shLbins)=ccepx(ind_delSL(jj),shLbins);
- poolspksqmat_shLonly(ind_delSL(jj),cc,fulldel2time(1)-1+shLbins)=ccepx(ind_delSL(jj),shLbins);
- end
- %disp(cc)
- end
-
- %save('pool_del2_shLRalgn.mat','pooleposxmat_shRalgn','poolspksqmat_shRalgn','pooleposxmat_shLalgn','poolspksqmat_shLalgn','-v7.3')
- end
-
- else
- if selflag<=2
- load pool_del1_shLRalgn.mat
- elseif selflag>2
- load pool_del2_shLRalgn.mat
- end
- end
- sum(num1stshiftsL)/sum(ntrs.*nccs)
- sum(num1stshiftsR)/sum(ntrs.*nccs)
- sum(num2ndshiftsR)/sum(num1stshiftsL)
- sum(num2ndshiftsL)/sum(num1stshiftsR)
- sum(num2ndshiftsR)/sum(ntrs.*nccs)
- sum(num2ndshiftsL)/sum(ntrs.*nccs)
- %%
- pooleposxmat_L=nan(Ntrs12,Nccs,Ntps_ds); pooleposxmat_R=nan(Ntrs12,Nccs,Ntps_ds);
- if any(caseflag==[1 2 4 5])
- pooleposxmat_L=pooleposxmat_shLalgn(:,:,:);
- pooleposxmat_R=pooleposxmat_shRalgn(:,:,:);
- else
- dtime=eval(selectedTimes);
- inddelstL=arrayfun(@(xx) all((rmnans(squeeze(pooleposxmat_ds_bln(xx,1,dtime))))<=0), 1:size(pooleposxmat_ds_bln,1));
- inddelstR=arrayfun(@(xx) all((rmnans(squeeze(pooleposxmat_ds_bln(xx,1,dtime))))>=0), 1:size(pooleposxmat_ds_bln,1));
- pooleposxmat_L(1:sum(inddelstL),:,dtime)=pooleposxmat_ds_bln(inddelstL,:,dtime);
- pooleposxmat_R(1:sum(inddelstR),:,dtime)=pooleposxmat_ds_bln(inddelstR,:,dtime);
- end
- if selflag <=2
- hfig=fullfig();
- subplot(1,2,1); title('Shifts to Left screen side');
- plot(rtmax_ds,(squeeze(pooleposxmat_L(:,1,vtps_ds==1)))./32558); ylim([-1 1]); plothline(0);
- xlabel('time after delay1 aligned to gaze shift initiation (ms)'); ylabel('horizontal eye position (normalized)'); box off
- subplot(1,2,2); title('Shifts to Right screen side');
- plot(rtmax_ds,(squeeze(pooleposxmat_R(:,1,vtps_ds==1)))./32558); ylim([-1 1]); plothline(0);
- xlabel('time after delay1 aligned to gaze shift initiation (ms)'); ylabel('horizontal eye position (normalized)'); box off
- saveas(hfig,[most_recent_folder 'span' num2str(Nspan) 'ms_lag' num2str(Nlag) 'ms/sample_trials_off_del_shifts_monitor.png']);
- saveas(hfig,[most_recent_folder 'span' num2str(Nspan) 'ms_lag' num2str(Nlag) 'ms/sample_trials_off_del_shifts_monitor.fig']);
- saveas(hfig,[most_recent_folder 'span' num2str(Nspan) 'ms_lag' num2str(Nlag) 'ms/sample_trials_off_del_shifts_monitor.svg']);
-
- fullfig();
- subplot(1,2,1);
- plotmsem(fulldel1time,nanmedian(squeeze(pooleposxmat_L(:,1,fulldel1time))),'k');
- plot(fulldel1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),99), fulldel1time),'color',[1 1 1].*.85);
- plot(fulldel1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),01), fulldel1time),'color',[1 1 1].*.85);
- plot(fulldel1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),95), fulldel1time),'color',[1 1 1].*.60);
- plot(fulldel1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),05), fulldel1time),'color',[1 1 1].*.60);
- plot(fulldel1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),90), fulldel1time),'color',[1 1 1].*.45);
- plot(fulldel1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),10), fulldel1time),'color',[1 1 1].*.45);
- plot(fulldel1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),75), fulldel1time),'color',[1 1 1].*.25);
- plot(fulldel1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),25), fulldel1time),'color',[1 1 1].*.25);
- plot(fulldel1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),65), fulldel1time),'color',[0 0 1].*.1);
- plot(fulldel1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),35), fulldel1time),'color',[1 1 1].*.1); %ylim([-1 1]);
- plotvline([min(eval(selectedTimes)) max(eval(selectedTimes))]); plothline(0); xlim([min(eval(selectedTimes)) max(eval(selectedTimes))]);
-
- subplot(1,2,2);
- plotmsem(fulldel1time,nanmedian(squeeze(pooleposxmat_R(:,1,fulldel1time))),'k');
- plot(fulldel1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),99), fulldel1time),'color',[1 1 1].*.85);
- plot(fulldel1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),01), fulldel1time),'color',[1 1 1].*.85);
- plot(fulldel1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),95), fulldel1time),'color',[1 1 1].*.60);
- plot(fulldel1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),05), fulldel1time),'color',[1 1 1].*.60);
- plot(fulldel1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),90), fulldel1time),'color',[1 1 1].*.45);
- plot(fulldel1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),10), fulldel1time),'color',[1 1 1].*.45);
- plot(fulldel1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),75), fulldel1time),'color',[1 1 1].*.25);
- plot(fulldel1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),25), fulldel1time),'color',[1 1 1].*.25);
- plot(fulldel1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),65), fulldel1time),'color',[0 0 1].*.1);
- plot(fulldel1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),35), fulldel1time),'color',[1 1 1].*.1); %ylim([-1 1]);
- plotvline([min(eval(selectedTimes)) max(eval(selectedTimes))]); plothline(0); xlim([min(eval(selectedTimes)) max(eval(selectedTimes))]);
- else
- hfig=fullfig();
- subplot(1,2,1); title('Shifts to Left screen side');
- plot(rtmax_ds,(squeeze(pooleposxmat_L(:,1,vtps_ds==1)))./32558); ylim([-1 1]); plothline(0);
- xlabel('time after delay2 aligned to gaze shift initiation (ms)'); ylabel('horizontal eye position (normalized)'); box off
- subplot(1,2,2); title('Shifts to Right screen side');
- plot(rtmax_ds,(squeeze(pooleposxmat_R(:,1,vtps_ds==1)))./32558); ylim([-1 1]); plothline(0);
- xlabel('time after delay2 aligned to gaze shift initiation (ms)'); ylabel('horizontal eye position (normalized)'); box off
- saveas(hfig,[most_recent_folder 'span' num2str(Nspan) 'ms_lag' num2str(Nlag) 'ms/sample_trials_off_del_shifts_monitor.png']);
- saveas(hfig,[most_recent_folder 'span' num2str(Nspan) 'ms_lag' num2str(Nlag) 'ms/sample_trials_off_del_shifts_monitor.fig']);
- saveas(hfig,[most_recent_folder 'span' num2str(Nspan) 'ms_lag' num2str(Nlag) 'ms/sample_trials_off_del_shifts_monitor.svg']);
- %%
- fullfig();
- subplot(1,2,1);
- plotmsem(fulldel2time,nanmedian(squeeze(pooleposxmat_L(:,1,fulldel2time))),'k');
- plot(fulldel2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),99), fulldel2time),'color',[1 1 1].*.85);
- plot(fulldel2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),01), fulldel2time),'color',[1 1 1].*.85);
- plot(fulldel2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),95), fulldel2time),'color',[1 1 1].*.60);
- plot(fulldel2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),05), fulldel2time),'color',[1 1 1].*.60);
- plot(fulldel2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),90), fulldel2time),'color',[1 1 1].*.45);
- plot(fulldel2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),10), fulldel2time),'color',[1 1 1].*.45);
- plot(fulldel2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),75), fulldel2time),'color',[1 1 1].*.25);
- plot(fulldel2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),25), fulldel2time),'color',[1 1 1].*.25);
- plot(fulldel2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),65), fulldel2time),'color',[0 0 1].*.1);
- plot(fulldel2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),35), fulldel2time),'color',[1 1 1].*.1);%ylim([-1 1]);
- plotvline([min(eval(selectedTimes)) max(eval(selectedTimes))]); plothline(0); xlim([min(eval(selectedTimes)) max(eval(selectedTimes))]);
-
- subplot(1,2,2);
- plotmsem(fulldel2time,nanmedian(squeeze(pooleposxmat_R(:,1,fulldel2time))),'k');
- plot(fulldel2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),99), fulldel2time),'color',[1 1 1].*.85);
- plot(fulldel2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),01), fulldel2time),'color',[1 1 1].*.85);
- plot(fulldel2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),95), fulldel2time),'color',[1 1 1].*.60);
- plot(fulldel2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),05), fulldel2time),'color',[1 1 1].*.60);
- plot(fulldel2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),90), fulldel2time),'color',[1 1 1].*.45);
- plot(fulldel2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),10), fulldel2time),'color',[1 1 1].*.45);
- plot(fulldel2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),75), fulldel2time),'color',[1 1 1].*.25);
- plot(fulldel2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),25), fulldel2time),'color',[1 1 1].*.25);
- plot(fulldel2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),65), fulldel2time),'color',[0 0 1].*.1);
- plot(fulldel2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),35), fulldel2time),'color',[1 1 1].*.1);%ylim([-1 1]);
- plotvline([min(eval(selectedTimes)) max(eval(selectedTimes))]); plothline(0); xlim([min(eval(selectedTimes)) max(eval(selectedTimes))]);
- end
- %%
- % fullfig();
- % subplot(1,4,1);
- % spy(vectorisen(~isnan(poolspksqmat_shLalgn(:,cumsum(nccs),:)),1:2));
- % subplot(1,4,2);
- % spy(vectorisen(~isnan(poolspksqmat_shRalgn(:,cumsum(nccs),:)),1:2));
- % subplot(1,4,3);
- % spy(vectorisen(~isnan(pooleposxmat_shLalgn(:,cumsum(nccs),:)),1:2));
- % subplot(1,4,4);
- % spy(vectorisen(~isnan(pooleposxmat_shRalgn(:,cumsum(nccs),:)),1:2));
- % title('Aligned to shifts');
- %%
- hfig=fullfig(); hfig.Position=[0 0 .5 1];
- subplot(2,1,1); ylim([0 100]); hold on
- plot(rtmax_ds,squeeze(sum(~isnan(pooleposxmat_L(:,cumsum(nccs),vtps_ds==1))))./repmat(ntrs',1,sum(vtps_ds>0))*100); hold on
- for jj=1:8; plot([1 1].*sum(rtmes_ds(1:jj)),get(gca,'YLim'),'k:'); text(sum(rtmes_ds(1:jj-1)),max(get(gca,'YLim')),twLabels{jj}); end
- subplot(2,1,2); ylim([0 100]); hold on
- plot(rtmax_ds,squeeze(sum(~isnan(pooleposxmat_R(:,cumsum(nccs),vtps_ds==1))))./repmat(ntrs',1,sum(vtps_ds>0))*100); hold on
- for jj=1:8; plot([1 1].*sum(rtmes_ds(1:jj)),get(gca,'YLim'),'k:'); text(sum(rtmes_ds(1:jj-1)),max(get(gca,'YLim')),twLabels{jj}); end
- legend({'subj 1, sn 1','subj 1, sn 2','subj 1, sn 3','subj 1, sn 4','subj 2, sn 1','subj 2, sn 2','subj 2, sn 3','subj 2, sn 4'},'box','off');
- switch selflag
- case 1
- subplot(2,1,1);
- title('Look Left Offer1 & Look Left Delay1'); ylim([0 100]); ylabel('% trials'); xlabel('Delay1 time bins (10 ms)');
- subplot(2,1,2);
- title('Look Left Offer1 & Look Right Delay1'); ylim([0 100]); ylabel('% trials'); xlabel('Delay1 time bins (10 ms)');
- case 2
- subplot(2,1,1);
- title('Look Right Offer1 & Look Left Delay1'); ylim([0 100]); ylabel('% trials'); xlabel('Delay1 time bins (10 ms)');
- subplot(2,1,2);
- title('Look Right Offer1 & Look Right Delay1'); ylim([0 100]); ylabel('% trials'); xlabel('Delay1 time bins (10 ms)');
- case 3
- subplot(2,1,1);
- title('Look Left Offer2 & Look Left Delay2'); ylim([0 100]); ylabel('% trials'); xlabel('Delay2 time bins (10 ms)');
- subplot(2,1,2);
- title('Look Left Offer2 & Look Right Delay2'); ylim([0 100]); ylabel('% trials'); xlabel('Delay2 time bins (10 ms)');
- case 4
- subplot(2,1,1);
- title('Look Right Offer2 & Look Left Delay2'); ylim([0 100]); ylabel('% trials'); xlabel('Delay2 time bins (10 ms)');
- subplot(2,1,2);
- title('Look Right Offer2 & Look Right Delay2'); ylim([0 100]); ylabel('% trials'); xlabel('Delay2 time bins (10 ms)');
- end
- saveas(hfig,[most_recent_folder 'span' num2str(Nspan) 'ms_lag' num2str(Nlag) 'ms/frac_trials_off_del.png']);
- saveas(hfig,[most_recent_folder 'span' num2str(Nspan) 'ms_lag' num2str(Nlag) 'ms/frac_trials_off_del.fig']);
- saveas(hfig,[most_recent_folder 'span' num2str(Nspan) 'ms_lag' num2str(Nlag) 'ms/frac_trials_off_del.svg']);
- clearvars pooleposxmat_L pooleposxmat_R
- %%
- if any(caseflag==[1 2 4 5])
- hfig=fullfig(); hfig.Position=[0 0 .5 1];
- subplot(2,1,1); ylim([0 100]); hold on; gg=gca;
- %plot(1:Ntps_ds,squeeze(sum(~isnan(poolspksqmat_shLonly(:,cumsum(nccs),:))))./repmat(ntrs',1,Ntps_ds)*100); hold on
- pp=plot(eval(selectedTimes),squeeze(sum(~isnan(poolspksqmat_shLonly(:,cumsum(nccs),eval(selectedTimes)))))./repmat(ntrs',1,length(eval(selectedTimes)))*100); hold on
- for jj=1:8
- plot(1:Ntps_ds,squeeze(sum(~isnan(poolspksqmat_shLonly(:,sum(nccs(1:jj)),:))))./repmat(ntrs(jj)',1,Ntps_ds)*100,':','color',pp(jj).Color); hold on
- end
- for jj=1:7; plotvline(ntce_ds(jj,1:2)); text(ntce_ds(jj,1),max(get(gca,'YLim')),twLabels{jj}); end
- %xlim([189 438]);%xlim([1 Ntps_ds]);
- subplot(2,1,2); ylim([0 100]); hold on
- %plot(1:Ntps_ds,squeeze(sum(~isnan(poolspksqmat_shRonly(:,cumsum(nccs),:))))./repmat(ntrs',1,Ntps_ds)*100); hold on
- pp=plot(eval(selectedTimes),squeeze(sum(~isnan(poolspksqmat_shRonly(:,cumsum(nccs),eval(selectedTimes)))))./repmat(ntrs',1,length(eval(selectedTimes)))*100); hold on
- for jj=1:8
- plot(1:Ntps_ds,squeeze(sum(~isnan(poolspksqmat_shRonly(:,sum(nccs(1:jj)),:))))./repmat(ntrs(jj)',1,Ntps_ds)*100,':','color',pp(jj).Color); hold on
- end
-
- for jj=1:7; plotvline(ntce_ds(jj,1:2)); tt=text(ntce_ds(jj,1),.85*max(get(gca,'YLim')),twLabels{jj},'Rotation',90); end
- legend({'subj 1, sn 1','subj 1, sn 2','subj 1, sn 3','subj 1, sn 4','subj 2, sn 1','subj 2, sn 2','subj 2, sn 3','subj 2, sn 4'},'box','off');
- %xlim([189 438]);%xlim([1 Ntps_ds]);
- switch selflag
- case 1
- subplot(2,1,1);
- title('Look Left Offer1 & Look Left Delay1'); ylim([0 100]); ylabel('% trials'); xlabel('Delay1 time bins (10 ms)');
- subplot(2,1,2);
- title('Look Left Offer1 & Look Right Delay1'); ylim([0 100]); ylabel('% trials'); xlabel('Delay1 time bins (10 ms)');
- case 2
- subplot(2,1,1);
- title('Look Right Offer1 & Look Left Delay1'); ylim([0 100]); ylabel('% trials'); xlabel('Delay1 time bins (10 ms)');
- subplot(2,1,2);
- title('Look Right Offer1 & Look Right Delay1'); ylim([0 100]); ylabel('% trials'); xlabel('Delay1 time bins (10 ms)');
- case 3
- subplot(2,1,1);
- title('Look Left Offer2 & Look Left Delay2'); ylim([0 100]); ylabel('% trials'); xlabel('Delay2 time bins (10 ms)');
- subplot(2,1,2);
- title('Look Left Offer2 & Look Right Delay2'); ylim([0 100]); ylabel('% trials'); xlabel('Delay2 time bins (10 ms)');
- case 4
- subplot(2,1,1);
- title('Look Right Offer2 & Look Left Delay2'); ylim([0 100]); ylabel('% trials'); xlabel('Delay2 time bins (10 ms)');
- subplot(2,1,2);
- title('Look Right Offer2 & Look Right Delay2'); ylim([0 100]); ylabel('% trials'); xlabel('Delay2 time bins (10 ms)');
- end
- saveas(hfig,[most_recent_folder 'span' num2str(Nspan) 'ms_lag' num2str(Nlag) 'ms/frac_trials_off_del_shifts.png']);
- saveas(hfig,[most_recent_folder 'span' num2str(Nspan) 'ms_lag' num2str(Nlag) 'ms/frac_trials_off_del_shifts.fig']);
- saveas(hfig,[most_recent_folder 'span' num2str(Nspan) 'ms_lag' num2str(Nlag) 'ms/frac_trials_off_del_shifts.svg']);
- end
- end
- %% Regress EV vs Spiking
- close all;
- if recomputelm
- lmELpv=nan(Nccs,Ntps_ds); lmELpv_shf=nan(Nccs,Ntps_ds,Nshf); lmERpv=nan(Nccs,Ntps_ds); lmERpv_shf=nan(Nccs,Ntps_ds,Nshf);
- lmELpvLL=nan(Nccs,Ntps_ds); lmELpvLL_shf=nan(Nccs,Ntps_ds,Nshf); lmERpvLL=nan(Nccs,Ntps_ds); lmERpvLL_shf=nan(Nccs,Ntps_ds,Nshf);
- lmELpvLR=nan(Nccs,Ntps_ds); lmELpvLR_shf=nan(Nccs,Ntps_ds,Nshf); lmERpvLR=nan(Nccs,Ntps_ds); lmERpvLR_shf=nan(Nccs,Ntps_ds,Nshf);
- lmELR2=nan(Nccs,Ntps_ds); lmELR2_shf=nan(Nccs,Ntps_ds,Nshf); lmERR2=nan(Nccs,Ntps_ds); lmERR2_shf=nan(Nccs,Ntps_ds,Nshf);
- lmELR2LL=nan(Nccs,Ntps_ds); lmELR2LL_shf=nan(Nccs,Ntps_ds,Nshf); lmERR2LL=nan(Nccs,Ntps_ds); lmERR2LL_shf=nan(Nccs,Ntps_ds,Nshf);
- lmELR2LR=nan(Nccs,Ntps_ds); lmELR2LR_shf=nan(Nccs,Ntps_ds,Nshf); lmERR2LR=nan(Nccs,Ntps_ds); lmERR2LR_shf=nan(Nccs,Ntps_ds,Nshf);
- lmELb0=nan(Nccs,Ntps_ds); lmELb0_shf=nan(Nccs,Ntps_ds,Nshf); lmERb0=nan(Nccs,Ntps_ds); lmERb0_shf=nan(Nccs,Ntps_ds,Nshf);
- lmELb0LL=nan(Nccs,Ntps_ds); lmELb0LL_shf=nan(Nccs,Ntps_ds,Nshf); lmERb0LL=nan(Nccs,Ntps_ds); lmERb0LL_shf=nan(Nccs,Ntps_ds,Nshf);
- lmELb0LR=nan(Nccs,Ntps_ds); lmELb0LR_shf=nan(Nccs,Ntps_ds,Nshf); lmERb0LR=nan(Nccs,Ntps_ds); lmERb0LR_shf=nan(Nccs,Ntps_ds,Nshf);
- lmELb1=nan(Nccs,Ntps_ds); lmELb1_shf=nan(Nccs,Ntps_ds,Nshf); lmERb1=nan(Nccs,Ntps_ds); lmERb1_shf=nan(Nccs,Ntps_ds,Nshf);
- lmELb1LL=nan(Nccs,Ntps_ds); lmELb1LL_shf=nan(Nccs,Ntps_ds,Nshf); lmERb1LL=nan(Nccs,Ntps_ds); lmERb1LL_shf=nan(Nccs,Ntps_ds,Nshf);
- lmELb1LR=nan(Nccs,Ntps_ds); lmELb1LR_shf=nan(Nccs,Ntps_ds,Nshf); lmERb1LR=nan(Nccs,Ntps_ds); lmERb1LR_shf=nan(Nccs,Ntps_ds,Nshf);
- lmntrsLL=nan(Nccs,Ntps_ds); lmntrsLR=nan(Nccs,Ntps_ds); lmntrsLL_nn=nan(Nccs,Ntps_ds); lmntrsLR_nn=nan(Nccs,Ntps_ds); lmntrsLL_nn_shLalgn=nan(Nccs,Ntps_ds); lmntrsLR_nn_shRalgn=nan(Nccs,Ntps_ds);
- for cc=1:Nccs
- ccoff1rw=pooloffer1rw(:,cc);
- ccoff2rw=pooloffer2rw(:,cc);
- ccoff1ev=pooloffer1ev(:,cc);
- ccoff2ev=pooloffer2ev(:,cc);
- ccspk=squeeze(poolspksqmat_ds_bln(:,cc,:)); % For linear fit
- %%%%% ccspk=squeeze(poolspksqmat_ds(:,cc,:)); % For Poisson fit
- ccepx=squeeze(pooleposxmat_ds_bln(:,cc,:));
-
- %%% shift aligned
- ccspk_shLalgn=squeeze(poolspksqmat_shLalgn(:,cc,:));
- ccspk_shRalgn=squeeze(poolspksqmat_shRalgn(:,cc,:));
- ccepx_shLalgn=squeeze(pooleposxmat_shLalgn(:,cc,:));
- ccepx_shRalgn=squeeze(pooleposxmat_shRalgn(:,cc,:));
- ccisdelSL=isdelSL(:,cc);
- ccisdelSR=isdelSR(:,cc);
-
- % cciso1LLd2LL=iso1LLd2LL(:,cc);
- % cciso1LLd2LR=iso1LLd2LR(:,cc);
- %cciso1LLd1LLd2LL=iso1LLd1LLd2LL(:,cc);
- %cciso1LLd1LLd2LR=iso1LLd1LLd2LR(:,cc);
- % cciso2LRd2LL=iso2LRd2LL(:,cc);
- % cciso2LLd2LL=iso2LLd2LL(:,cc);
- % cciso2LRd2LR=iso2LRd2LR(:,cc);
- % cciso2LLd2LR=iso2LLd2LR(:,cc);
- rmallnans=isnan(ccoff1ev);
- rmtrials=rmallnans;%(rmallnans | ccoff1rw~=1 | ccoff2rw~=1);
- %ccspk(rmallnans,:)=[];
- %ccepx(rmallnans,:)=[];
- %ccoff1ev(rmallnans)=[];
- %ccoff2ev(rmallnans)=[];
- ccspk(rmtrials,:)=[];
- ccepx(rmtrials,:)=[];
- ccoff1ev(rmtrials)=[];
- ccoff2ev(rmtrials)=[];
- ccoff1rw(rmtrials)=[];
- ccoff2rw(rmtrials)=[];
- %cciso2LRd2LL(rmtrials)=[];
- %cciso2LRd2LR(rmtrials)=[];
- %cciso2LLd2LL(rmtrials)=[];
- %cciso2LLd2LR(rmtrials)=[];
- %cciso1LLd1LLd2LL(rmtrials)=[];
- %cciso1LLd1LLd2LR(rmtrials)=[];
- ccisdelSL(rmtrials)=[];
- ccisdelSR(rmtrials)=[];
- ccspk_shLalgn(rmtrials,:)=[];
- ccspk_shRalgn(rmtrials,:)=[];
- ccepx_shLalgn(rmtrials,:)=[];
- ccepx_shRalgn(rmtrials,:)=[];
- ccntrs=size(ccspk,1);
-
- % ccspk_shf=nan(Nshf,size(ccspk,1),size(ccspk,2)); %time-shuffle
- % for jj=1:Nshf %time-shuffle
- % for ttr=1:ccntrs %time-shuffle
- % isnn=find(~isnan(ccspk(ttr,:))); %time-shuffle
- % ccspk_shf(jj,ttr,isnn)=ccspk(ttr,isnn(randperm(length(isnn)))); %time-shuffle
- % %isvtps=find(vtps_ds==1); %time-shuffle
- % %ccspk_shf(jj,ttr,isvtps)=ccspk(ttr,isvtps(randperm(length(isvtps)))); %time-shuffle
- % end %time-shuffle
- % end %time-shuffle
- parfor tt=eval(selectedTimes) % delay1
- %for tt=eval(selectedTimes)
- %parfor tt=(ntce_ds(5,1):ntce_ds(5,2)) % delay2
- %for tt=1:Ntps_ds
- warning('off','all')
- if 1%vtps_ds(tt)==1 % discards low trials times
- ctspk=squeeze(ccspk(:,tt));
- ctepx=squeeze(ccepx(:,tt));
- ctspk_shLalgn=squeeze(ccspk_shLalgn(:,tt));
- ctspk_shRalgn=squeeze(ccspk_shRalgn(:,tt));
-
- ctlm1=fitlm(ccoff1ev,ctspk);
- ctlm2=fitlm(ccoff2ev,ctspk);
- % ctlm1=fitglm(ccoff1ev,ctspk,'linear','Distribution','poisson');
- % ctlm2=fitglm(ccoff2ev,ctspk,'linear','Distribution','poisson');
- lmELpv(cc,tt)=ctlm1.Coefficients.pValue(2);
- lmERpv(cc,tt)=ctlm2.Coefficients.pValue(2);
- lmELR2(cc,tt)=ctlm1.Rsquared.Ordinary;
- lmERR2(cc,tt)=ctlm2.Rsquared.Ordinary;
- lmELb0(cc,tt)=ctlm1.Coefficients.Estimate(1);
- lmERb0(cc,tt)=ctlm2.Coefficients.Estimate(1);
- lmELb1(cc,tt)=ctlm1.Coefficients.Estimate(2);
- lmERb1(cc,tt)=ctlm2.Coefficients.Estimate(2);
-
- cciso1LL=(nanmean(ccepx(:,off1time),2)<0);
- ccisd1LL=(nanmean(ccepx(:,del1time),2)<0);
- cciso2LL=(nanmean(ccepx(:,off2time),2)<0);
- ccisd2LL=(nanmean(ccepx(:,del2time),2)<0);
-
- %[nuL,~,~,ishiftsL]=nanmonotonicdrifts_forward_simplified(ccepx(:,fulldel1time),2,0,-1,1,1);
- %check1=find(~isnan(ishiftsL));
- %check0=find((ccisdelSL));
-
- % ccisd1allLL=(arrayfun(@(xx) all((ccepx(xx,fulldel1time(1)-1+find(~isnan(ccepx(xx,fulldel1time)))))<=0),1:size(ccepx,1)));
- % ccisd1allLR=(arrayfun(@(xx) all((ccepx(xx,fulldel1time(1)-1+find(~isnan(ccepx(xx,fulldel1time)))))>=0),1:size(ccepx,1)));
-
- ccisd1allLL=(arrayfun(@(xx) all((ccepx(xx,fulldel1time(41)-1+find(~isnan(ccepx(xx,fulldel1time(41:end))))))<=0),1:size(ccepx,1)));
- ccisd1allLR=(arrayfun(@(xx) all((ccepx(xx,fulldel1time(41)-1+find(~isnan(ccepx(xx,fulldel1time(41:end))))))>=0),1:size(ccepx,1)));
-
- %fullfig(); subplot(1,2,1); plot(fulldel1time,ccepx(ccisd1allLL,fulldel1time));
- % subplot(1,2,2); plot(fulldel1time,ccepx(ccisd1allLR,fulldel1time));
-
- % ccisd2allLL=(arrayfun(@(xx) all((ccepx(xx,fulldel2time(1)-1+find(~isnan(ccepx(xx,fulldel2time)))))<=0),1:size(ccepx,1)));
- % ccisd2allLR=(arrayfun(@(xx) all((ccepx(xx,fulldel2time(1)-1+find(~isnan(ccepx(xx,fulldel2time)))))>=0),1:size(ccepx,1)));
- ccisd2allLL=(arrayfun(@(xx) all((ccepx(xx,fulldel2time(41)-1+find(~isnan(ccepx(xx,fulldel2time(41:end))))))<=0),1:size(ccepx,1)));
- ccisd2allLR=(arrayfun(@(xx) all((ccepx(xx,fulldel2time(41)-1+find(~isnan(ccepx(xx,fulldel2time(41:end))))))>=0),1:size(ccepx,1)));
- %fullfig(); subplot(1,2,1); plot(fulldel2time,ccepx(ccisd2allLL,fulldel2time));
- % subplot(1,2,2); plot(fulldel2time,ccepx(ccisd2allLR,fulldel2time));
-
- switch selflag
- case 1 % OFFER1 LookL and DELAY1 LookL/R
- %isLL=find((cciso1LL) & (ccepx(:,tt)<0));
- %isLR=find((cciso1LL) & (ccepx(:,tt)>0));
- %isLL=find((cciso1LL) & (ccisdelSL));
- %isLR=find((cciso1LL) & (ccisdelSR));
- %isLL=find((ccisdelSL));
- %isLR=find((ccisdelSR));
- switch caseflag
- case {1,2}
- isLL=find((ccisdelSL));
- isLR=find((ccisdelSR));
- case 3
- isLL=find((ccisd1allLL));
- isLR=find((ccisd1allLR));
- case {4,5}
- isLL=find((cciso1LL) & (ccisdelSL));
- isLR=find((cciso1LL) & (ccisdelSR));
- case 6
- isLL=find((cciso1LL) & (ccisd1allLL)');
- isLR=find((cciso1LL) & (ccisd1allLR)');
- end
- case 2 % OFFER1 LookR and DELAY1 LookL/R
- %isLL=find((~cciso1LL) & (ccepx(:,tt)<0));
- %isLR=find((~cciso1LL) & (ccepx(:,tt)>0));
- isLL=find((~cciso1LL) & (ccisdelSL));
- isLR=find((~cciso1LL) & (ccisdelSR));
- case 3 % OFFER2 LookL and DELAY2 LookL/R
- %isLL=find((cciso2LL) & (ccepx(:,tt)<0));
- %isLR=find((cciso2LL) & (ccepx(:,tt)>0));
- isLL=find((cciso2LL) & (ccisdelSL));
- isLR=find((cciso2LL) & (ccisdelSR));
- case 4 % OFFER2 LookR and DELAY2 LookL/R
- %isLL=find((~cciso2LL) & (ccepx(:,tt)<0));
- %isLR=find((~cciso2LL) & (ccepx(:,tt)>0));
- %isLL=find((~cciso2LL) & (ccisdelSL));
- %isLR=find((~cciso2LL) & (ccisdelSR));
- %isLL=find((ccisdelSL));
- %isLR=find((ccisdelSR));
- switch caseflag
- case {1,2}
- isLL=find((ccisdelSL));
- isLR=find((ccisdelSR));
- case 3
- isLL=find((ccisd2allLL));
- isLR=find((ccisd2allLR));
- case {4,5}
- isLL=find((~cciso2LL) & (ccisdelSL));
- isLR=find((~cciso2LL) & (ccisdelSR));
- case 6
- isLL=find((~cciso2LL) & (ccisd2allLL)');
- isLR=find((~cciso2LL) & (ccisd2allLR)');
- end
- %isLL=find((~cciso2LL) & (ccisd2allLL)');
- %isLR=find((~cciso2LL) & (ccisd2allLR)');
- %isLL=find((ccisd2allLL));
- %isLR=find((ccisd2allLR));
- end
-
- %Relevant cases:
- % Left in offer1 and Right in delay1
- % Right in offer2 and Left in delay2
- % control cases:
- % Right in offer1
- % Left in offer2
- niLL=length(isLL);
- if (caseflag==3 || caseflag==6)
- ctlm1LL=fitlm(ccoff1ev(isLL),ctspk(isLL));
- ctlm2LL=fitlm(ccoff2ev(isLL),ctspk(isLL));
- else
- ctlm1LL=fitlm(ccoff1ev(isLL),ctspk_shLalgn(isLL));
- ctlm2LL=fitlm(ccoff2ev(isLL),ctspk_shLalgn(isLL));
- end
- lmELpvLL(cc,tt)=ctlm1LL.Coefficients.pValue(2);
- lmERpvLL(cc,tt)=ctlm2LL.Coefficients.pValue(2);
- lmELR2LL(cc,tt)=ctlm1LL.Rsquared.Ordinary;
- lmERR2LL(cc,tt)=ctlm2LL.Rsquared.Ordinary;
- lmELb0LL(cc,tt)=ctlm1LL.Coefficients.Estimate(1);
- lmERb0LL(cc,tt)=ctlm2LL.Coefficients.Estimate(1);
- lmELb1LL(cc,tt)=ctlm1LL.Coefficients.Estimate(2);
- lmERb1LL(cc,tt)=ctlm2LL.Coefficients.Estimate(2);
- lmntrsLL(cc,tt)=niLL;
- lmntrsLL_nn(cc,tt)=sum(~isnan(ctspk(isLL)));
- lmntrsLL_nn_shLalgn(cc,tt)=sum(~isnan(ctspk_shLalgn(isLL)));
-
- niLR=length(isLR);
- if (caseflag==3 || caseflag==6)
- ctlm1LR=fitlm(ccoff1ev(isLR),ctspk(isLR));
- ctlm2LR=fitlm(ccoff2ev(isLR),ctspk(isLR));
- else
- ctlm1LR=fitlm(ccoff1ev(isLR),ctspk_shRalgn(isLR));
- ctlm2LR=fitlm(ccoff2ev(isLR),ctspk_shRalgn(isLR));
- end
- lmELpvLR(cc,tt)=ctlm1LR.Coefficients.pValue(2);
- lmERpvLR(cc,tt)=ctlm2LR.Coefficients.pValue(2);
- lmELR2LR(cc,tt)=ctlm1LR.Rsquared.Ordinary;
- lmERR2LR(cc,tt)=ctlm2LR.Rsquared.Ordinary;
- lmELb0LR(cc,tt)=ctlm1LR.Coefficients.Estimate(1);
- lmERb0LR(cc,tt)=ctlm2LR.Coefficients.Estimate(1);
- lmELb1LR(cc,tt)=ctlm1LR.Coefficients.Estimate(2);
- lmERb1LR(cc,tt)=ctlm2LR.Coefficients.Estimate(2);
- lmntrsLR(cc,tt)=niLR;
- lmntrsLR_nn(cc,tt)=sum(~isnan(ctspk(isLR)));
- lmntrsLR_nn_shRalgn(cc,tt)=sum(~isnan(ctspk_shRalgn(isLR)));
-
- for shf=1:Nshf
- i1shf=randperm(ccntrs); %trial-shuffle
- i2shf=randperm(ccntrs); %trial-shuffle
- isshf=randperm(ccntrs); %trial-shuffle
- ctlm1_shf=fitlm(ccoff1ev(i1shf),ctspk(isshf)); %trial-shuffle
- ctlm2_shf=fitlm(ccoff2ev(i2shf),ctspk(isshf)); %trial-shuffle
- lmELpv_shf(cc,tt,shf)=ctlm1_shf.Coefficients.pValue(2);
- lmERpv_shf(cc,tt,shf)=ctlm2_shf.Coefficients.pValue(2);
- lmELR2_shf(cc,tt,shf)=ctlm1_shf.Rsquared.Ordinary;
- lmERR2_shf(cc,tt,shf)=ctlm2_shf.Rsquared.Ordinary;
- lmELb0_shf(cc,tt,shf)=ctlm1_shf.Coefficients.Estimate(1);
- lmERb0_shf(cc,tt,shf)=ctlm2_shf.Coefficients.Estimate(1);
- lmELb1_shf(cc,tt,shf)=ctlm1_shf.Coefficients.Estimate(2);
- lmERb1_shf(cc,tt,shf)=ctlm2_shf.Coefficients.Estimate(2);
-
- i1LLshf=isLL(randperm(niLL)); %trial-shuffle
- i2LLshf=isLL(randperm(niLL)); %trial-shuffle
- isLLshf=isLL(randperm(niLL)); %trial-shuffle
- if (caseflag==3 || caseflag==6)
- ctlm1LL_shf=fitlm(ccoff1ev(i1LLshf),ctspk(isLLshf)); %trial-shuffle
- ctlm2LL_shf=fitlm(ccoff2ev(i2LLshf),ctspk(isLLshf)); %trial-shuffle
- else
- ctlm1LL_shf=fitlm(ccoff1ev(i1LLshf),ctspk_shLalgn(isLLshf)); %trial-shuffle
- ctlm2LL_shf=fitlm(ccoff2ev(i2LLshf),ctspk_shLalgn(isLLshf)); %trial-shuffle
- end
- lmELpvLL_shf(cc,tt,shf)=ctlm1LL_shf.Coefficients.pValue(2);
- lmERpvLL_shf(cc,tt,shf)=ctlm2LL_shf.Coefficients.pValue(2);
- lmELR2LL_shf(cc,tt,shf)=ctlm1LL_shf.Rsquared.Ordinary;
- lmERR2LL_shf(cc,tt,shf)=ctlm2LL_shf.Rsquared.Ordinary;
- lmELb0LL_shf(cc,tt,shf)=ctlm1LL_shf.Coefficients.Estimate(1);
- lmERb0LL_shf(cc,tt,shf)=ctlm2LL_shf.Coefficients.Estimate(1);
- lmELb1LL_shf(cc,tt,shf)=ctlm1LL_shf.Coefficients.Estimate(2);
- lmERb1LL_shf(cc,tt,shf)=ctlm2LL_shf.Coefficients.Estimate(2);
-
- i1LRshf=isLR(randperm(niLR)); %trial-shuffle
- i2LRshf=isLR(randperm(niLR)); %trial-shuffle
- isLRshf=isLR(randperm(niLR)); %trial-shuffle
- if (caseflag==3 || caseflag==6)
- ctlm1LR_shf=fitlm(ccoff1ev(i1LRshf),ctspk(isLRshf)); %trial-shuffle
- ctlm2LR_shf=fitlm(ccoff2ev(i2LRshf),ctspk(isLRshf)); %trial-shuffle
- else
- ctlm1LR_shf=fitlm(ccoff1ev(i1LRshf),ctspk_shRalgn(isLRshf)); %trial-shuffle
- ctlm2LR_shf=fitlm(ccoff2ev(i2LRshf),ctspk_shRalgn(isLRshf)); %trial-shuffle
- end
- lmELpvLR_shf(cc,tt,shf)=ctlm1LR_shf.Coefficients.pValue(2);
- lmERpvLR_shf(cc,tt,shf)=ctlm2LR_shf.Coefficients.pValue(2);
- lmELR2LR_shf(cc,tt,shf)=ctlm1LR_shf.Rsquared.Ordinary;
- lmERR2LR_shf(cc,tt,shf)=ctlm2LR_shf.Rsquared.Ordinary;
- lmELb0LR_shf(cc,tt,shf)=ctlm1LR_shf.Coefficients.Estimate(1);
- lmERb0LR_shf(cc,tt,shf)=ctlm2LR_shf.Coefficients.Estimate(1);
- lmELb1LR_shf(cc,tt,shf)=ctlm1LR_shf.Coefficients.Estimate(2);
- lmERb1LR_shf(cc,tt,shf)=ctlm2LR_shf.Coefficients.Estimate(2);
- end
- end
- warning('on','all')
- end
- disp([sprintf('%s',datetime('now','Format','HH:mm')) ' - done: ' num2str(cc) '/' num2str(Nccs) ', ' num2str(cc/Nccs.*100) '%']);
- end
- save([most_recent_folder 'fitlmstats_span_' num2str(Nspan) 'ms_lag_' num2str(Nlag) 'ms_' date '.mat'],'lmE*','lmntr*');
- else
- %load(['fitlmstats_span_' num2str(Nspan) 'ms_lag_' num2str(Nlag) 'ms_13-May-2022.mat']);
- end
- %%
- hfig=fullfig(); hfig.Position=[0 0 .5 1];
- if any(caseflag==[1 2 4 5])
- subplot(2,1,1);
- plot(rtmax_ds,(lmntrsLL_nn_shLalgn(cumsum(nccs),vtps_ds==1))./repmat(ntrs',1,nansum(vtps_ds)).*100);
- subplot(2,1,2);
- plot(rtmax_ds,(lmntrsLR_nn_shRalgn(cumsum(nccs),vtps_ds==1))./repmat(ntrs',1,nansum(vtps_ds)).*100);
- else
- subplot(2,1,1);
- plot(rtmax_ds,(lmntrsLL_nn(cumsum(nccs),vtps_ds==1))./repmat(ntrs',1,nansum(vtps_ds)).*100);
- subplot(2,1,2);
- plot(rtmax_ds,(lmntrsLR_nn(cumsum(nccs),vtps_ds==1))./repmat(ntrs',1,nansum(vtps_ds)).*100);
- end
- switch selflag
- case 1
- subplot(2,1,1);
- title('Look Left Offer1 & Look Left Delay1'); ylim([0 100]); ylabel('% trials'); xlabel('Delay1 time bins (10 ms)');
- subplot(2,1,2);
- title('Look Left Offer1 & Look Right Delay1'); ylim([0 100]); ylabel('% trials'); xlabel('Delay1 time bins (10 ms)');
- case 2
- subplot(2,1,1);
- title('Look Right Offer1 & Look Left Delay1'); ylim([0 100]); ylabel('% trials'); xlabel('Delay1 time bins (10 ms)');
- subplot(2,1,2);
- title('Look Right Offer1 & Look Right Delay1'); ylim([0 100]); ylabel('% trials'); xlabel('Delay1 time bins (10 ms)');
- case 3
- subplot(2,1,1);
- title('Look Left Offer2 & Look Left Delay2'); ylim([0 100]); ylabel('% trials'); xlabel('Delay2 time bins (10 ms)');
- subplot(2,1,2);
- title('Look Left Offer2 & Look Right Delay2'); ylim([0 100]); ylabel('% trials'); xlabel('Delay2 time bins (10 ms)');
- case 4
- subplot(2,1,1);
- title('Look Right Offer2 & Look Left Delay2'); ylim([0 100]); ylabel('% trials'); xlabel('Delay2 time bins (10 ms)');
- subplot(2,1,2);
- title('Look Right Offer2 & Look Right Delay2'); ylim([0 100]); ylabel('% trials'); xlabel('Delay2 time bins (10 ms)');
- end
- hl=legend(strsplit(sprintf('session %d-',1:8),'-'));
- saveas(hfig,[most_recent_folder 'span' num2str(Nspan) 'ms_lag' num2str(Nlag) 'ms/frac_trials_off_del_selected.png']);
- saveas(hfig,[most_recent_folder 'span' num2str(Nspan) 'ms_lag' num2str(Nlag) 'ms/frac_trials_off_del_selected.fig']);
- saveas(hfig,[most_recent_folder 'span' num2str(Nspan) 'ms_lag' num2str(Nlag) 'ms/frac_trials_off_del_selected.svg']);
- %% Plot colors
- o1col = [ 55 188 52]/255;
- o2col = [ 55 131 200]/255;
- o3col = [121 121 121]/255;
- o1LLcol=[ 50 148 48]/255;
- o2LLcol=[ 55 97 135]/255;
- o3LLcol=[ 43 43 43]/255;
- o1LRcol=[135 215 133]/255;
- o2LRcol=[144 187 226]/255;
- o3LRcol=[168 168 168]/255;
- o1LLcol=[212 87 28]/255;
- o1LRcol=[251 179 144]/255;
- o2LLcol=[119 30 152]/255;
- o2LRcol=[185 118 210]/255;
- %%
- lmELpvd=double(lmELpv(:,vtps_ds==1)<0.05);
- lmERpvd=double(lmERpv(:,vtps_ds==1)<0.05);
- lmELpvdLL=double(lmELpvLL(:,vtps_ds==1)<0.05);
- lmERpvdLL=double(lmERpvLL(:,vtps_ds==1)<0.05);
- lmELpvdLR=double(lmELpvLR(:,vtps_ds==1)<0.05);
- lmERpvdLR=double(lmERpvLR(:,vtps_ds==1)<0.05);
- lmELpvd_shf=squeeze(double(lmELpv_shf(:,vtps_ds==1,:)<0.05));
- lmERpvd_shf=squeeze(double(lmERpv_shf(:,vtps_ds==1,:)<0.05));
- lmELpvdLL_shf=squeeze(double(lmELpvLL_shf(:,vtps_ds==1,:)<0.05));
- lmERpvdLL_shf=squeeze(double(lmERpvLL_shf(:,vtps_ds==1,:)<0.05));
- lmELpvdLR_shf=squeeze(double(lmELpvLR_shf(:,vtps_ds==1,:)<0.05));
- lmERpvdLR_shf=squeeze(double(lmERpvLR_shf(:,vtps_ds==1,:)<0.05));
- hfig=fullfig();
- subplot(3,1,1);
- plotcmapdots([o1col; o2col]); hold on
- runlength(nanmean(lmELpvd),squeeze(nanmean(lmELpvd_shf)),1,rtmax_ds,o1col,0.005);
- runlength(nanmean(lmERpvd),squeeze(nanmean(lmERpvd_shf)),1,rtmax_ds,o2col,0.002);
- for jj=1:8; plot([1 1].*sum(rtmes_ds(1:jj)),[0 0.2],'k:'); text(sum(rtmes_ds(1:jj-1)),.21,twLabels{jj}); end
- hl=legend({'E(L)','E(R)'}); ylim([0 0.2]); box(hl,'on');
- xlabel('time bins (10 ms)'); ylabel('% signif. cells');
- subplot(3,1,2);
- plotcmapdots([o1LLcol; o1LRcol]); hold on
- runlength(nanmean(lmELpvdLL),squeeze(nanmean(lmELpvdLL_shf)),1,rtmax_ds,o1LLcol,0.005);
- runlength(nanmean(lmELpvdLR),squeeze(nanmean(lmELpvdLR_shf)),1,rtmax_ds,o1LRcol,0.002);
- for jj=1:8; plot([1 1].*sum(rtmes_ds(1:jj)),[0 0.2],'k:'); text(sum(rtmes_ds(1:jj-1)),.21,twLabels{jj}); end
- hl=legend({'E(L), LookL','E(L), LookR'}); ylim([0 0.2]); box(hl,'on');
- xlabel('time bins (10 ms)'); ylabel('% signif. cells');
- subplot(3,1,3);
- plotcmapdots([o2LLcol; o2LRcol]);
- runlength(nanmean(lmERpvdLL),squeeze(nanmean(lmERpvdLL_shf)),1,rtmax_ds,o2LLcol,0.005);
- runlength(nanmean(lmERpvdLR),squeeze(nanmean(lmERpvdLR_shf)),1,rtmax_ds,o2LRcol,0.002);
- for jj=1:8; plot([1 1].*sum(rtmes_ds(1:jj)),[0 0.2],'k:'); text(sum(rtmes_ds(1:jj-1)),.21,twLabels{jj}); end
- hl=legend({'E(R), LookL','E(R), LookR'}); ylim([0 0.2]); box(hl,'on');
- xlabel('time bins (10 ms)'); ylabel('% signif. cells');
- saveas(hfig,[most_recent_folder 'span' num2str(Nspan) 'ms_lag' num2str(Nlag) 'ms/sig_in_time_pv.png']);
- saveas(hfig,[most_recent_folder 'span' num2str(Nspan) 'ms_lag' num2str(Nlag) 'ms/sig_in_time_pv.fig']);
- saveas(hfig,[most_recent_folder 'span' num2str(Nspan) 'ms_lag' num2str(Nlag) 'ms/sig_in_time_pv.svg']);
- %%
- lmELpvd=double(lmELpv(:,:)<0.05);
- lmERpvd=double(lmERpv(:,:)<0.05);
- lmELpvdLL=double(lmELpvLL(:,:)<0.05);
- lmERpvdLL=double(lmERpvLL(:,:)<0.05);
- lmELpvdLR=double(lmELpvLR(:,:)<0.05);
- lmERpvdLR=double(lmERpvLR(:,:)<0.05);
- lmELpvd_shf=squeeze(double(lmELpv_shf(:,:,:)<0.05));
- lmERpvd_shf=squeeze(double(lmERpv_shf(:,:,:)<0.05));
- lmELpvdLL_shf=squeeze(double(lmELpvLL_shf(:,:,:)<0.05));
- lmERpvdLL_shf=squeeze(double(lmERpvLL_shf(:,:,:)<0.05));
- lmELpvdLR_shf=squeeze(double(lmELpvLR_shf(:,:,:)<0.05));
- lmERpvdLR_shf=squeeze(double(lmERpvLR_shf(:,:,:)<0.05));
- hfig=fullfig();
- subplot(3,1,1);
- plotcmapdots([o1col; o2col]);
- runlength(nanmean(lmELpvd),squeeze(nanmean(lmELpvd_shf)),1,1:Ntps_ds,o1col,0.005);
- runlength(nanmean(lmERpvd),squeeze(nanmean(lmERpvd_shf)),1,1:Ntps_ds,o2col,0.002);
- ylim([0 0.2]); for jj=1:7; plotvline(ntce_ds(jj,1:2)); text(ntce_ds(jj,1),max(get(gca,'YLim')),twLabels{jj}); end
- hl=legend({'E(L)','E(R)'}); box(hl,'on'); box off;
- if selflag<=2; xlim(fulldel1time([1 end])); else; xlim(fulldel2time([1 end])); end
- xlabel('time bins (10 ms)'); ylabel('% signif. cells');
- subplot(3,1,2);
- plotcmapdots([o1LLcol; o1LRcol]);
- runlength(nanmean(lmELpvdLL),squeeze(nanmean(lmELpvdLL_shf)),1,1:Ntps_ds,o1LLcol,0.005);
- runlength(nanmean(lmELpvdLR),squeeze(nanmean(lmELpvdLR_shf)),1,1:Ntps_ds,o1LRcol,0.002);
- ylim([0 0.2]); for jj=1:7; plotvline(ntce_ds(jj,1:2)); text(ntce_ds(jj,1),max(get(gca,'YLim')),twLabels{jj}); end
- hl=legend({'E(L), LookL','E(L), LookR'}); box(hl,'on'); box off;
- if selflag<=2; xlim(fulldel1time([1 end])); else; xlim(fulldel2time([1 end])); end
- xlabel('time bins (10 ms)'); ylabel('% signif. cells');
- subplot(3,1,3);
- plotcmapdots([o2LLcol; o2LRcol]);
- runlength(nanmean(lmERpvdLL),squeeze(nanmean(lmERpvdLL_shf)),1,1:Ntps_ds,o2LLcol,0.005);
- runlength(nanmean(lmERpvdLR),squeeze(nanmean(lmERpvdLR_shf)),1,1:Ntps_ds,o2LRcol,0.002);
- ylim([0 0.2]); for jj=1:7; plotvline(ntce_ds(jj,1:2)); text(ntce_ds(jj,1),max(get(gca,'YLim')),twLabels{jj}); end
- hl=legend({'E(R), LookL','E(R), LookR'}); box(hl,'on'); box off;
- if selflag<=2; xlim(fulldel1time([1 end])); else; xlim(fulldel2time([1 end])); end
- xlabel('time bins (10 ms)'); ylabel('% signif. cells');
- saveas(hfig,[most_recent_folder 'span' num2str(Nspan) 'ms_lag' num2str(Nlag) 'ms/sig_in_time_pv_deltime.png']);
- saveas(hfig,[most_recent_folder 'span' num2str(Nspan) 'ms_lag' num2str(Nlag) 'ms/sig_in_time_pv_deltime.fig']);
- saveas(hfig,[most_recent_folder 'span' num2str(Nspan) 'ms_lag' num2str(Nlag) 'ms/sig_in_time_pv_deltime.svg']);
- end
- end
|