12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004 |
- 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 saccade
- %caseflag=2; % perform analysis saccade-aligned ignoring gaze after saccade
- %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%[1 4]
- for caseflag=2%4:6
- close all
- 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_off1LR_' 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(2,1)-40):ntce_ds(2,2))';
- %selectedCases{1}='find((cciso1LL) & (ccepx(:,tt)<0))';
- %selectedCases{2}='find((cciso1LL) & (ccepx(:,tt)>0))';
- %case 2 % DEPRECATED
- %most_recent_folder='../../Figures/';
- %selectedTimes='(ntce_ds(2,1)-40:ntce_ds(2,2))';
- %selectedCases{1}='find((~cciso1LL) & (ccepx(:,tt)<0))';
- %selectedCases{2}='find((~cciso1LL) & (ccepx(:,tt)>0))';
- %case 3 % DEPRECATED
- %most_recent_folder='../../Figures/';
- %selectedTimes='(ntce_ds(4,1)-40:ntce_ds(4,2))';
- %selectedCases{1}='find((cciso2LL) & (ccepx(:,tt)<0))';
- %selectedCases{2}='find((cciso2LL) & (ccepx(:,tt)>0))';
- case 4
- most_recent_folder=['../../Figures/evLevR_off2LR_' 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(4,1)-40):ntce_ds(4,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>=.8); fchl_ds=find(poolcovhist_ds<.8);
- 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)];
- %fulloff1time=[(ntce_ds(2,1)-46):(ntce_ds(2,1)-7) ntce_ds(2,1):ntce_ds(2,2)];
- fulloff1time=[(ntce_ds(2,1)-40):ntce_ds(2,2)];
- fulloff1time=fulloff1time(fulloff1time>0); % ensure it is not negative
- %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];
- fulloff2time=[(ntce_ds(4,1)-46):(ntce_ds(4,1)-7) ntce_ds(4,1):ntce_ds(4,2)];
- %fulloff2time=[(ntce_ds(4,1)-40):ntce_ds(4,2)];
- 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,fulloff1time));
- ccspk=squeeze(poolspksqmat_ds_bln(:,cc,fulloff1time));
- [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);
- for jj=1:length(ind_delSR)
- shRbins=(ishiftsR(ind_delSR(jj)):length(fulloff1time));
- pooleposxmat_shRalgn(ind_delSR(jj),cc,fulloff1time)=[ccepx(ind_delSR(jj),shRbins) nan(1,length(fulloff1time)-sum(shRbins<=length(fulloff1time)))];
- poolspksqmat_shRalgn(ind_delSR(jj),cc,fulloff1time)=[ccspk(ind_delSR(jj),shRbins) nan(1,length(fulloff1time)-sum(shRbins<=length(fulloff1time)))];
- pooleposxmat_shRonly(ind_delSR(jj),cc,fulloff1time(1)-1+shRbins)=ccepx(ind_delSR(jj),shRbins);
- poolspksqmat_shRonly(ind_delSR(jj),cc,fulloff1time(1)-1+shRbins)=ccepx(ind_delSR(jj),shRbins);
- end
- %figure(); plot(1:76,squeeze(pooleposxmat_shRalgn(:,1,fulloff1time)))
- %%
- [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);
- for jj=1:length(ind_delSL)
- shLbins=(ishiftsL(ind_delSL(jj)):length(fulloff1time));
- pooleposxmat_shLalgn(ind_delSL(jj),cc,fulloff1time)=[ccepx(ind_delSL(jj),shLbins) nan(1,length(fulloff1time)-sum(shLbins<=length(fulloff1time)))];
- poolspksqmat_shLalgn(ind_delSL(jj),cc,fulloff1time)=[ccspk(ind_delSL(jj),shLbins) nan(1,length(fulloff1time)-sum(shLbins<=length(fulloff1time)))];
- pooleposxmat_shLonly(ind_delSL(jj),cc,fulloff1time(1)-1+shLbins)=ccepx(ind_delSL(jj),shLbins);
- poolspksqmat_shLonly(ind_delSL(jj),cc,fulloff1time(1)-1+shLbins)=ccepx(ind_delSL(jj),shLbins);
- end
- %figure(); plot(1:76,squeeze(pooleposxmat_shLalgn(:,1,fulloff1time)))
- 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,fulloff2time));
- ccspk=squeeze(poolspksqmat_ds_bln(:,cc,fulloff2time));
- [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);
- for jj=1:length(ind_delSR)
- shRbins=(ishiftsR(ind_delSR(jj)):length(fulloff2time));
- pooleposxmat_shRalgn(ind_delSR(jj),cc,fulloff2time)=[ccepx(ind_delSR(jj),shRbins) nan(1,length(fulloff2time)-sum(shRbins<=length(fulloff2time)))];
- poolspksqmat_shRalgn(ind_delSR(jj),cc,fulloff2time)=[ccspk(ind_delSR(jj),shRbins) nan(1,length(fulloff2time)-sum(shRbins<=length(fulloff2time)))];
- pooleposxmat_shRonly(ind_delSR(jj),cc,fulloff2time(1)-1+shRbins)=ccepx(ind_delSR(jj),shRbins);
- poolspksqmat_shRonly(ind_delSR(jj),cc,fulloff2time(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);
- for jj=1:length(ind_delSL)
- shLbins=(ishiftsL(ind_delSL(jj)):length(fulloff2time));
- pooleposxmat_shLalgn(ind_delSL(jj),cc,fulloff2time)=[ccepx(ind_delSL(jj),shLbins) nan(1,length(fulloff2time)-sum(shLbins<=length(fulloff2time)))];
- poolspksqmat_shLalgn(ind_delSL(jj),cc,fulloff2time)=[ccspk(ind_delSL(jj),shLbins) nan(1,length(fulloff2time)-sum(shLbins<=length(fulloff2time)))];
- pooleposxmat_shLonly(ind_delSL(jj),cc,fulloff2time(1)-1+shLbins)=ccepx(ind_delSL(jj),shLbins);
- poolspksqmat_shLonly(ind_delSL(jj),cc,fulloff2time(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
- %% EXTRA CHECKS: plotting percentiles of eye tracks
- 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 offer1 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 offer1 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(fulloff1time,nanmedian(squeeze(pooleposxmat_L(:,1,fulloff1time))),'k');
- plot(fulloff1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),99), fulloff1time),'color',[1 1 1].*.85);
- plot(fulloff1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),01), fulloff1time),'color',[1 1 1].*.85);
- plot(fulloff1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),95), fulloff1time),'color',[1 1 1].*.60);
- plot(fulloff1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),05), fulloff1time),'color',[1 1 1].*.60);
- plot(fulloff1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),90), fulloff1time),'color',[1 1 1].*.45);
- plot(fulloff1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),10), fulloff1time),'color',[1 1 1].*.45);
- plot(fulloff1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),75), fulloff1time),'color',[1 1 1].*.25);
- plot(fulloff1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),25), fulloff1time),'color',[1 1 1].*.25);
- plot(fulloff1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),65), fulloff1time),'color',[0 0 1].*.1);
- plot(fulloff1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),35), fulloff1time),'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(fulloff1time,nanmedian(squeeze(pooleposxmat_R(:,1,fulloff1time))),'k');
- plot(fulloff1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),99), fulloff1time),'color',[1 1 1].*.85);
- plot(fulloff1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),01), fulloff1time),'color',[1 1 1].*.85);
- plot(fulloff1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),95), fulloff1time),'color',[1 1 1].*.60);
- plot(fulloff1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),05), fulloff1time),'color',[1 1 1].*.60);
- plot(fulloff1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),90), fulloff1time),'color',[1 1 1].*.45);
- plot(fulloff1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),10), fulloff1time),'color',[1 1 1].*.45);
- plot(fulloff1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),75), fulloff1time),'color',[1 1 1].*.25);
- plot(fulloff1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),25), fulloff1time),'color',[1 1 1].*.25);
- plot(fulloff1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),65), fulloff1time),'color',[0 0 1].*.1);
- plot(fulloff1time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),35), fulloff1time),'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(fulloff2time,nanmedian(squeeze(pooleposxmat_L(:,1,fulloff2time))),'k');
- plot(fulloff2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),99), fulloff2time),'color',[1 1 1].*.85);
- plot(fulloff2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),01), fulloff2time),'color',[1 1 1].*.85);
- plot(fulloff2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),95), fulloff2time),'color',[1 1 1].*.60);
- plot(fulloff2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),05), fulloff2time),'color',[1 1 1].*.60);
- plot(fulloff2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),90), fulloff2time),'color',[1 1 1].*.45);
- plot(fulloff2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),10), fulloff2time),'color',[1 1 1].*.45);
- plot(fulloff2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),75), fulloff2time),'color',[1 1 1].*.25);
- plot(fulloff2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),25), fulloff2time),'color',[1 1 1].*.25);
- plot(fulloff2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),65), fulloff2time),'color',[0 0 1].*.1);
- plot(fulloff2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_L(:,1,xx))),35), fulloff2time),'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(fulloff2time,nanmedian(squeeze(pooleposxmat_R(:,1,fulloff2time))),'k');
- plot(fulloff2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),99), fulloff2time),'color',[1 1 1].*.85);
- plot(fulloff2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),01), fulloff2time),'color',[1 1 1].*.85);
- plot(fulloff2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),95), fulloff2time),'color',[1 1 1].*.60);
- plot(fulloff2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),05), fulloff2time),'color',[1 1 1].*.60);
- plot(fulloff2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),90), fulloff2time),'color',[1 1 1].*.45);
- plot(fulloff2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),10), fulloff2time),'color',[1 1 1].*.45);
- plot(fulloff2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),75), fulloff2time),'color',[1 1 1].*.25);
- plot(fulloff2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),25), fulloff2time),'color',[1 1 1].*.25);
- plot(fulloff2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),65), fulloff2time),'color',[0 0 1].*.1);
- plot(fulloff2time,arrayfun(@(xx) prctile(rmnans(squeeze(pooleposxmat_R(:,1,xx))),35), fulloff2time),'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
- %% Regress EV vs Spiking
- 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(:,fulloff1time),2,0,-1,1,1);
- %check1=find(~isnan(ishiftsL));
- %check0=find((ccisdelSL));
-
-
- % ccisd1allLL=(arrayfun(@(xx) all((ccepx(xx,fulloff1time(1)-1+find(~isnan(ccepx(xx,fulloff1time)))))<=0),1:size(ccepx,1)));
- % ccisd1allLR=(arrayfun(@(xx) all((ccepx(xx,fulloff1time(1)-1+find(~isnan(ccepx(xx,fulloff1time)))))>=0),1:size(ccepx,1)));
-
- ccisd1allLL=(arrayfun(@(xx) all((ccepx(xx,fulloff1time(41)-1+find(~isnan(ccepx(xx,fulloff1time(41:end))))))<=0),1:size(ccepx,1)));
- ccisd1allLR=(arrayfun(@(xx) all((ccepx(xx,fulloff1time(41)-1+find(~isnan(ccepx(xx,fulloff1time(41:end))))))>=0),1:size(ccepx,1)));
-
- %fullfig(); subplot(1,2,1); plot(fulloff1time,ccepx(ccisd1allLL,fulloff1time));
- % subplot(1,2,2); plot(fulloff1time,ccepx(ccisd1allLR,fulloff1time));
-
- % ccisd2allLL=(arrayfun(@(xx) all((ccepx(xx,fulloff2time(1)-1+find(~isnan(ccepx(xx,fulloff2time)))))<=0),1:size(ccepx,1)));
- % ccisd2allLR=(arrayfun(@(xx) all((ccepx(xx,fulloff2time(1)-1+find(~isnan(ccepx(xx,fulloff2time)))))>=0),1:size(ccepx,1)));
- ccisd2allLL=(arrayfun(@(xx) all((ccepx(xx,fulloff2time(41)-1+find(~isnan(ccepx(xx,fulloff2time(41:end))))))<=0),1:size(ccepx,1)));
- ccisd2allLR=(arrayfun(@(xx) all((ccepx(xx,fulloff2time(41)-1+find(~isnan(ccepx(xx,fulloff2time(41:end))))))>=0),1:size(ccepx,1)));
- %fullfig(); subplot(1,2,1); plot(fulloff2time,ccepx(ccisd2allLL,fulloff2time));
- % subplot(1,2,2); plot(fulloff2time,ccepx(ccisd2allLR,fulloff2time));
-
- 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
- %isLL=find((~cciso1LL) & (ccepx(:,tt)<0));
- %isLL=find((cciso1LL) & (ccepx(:,tt)<0));
- %isLL=eval(selectedCases{1});
- %isLL=find((~cciso2LL) & (ccepx(:,tt)<0));
- %isLL=find((cciso2LL) & (ccepx(:,tt)<0));
- %isLL=find(cciso1LL & ccisd1LL & cciso2LL & (ccepx(:,tt)<0));
- %isLL=find((~cciso1LL) & (~ccisd1LL) & (~cciso2LL) & (ccepx(:,tt)<0));
- 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
- % ctlm1LL=fitglm(ccoff1ev(isLL),ctspk(isLL),'linear','Distribution','poisson');
- % ctlm2LL=fitglm(ccoff2ev(isLL),ctspk(isLL),'linear','Distribution','poisson');
- 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)));
-
- %isLR=find((~cciso1LL) & (ccepx(:,tt)>0));
- %isLR=find((cciso1LL) & (ccepx(:,tt)>0));
- %isLR=eval(selectedCases{2});
- %isLR=find((~cciso2LL) & (ccepx(:,tt)>0));
- %isLR=find((cciso2LL) & (ccepx(:,tt)>0));
- %isLR=find(cciso1LL & ccisd1LL & cciso2LL & (ccepx(:,tt)>0));
- %isLR=find((~cciso1LL) & (~ccisd1LL) & (~cciso2LL) & (ccepx(:,tt)>0));
- 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
- % ctlm1LR=fitglm(ccoff1ev(isLR),ctspk(isLR),'linear','Distribution','poisson');
- % ctlm2LR=fitglm(ccoff2ev(isLR),ctspk(isLR),'linear','Distribution','poisson');
- 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
- % ctlm1_shf=fitglm(ccoff1ev(i1shf),ctspk(isshf),'linear','Distribution','poisson');
- % ctlm2_shf=fitglm(ccoff2ev(i2shf),ctspk(isshf),'linear','Distribution','poisson');
- %ctlm1_shf=fitlm(ccoff1ev,squeeze(ccspk_shf(shf,:,tt))); %time-shuffle
- %ctlm2_shf=fitlm(ccoff2ev,squeeze(ccspk_shf(shf,:,tt))); %time-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
- % ctlm1LL_shf=fitglm(ccoff1ev(i1LLshf),ctspk(isLLshf),'linear','Distribution','poisson');
- % ctlm2LL_shf=fitglm(ccoff2ev(i2LLshf),ctspk(isLLshf),'linear','Distribution','poisson');
- %ctlm1LL_shf=fitlm(ccoff1ev(isLL),squeeze(ccspk_shf(shf,isLL,tt))); %time-shuffle
- %ctlm2LL_shf=fitlm(ccoff2ev(isLL),squeeze(ccspk_shf(shf,isLL,tt))); %time-shuffle
- 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
- % ctlm1LR_shf=fitglm(ccoff1ev(i1LRshf),ctspk(isLRshf),'linear','Distribution','poisson');
- % ctlm2LR_shf=fitglm(ccoff2ev(i2LRshf),ctspk(isLRshf),'linear','Distribution','poisson');
- %ctlm1LR_shf=fitlm(ccoff1ev(isLR),squeeze(ccspk_shf(shf,isLR,tt))); %time-shuffle
- %ctlm2LR_shf=fitlm(ccoff2ev(isLR),squeeze(ccspk_shf(shf,isLR,tt))); %time-shuffle
- 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']);
- %load(['fitlmstats_span_' num2str(Nspan) 'ms_lag_' num2str(Nlag) 'ms_26-May-2022-BEST.mat']);
- %load('fitlmstats_span_100ms_lag_10ms_21-May-2022.mat');
- %load('fitlmstats_span_250ms_lag_10ms_01-Jul-2022.mat');
- %load('fitlmstats_span_150ms_lag_10ms_02-Jul-2022.mat');
- %load('fitlmstats_span_200ms_lag_10ms_24-Jun-2022_TIMESHUFF.mat');
- %load('fitlmstats_span_200ms_lag_10ms_13-Jul-2022.mat');
- %load(['fitlmstats_span_' num2str(Nspan) 'ms_lag_' num2str(Nlag) 'ms_06-Sep-2022.mat']);
- end
- %%
- %fullfig();
- %subplot(2,1,1);
- %plot(rtmax_ds,rmnans((lmntrsLL(:,vtps_ds==1)./(lmntrsLL(:,vtps_ds==1)+lmntrsLR(:,vtps_ds==1)))',1));
- %title('Look Left fraction of trials');
- %subplot(2,1,2);
- %plot(rtmax_ds,rmnans((lmntrsLR(:,vtps_ds==1)./(lmntrsLL(:,vtps_ds==1)+lmntrsLR(:,vtps_ds==1)))',1));
- %title('Look Right fraction of trials');
- %%
- %%
- 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']);
- %%
- %cmp=linspecer(14);
- %o1col=cmp(1,:); o2col=cmp(2,:); o1LLcol=cmp(9,:); o1LRcol=cmp(11,:); o2LLcol=cmp(10,:); o2LRcol=cmp(12,:);
- %% 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(fulloff1time([1 end])); else; xlim(fulloff2time([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(fulloff1time([1 end])); else; xlim(fulloff2time([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(fulloff1time([1 end])); else; xlim(fulloff2time([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
|