plotLasagnaTracesFromCell.m 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. function hSubAx = plotLasagnaTracesFromCell(hFig, allNeuronsOnOffTraces, colors, varargin)
  2. timePoints = (0: size(allNeuronsOnOffTraces{1}, 2)-1) /10;
  3. if ~isempty(varargin)
  4. timePoints = varargin{1};
  5. end
  6. cLims = ZeroCenteredBounds(cat(1, allNeuronsOnOffTraces{:}), [0 100]);
  7. figure(hFig)
  8. nNeurons = numel(allNeuronsOnOffTraces);
  9. for iNeuron = 1: nNeurons
  10. hSubAx(iNeuron, 1) = subplot(3, nNeurons + 1, iNeuron);
  11. hSubAx(iNeuron, 2) = subplot(3, nNeurons + 1, iNeuron + (nNeurons + 1) * (1:2));
  12. axes(hSubAx(iNeuron, 1))
  13. hold on;
  14. plot(timePoints, allNeuronsOnOffTraces{iNeuron}', 'Color', [colors(iNeuron, :) 0.3], 'LineWidth', 1);
  15. plot(timePoints, mean(allNeuronsOnOffTraces{iNeuron}), 'Color', [colors(iNeuron, :)], 'LineWidth', 3);
  16. % shadedErrorBar(timePoints, allNeuronsOnOffTraces{iNeuron}, {@mean @(x) std(x) / sqrt(size(x, 1))}, {'Color', [colors(iNeuron, :) 0.3], 'LineWidth', 3});
  17. axis tight
  18. if iNeuron > 1
  19. hSubAx(iNeuron, 1).YAxis.Visible = 'off';
  20. end
  21. hSubAx(iNeuron, 1).XAxis.Visible = 'off';
  22. hSubAx(iNeuron, 1).Position(2) = sum(hSubAx(iNeuron, 2).Position([2, 4]));
  23. axes(hSubAx(iNeuron, 2))
  24. % cLims = ZeroCenteredBounds(cat(1, allNeuronsOnOffTraces{:}), [0 100]);
  25. imagesc(timePoints, [], allNeuronsOnOffTraces{iNeuron}, cLims);
  26. setFavoriteColormap;
  27. imAxisRatio = hSubAx(iNeuron, 2).PlotBoxAspectRatio(1) / hSubAx(iNeuron, 2).PlotBoxAspectRatio(2);
  28. xAxisRatio = imAxisRatio * hSubAx(iNeuron, 2).Position(4) / hSubAx(iNeuron, 1).Position(4);
  29. % hSubAx(iNeuron, 1).PlotBoxAspectRatio = [xAxisRatio, 1, 1];
  30. pos1 = hSubAx(iNeuron, 1).Position;
  31. pos2 = hSubAx(iNeuron, 2).Position;
  32. pos1(3) = pos2(3);
  33. set(hSubAx(iNeuron, 1), 'Position', pos1);
  34. hSubAx(iNeuron, 1).Position(3) = hSubAx(iNeuron, 2).Position(3);
  35. end
  36. end