PlotSortedSeqDecoding.m 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. function PlotSortedSeqDecoding( tcs, deconv, behavior, varargin )
  2. % default parameters
  3. n_smooth = 3;
  4. n_lowpass = 0.1;
  5. ts_beh_int = 0:0.02:behavior.ts(end);
  6. spd_int = interp1(behavior.ts, behavior.speed, ts_beh_int, 'linear');
  7. order_idx = 1:size(tcs.ratio,2);
  8. unit_list = 1:size(tcs.ratio, 2);
  9. % parse input parameters
  10. % Parse parameter list
  11. for i = 1:2:length(varargin),
  12. if ~ischar(varargin{i}),
  13. error(['Parameter ' num2str(i+2) ' is not a property']);
  14. end
  15. switch(lower(varargin{i}))
  16. case 'sort_order',
  17. o = varargin{i+1};
  18. if ~isvector(o),
  19. error('Incorrect value for property ''sort_order''');
  20. end
  21. case 'unit_list'
  22. unit_list = varargin{i+1};
  23. if ~isvector(unit_list),
  24. error('Incorrect value for property ''unit_list''');
  25. end
  26. case 'order_idx'
  27. order_idx = varargin{i+1};
  28. if ~isvector(order_idx),
  29. error('Incorrect value for property ''order_idx''');
  30. end
  31. otherwise,
  32. error(['Unknown property ''' num2str(varargin{i}) '''']);
  33. end
  34. end
  35. % ratio_lp = lowpass(tcs.ratio(:,:), n_lowpass);
  36. ratio_lp = lowpass(double(tcs.ratio(:,unit_list)), n_lowpass);
  37. figure;
  38. ax1 = subplot(7,1,1:5);
  39. zz = (ratio_lp(:,order_idx))';
  40. % zz = (Smooth(deconv(:,order_idx),[3 0]))';
  41. imagesc(tcs.tt, 1:length(order_idx), zz, [-80 80]);
  42. % imagesc(tcs.tt, 1:length(order_idx), zz, [-2 2]);
  43. colormap bluered
  44. set(gca, 'box', 'on', 'YDir', 'normal', 'xtick', []);
  45. set(gca, 'YTick', [1 length(order_idx)])
  46. ylabel('Neuron no.(sorted)')
  47. % colormap bluered
  48. ax2 = subplot(7,1,6);
  49. plot(ts_beh_int, Smooth(spd_int, n_smooth), 'k', 'LineWidth', 2)
  50. set(gca, 'box', 'off', 'YDir', 'normal', 'xtick', [])
  51. ylabel('Speed (cm/s)')
  52. ax3 = subplot(7,1,7);
  53. for iTrial = 1:max(behavior.trial)
  54. ok = behavior.trial == iTrial;
  55. plot(behavior.ts(ok), behavior.pos_norm(ok), 'k', 'LineWidth', 2);
  56. hold on
  57. end
  58. ylabel('Position (cm)')
  59. linkaxes([ax1, ax2, ax3], 'x');
  60. end