123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- load('data_fig_2.db','-mat');
- res={};
- bins=(1:300)*.002;
- res.allcells.positive=0*bins;
- res.allcells.negative=0*bins;
- res.allcells.shuff=zeros(1000,numel(bins));
- typ='allcells';
- delta_r=5.0666667;
- delta_l=30.4;
- if 1
- for i=1:numel(alldata.ts)
-
-
- data=alldata.pos{i};
- ts=alldata.ts{i};
-
- %%
- nlaps=min(numel(data.log.end_r),numel(data.log.end_l));
-
- right=(data.log.start_r(1:nlaps)+delta_r)';
- left=(data.log.start_l(1:nlaps)+delta_l)';
- dwin=.5;
- %% speed
- selfast=is_inside(ts',data.log.start_r'+1,data.log.start_r'+4) | is_inside(ts',data.log.start_l'+31.5,data.log.start_l'+34.5);
- selslow=is_inside(ts',data.log.start_l'+5,data.log.start_l'+25) | is_inside(ts',data.log.start_r'+8,data.log.start_r'+28);
- res.(typ).fast(i,:)=hist(autoc2(ts(selfast)),bins)/6;
- res.(typ).slow(i,:)=hist(autoc2(ts(selslow)),bins)/40;
-
- %% acceleration
- res.(typ).negative=res.(typ).negative + hist(autoc2(ts(is_inside(ts',right,right+dwin))),bins);
- res.(typ).positive=res.(typ).positive + hist(autoc2(ts(is_inside(ts',left,left+dwin))),bins);
-
- for j=1:1000
- shuff_fast=data.log.start_r'+1+3*rand(1,nlaps);
- shuff_slow=data.log.start_l'+5+20*rand(1,nlaps);
- shuff=[shuff_fast shuff_slow];
- shuff=shuff(randperm(numel(shuff),numel(shuff)/2));
- res.(typ).shuff(j,:)=res.(typ).shuff(j,:)+hist(autoc2(ts(is_inside(ts',shuff,shuff+dwin))),bins);
- end
-
- end
- save('partial_res.db','res','-mat');
- end
- %%
- %%
- close all
- bins=(1:150)*.004;
- %%
- sel=bins>0.01 & bins<0.3;
- types={'allcells'};
- nshuf=1000;
- sname='shuff_speed.mat';
- if 0%exist(sname,'file')
- load(sname,'-mat')
- else
- sh_f1={};sh_f2={};
- for ty=1:numel(types)
- typ=types{ty};
- sh_f1.(typ)=zeros(1,nshuf);
- sh_f2.(typ)=zeros(1,nshuf);
- % aux_all=[.5*(res.(typ).fast(:,1:2:end)+res.(typ).fast(:,2:2:end)); .5*(res.(typ).slow(:,1:2:end)+res.(typ).slow(:,2:2:end)); ]
- for j=1:nshuf
- if mod(j,100)==0
- disp(j);
- end
- sel=rand(1,size(res.(typ).fast,1))>.5;
-
- aux1=mean([reshape(res.(typ).fast(sel,:),[],150); reshape(res.(typ).slow(~sel,:),[],150)]);
- aux2=mean([reshape(res.(typ).fast(~sel,:),[],150); reshape(res.(typ).slow(sel,:),[],150)]);
- aux1(end)=0;
- aux2(end)=0;
- aux1=aux1/max(aux1);
- aux2=aux2/max(aux2);
- c1=do_fit(bins,aux1);
- c2=do_fit(bins,aux2);
-
- sh_f1.(typ)(j)=c1.f;
- sh_f2.(typ)(j)=c2.f;
-
- end
- end
- save(sname,'sh_f1','sh_f2','-mat');
- end
- %% speed
- for ty=numel(types)
- typ=types{ty};
- f=figure;
- hold on;
- aux=mean(reshape(res.(typ).fast,[],150))/8;
- aux(end)=0;
- mxaux=max(aux);
- aux=aux/max(aux);
- ffast=do_plot(bins,aux,[0 1 0],[.5 1 .5]);
- auxs=mean(reshape(res.(typ).slow,[],150))/40;
- auxs(end)=0;
- mxauxs=max(auxs);
- auxs=auxs/max(auxs);
- fslow=do_plot2(bins,auxs,[1 0 0],[1 .5*[1 1]]);
- subplot(2,2,1)
- axis([0 .3 0.3 1.2]);
- gl=1.5;
- %golden(gl);
- set(gca,'YTick',0:.5:2,'FontName','Arial');
- subplot(2,2,2)
- axis([0 .3 .15*[-1 1] ]);
- %golden(gl);
- set(gca,'YTick',-.6:.1:.6,'FontName','Arial');
- subplot(2,2,3)
- fbins=7.5:.01:8.5;
- h=hist([sh_f1.(typ) sh_f2.(typ)],fbins);
- b=bar(fbins,h,'LineStyle','none','FaceColor',.5*[1 2 1],'BarWidth',1.0);
- mx=ceil(2*max(h));
- hold on;
- legend off;
- line((fslow)*[1 1],[0 mx],'LineWidth',2,'Color',[1 1 1]*.5);
- line(ffast*[1 1],[0 mx],'LineWidth',2,'Color',[1 .5 .5]);
- axis([7.6 8.0 0 380]);
- axis([7.5 9.5 0 380]);
- set(gca,'YTick',0:100:300)
- subplot(224)
- fbins=7.5:.01:8.5;
- h=hist([sh_f1.(typ) sh_f2.(typ)],fbins);
- b=bar(fbins,h,'LineStyle','none','FaceColor',.5*[1 2 1],'BarWidth',1.0);
- mx=ceil(2*max(h));
- hold on;
- legend off;
- line((fslow)*[1 1],[0 mx],'LineWidth',2,'Color',[1 1 1]*.5);
- line(ffast*[1 1],[0 mx],'LineWidth',2,'Color',[1 .5 .5]);
- axis([7.6 8.0 0 300]);
- set(gca,'YTick',0:100:300)
- end
- %% Acceleration
- gs=0;
- for ty=numel(types)
- typ=types{ty};
- % f=figure;
- % plot(bins,gauss_boxcar(sum(res.(typ).right.pre,1),gs),'Color',[1 .5 .5]);
- hold on;
- aux=gauss_boxcar(mean(reshape(res.(typ).right,2,150)),gs);
- aux=aux/max(aux);
- fm=myplot33(bins,aux,[0 0 0],.5*[1 1 1]);
- % plot(bins,gauss_boxcar(sum(res.(typ).left.pre,1),gs),'Color',.5*[1 1 1]);
- %%
-
- % plot(bins,aux/max(aux),'Color',[1 0 0]);
- aux=gauss_boxcar(mean(reshape(res.(typ).control(1,:),2,150)),gs);
- aux=aux/max(aux);
- fc=myplot3(bins,aux,[0 1 0],[.5 1 .5]);
- % plot(bins,aux/max(aux),'Color',[0 1 0]);
- aux=gauss_boxcar(mean(reshape(res.(typ).left,2,150)),gs);
- aux=aux/max(aux);
- fp=myplot3(bins,aux,[1 0 0],[1 .5*[1 1]]);
- end
- subplot(2,2,1)
- axis([0 .3 0.3 1.2]);
- gl=1.5;
- golden(gl);
- set(gca,'YTick',0:.5:2,'FontName','Arial');
- subplot(2,2,2)
- axis([0 .3 .15*[-1 1] ]);
- golden(gl);
- set(gca,'YTick',-.6:.1:.6,'FontName','Arial');
|