plotRFsAlignedWithFitGenotypes.m 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. function varargout = plotRFsAlignedWithFitGenotypes(StimTableNeuronStim, rSqThresh, ...
  2. respIndThresh, figDir, nameSuffix, varargin)
  3. if nargin > 5
  4. alignAll = varargin{1};
  5. if nargin > 6
  6. cLims = varargin{2};
  7. else
  8. cLims = [];
  9. end
  10. if nargin > 7
  11. alignOrientation = varargin{3};
  12. else
  13. alignOrientation = true;
  14. end
  15. else
  16. alignAll = false;
  17. alignOrientation = true;
  18. cLims = [];
  19. end
  20. [offX, offY, onX, onY] = deal(cell(size(StimTableNeuronStim, 1), 1));
  21. for iNeuron = 1: size(StimTableNeuronStim, 1)
  22. StimTableCell = StimTableNeuronStim(iNeuron, :);
  23. [offX{iNeuron}, offY{iNeuron}, ...
  24. onX{iNeuron}, onY{iNeuron}] = getRFsAlignedWithFit(StimTableCell, ...
  25. rSqThresh, ...
  26. respIndThresh, ...
  27. alignAll, ...
  28. alignOrientation);
  29. end
  30. varargout{1} = [offX, offY, onX, onY];
  31. [offX{cellfun(@isempty, offX)}] = deal(zeros(1, size(offX{find(cellfun(@isempty, offX)==0, 1)}, 2)));
  32. [offY{cellfun(@isempty, offY)}] = deal(zeros(1, size(offY{find(cellfun(@isempty, offY)==0, 1)}, 2)));
  33. [onX{cellfun(@isempty, onX)}] = deal(zeros(1, size(onX{find(cellfun(@isempty, onX)==0, 1)}, 2)));
  34. [onY{cellfun(@isempty, onY)}] = deal(zeros(1, size(onY{find(cellfun(@isempty, onY)==0, 1)}, 2)));
  35. plotLasagnaRFs(offX, offY, 'OFF');
  36. plotLasagnaRFs(onX, onY, 'ON');
  37. function plotLasagnaRFs(xRFs, yRFs, polarityStr)
  38. %% Plot traces and average above colormap of single cell responses
  39. % Last subplot is a dummy to avoid resizing when colorbar is used.
  40. hFig = createPrintFig(15 * [ 1 2/3]);
  41. colors = brewermap(6, 'Paired');
  42. colors = repmat(lines(2), numel(xRFs) + 1, 1);
  43. % colors = brewermap(numel(xRFs), 'Set1');
  44. % colors = colors([1, 2, 4, 3, 1, 2, 4, 3, 1], :);
  45. hSubAx = plotLasagnaTracesFromCell(gcf, [xRFs(:)', yRFs(:)', xRFs(1)], colors);
  46. if ~isempty(cLims)
  47. arrayfun(@(x) caxis(x, cLims), hSubAx);
  48. end
  49. colorbar;
  50. linkaxes(hSubAx(:, 1), 'y');
  51. linkaxes(hSubAx(:, 2), 'y');
  52. hFig.Color = 'none';
  53. set(hSubAx, 'Color', 'none');
  54. setFontForThesis(hSubAx, hFig);
  55. arrayfun(@prettifyAxes, hSubAx);
  56. arrayfun(@offsetAxes, hSubAx);
  57. for iAx = 2: size(hSubAx, 1) - 1
  58. hSubAx(iAx, 1).YAxis.Visible = 'off';
  59. hSubAx(iAx, 2).YAxis.Visible = 'off';
  60. hSubAx(iAx, 1).XAxis.Visible = 'off';
  61. hSubAx(iAx, 2).XAxis.Visible = 'off';
  62. end
  63. figFileName = ['RFcurves-' polarityStr '-XY-lasagna-' nameSuffix];
  64. print(hFig, [figDir figFileName '.pdf'], '-dpdf');
  65. end
  66. end