function varargout = plotRFsAlignedWithFitGenotypes(StimTableNeuronStim, rSqThresh, ... respIndThresh, figDir, nameSuffix, varargin) if nargin > 5 alignAll = varargin{1}; if nargin > 6 cLims = varargin{2}; else cLims = []; end if nargin > 7 alignOrientation = varargin{3}; else alignOrientation = true; end else alignAll = false; alignOrientation = true; cLims = []; end [offX, offY, onX, onY] = deal(cell(size(StimTableNeuronStim, 1), 1)); for iNeuron = 1: size(StimTableNeuronStim, 1) StimTableCell = StimTableNeuronStim(iNeuron, :); [offX{iNeuron}, offY{iNeuron}, ... onX{iNeuron}, onY{iNeuron}] = getRFsAlignedWithFit(StimTableCell, ... rSqThresh, ... respIndThresh, ... alignAll, ... alignOrientation); end varargout{1} = [offX, offY, onX, onY]; [offX{cellfun(@isempty, offX)}] = deal(zeros(1, size(offX{find(cellfun(@isempty, offX)==0, 1)}, 2))); [offY{cellfun(@isempty, offY)}] = deal(zeros(1, size(offY{find(cellfun(@isempty, offY)==0, 1)}, 2))); [onX{cellfun(@isempty, onX)}] = deal(zeros(1, size(onX{find(cellfun(@isempty, onX)==0, 1)}, 2))); [onY{cellfun(@isempty, onY)}] = deal(zeros(1, size(onY{find(cellfun(@isempty, onY)==0, 1)}, 2))); plotLasagnaRFs(offX, offY, 'OFF'); plotLasagnaRFs(onX, onY, 'ON'); function plotLasagnaRFs(xRFs, yRFs, polarityStr) %% Plot traces and average above colormap of single cell responses % Last subplot is a dummy to avoid resizing when colorbar is used. hFig = createPrintFig(15 * [ 1 2/3]); colors = brewermap(6, 'Paired'); colors = repmat(lines(2), numel(xRFs) + 1, 1); % colors = brewermap(numel(xRFs), 'Set1'); % colors = colors([1, 2, 4, 3, 1, 2, 4, 3, 1], :); hSubAx = plotLasagnaTracesFromCell(gcf, [xRFs(:)', yRFs(:)', xRFs(1)], colors); if ~isempty(cLims) arrayfun(@(x) caxis(x, cLims), hSubAx); end colorbar; linkaxes(hSubAx(:, 1), 'y'); linkaxes(hSubAx(:, 2), 'y'); hFig.Color = 'none'; set(hSubAx, 'Color', 'none'); setFontForThesis(hSubAx, hFig); arrayfun(@prettifyAxes, hSubAx); arrayfun(@offsetAxes, hSubAx); for iAx = 2: size(hSubAx, 1) - 1 hSubAx(iAx, 1).YAxis.Visible = 'off'; hSubAx(iAx, 2).YAxis.Visible = 'off'; hSubAx(iAx, 1).XAxis.Visible = 'off'; hSubAx(iAx, 2).XAxis.Visible = 'off'; end figFileName = ['RFcurves-' polarityStr '-XY-lasagna-' nameSuffix]; print(hFig, [figDir figFileName '.pdf'], '-dpdf'); end end