function plotBootstrapCoeffOfVariationTest(widthCell, figDir, threshold, rSquareThreshold, varargin) if nargin > 4 xLabels = varargin{1}; nameSuffix = varargin{2}; else xLabels = {'X OFF', 'Y OFF', 'X ON', 'Y ON'}; nameSuffix = ''; end qualityMeasure = 'responseQuality'; [isSignificant, cvArray, ~, ... centralDecisionLineCV, ldlCV, udlCV] = bootstrapCoeffOfVariation(widthCell); error = (udlCV - ldlCV) / 2; colors = getONOFFXYColors; if numel(widthCell) > 4 colors = repmat(colors, ceil(numel(widthCell) / 4), 1); end % Fill space. hFig = createPrintFig(5 * [1 0.7]); dummyVec = ones(1, numel(widthCell) + 2); hAx = gca; [hLine, hPatch] = plotErrorPatch(hAx, 0: numel(widthCell) + 1, ... centralDecisionLineCV * dummyVec, ... error * dummyVec, ... [1 1 1] * 0.2, [1 1 1] * 0.85); hLine.LineWidth = 2; hPatch.FaceAlpha = 1; for iGroup = 1: numel(widthCell) scatter(iGroup, cvArray(iGroup), 50, colors(iGroup, :), ... 'MarkerFaceColor', colors(iGroup, :), ... 'MarkerFaceAlpha', isSignificant(iGroup), ... 'LineWidth', 2); end ylabel('$$CV=\frac{s}{\bar{x}}$$', 'Interpreter', 'latex', 'Rotation', 90) hAx.XTick = 1: numel(widthCell); hAx.XTickLabel = xLabels; arrayfun(@prettifyAxes, [hAx]); arrayfun(@offsetAxes, hAx); setFontForThesis([hAx], hFig) figFileName = ['fhwmCV-' nameSuffix qualityMeasure '-' num2str(threshold) ... '-rSquare-' num2str(rSquareThreshold)]; % set(gcf,'renderer','painters') % set(gcf, 'PaperPositionMode', 'auto'); print(hFig, [figDir figFileName '.pdf'], '-dpdf') print(hFig, [figDir figFileName '.png'], '-dpng', '-r300') end function [isSignificant, cvArray, varargout] = bootstrapCoeffOfVariation(widthCell) %% Bootstrap analysis of CV. cvArray = cellfun(@calcCoeffOfVariation, widthCell); bootsCV = cellfun(@(x) bootstrp(5000, @calcCoeffOfVariation, x), widthCell, 'uni', 0); bootsCVArray = cell2mat(bootsCV); meanCVPerBoot = mean(bootsCVArray, 2); centralDecisionLineCV = mean(meanCVPerBoot); standardErrorCV = sqrt(mean((meanCVPerBoot - centralDecisionLineCV) .^ 2)); alpha = 0.05; lowerDecisionLineCV = centralDecisionLineCV - norminv(1 - alpha / 2) * standardErrorCV; upperDecisionLineCV = centralDecisionLineCV + norminv(1 - alpha / 2) * standardErrorCV; error = norminv(1 - alpha / 2) * standardErrorCV; isSignificant = cvArray < lowerDecisionLineCV | cvArray > upperDecisionLineCV; varargout{1} = bootsCVArray; varargout{2} = centralDecisionLineCV; varargout{3} = lowerDecisionLineCV; varargout{4} = upperDecisionLineCV; end