Fig_6.m~ 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. % f1=figure;
  2. mypath='/mnt/Vol2/kropff/analyisis/figs/theta_new/fig2abc-openfield theta/clean_test/';
  3. files=dir([mypath 'peak_matr_final_f2_*.db']);
  4. close all;
  5. for ifile=14%1:numel(files) % 14 10
  6. p=load([mypath files(ifile).name],'-mat');%3 6 8
  7. data=p.out.data{1};
  8. %%
  9. % close all;
  10. f=figure;
  11. subplot(2,1,1)
  12. sel=1:numel(data.v);
  13. speeds=data.v(sel)';
  14. accs=[0 speeds(3:end)-speeds(1:end-2) 0]/.04;
  15. % ths=smooth_theta(accs,0.1); %0.06
  16. ths=smooth_theta2(accs,1-exp(-.1)); %0.06
  17. raccs=accs;
  18. raccs(raccs<0)=0;
  19. plot(sel/50,(speeds)/std(speeds),'r');
  20. hold on;
  21. plot(sel/50,accs/std(accs),'b');
  22. plot(sel/50,ths/std(accs),'g');
  23. xlim([0 10])
  24. %
  25. % sel2=true(size(speeds));
  26. ths=8+ths/100;
  27. da=20; abins=-5:5;
  28. dv=5; vbins=0:12;
  29. rv=round(speeds/dv);
  30. ra=round(accs/da);
  31. vfr=arrayfun(@(x) mean(ths(rv==x)),vbins);
  32. afr=arrayfun(@(x) mean(ths(ra==x)),abins);
  33. m8=vfr(1);%mean(ths);
  34. [th_f5,th_s5]=mybp(ths-m8,0.5);
  35. [th_f1,th_s1]=mybp(ths-m8,0.1);
  36. [th_f3,th_s3]=mybp(ths-m8,0.3);
  37. vfr_f=arrayfun(@(x) mean(th_f5(rv==x))+m8,vbins);
  38. vfr_s=arrayfun(@(x) mean(th_s5(rv==x))+m8,vbins);
  39. afr_f=arrayfun(@(x) mean(th_f1(ra==x))+m8,abins);
  40. afr_s=arrayfun(@(x) mean(th_s1(ra==x))+m8,abins);
  41. subplot(2,2,3)
  42. plot(vbins*dv,[vfr; vfr_s; vfr_f]');
  43. axis([0 50 7.8 9.1])
  44. golden(2.5)
  45. subplot(2,2,4)
  46. plot(abins*da,[afr; afr_s; afr_f]');
  47. axis([-120 140 7.8 9.1])
  48. set(gca,'YTick',6:.5:12);
  49. [corr(speeds',ths') corr(accs',ths');
  50. corr(speeds',th_f5') corr(accs',th_f1');
  51. corr(speeds',th_s5') corr(accs',th_s1')]
  52. drawnow;
  53. end
  54. function [th_f,th_s]=mybp(ths,f1)
  55. th_f=real(bandpass_and_hilbert(ths',f1,100,50)');
  56. th_f=abs(th_f).*cos(angle(th_f));
  57. th_s=bandpass_and_hilbert(ths',0,f1,50)';
  58. th_s=abs(th_s).*cos(angle(th_s));
  59. end