diff --git a/code/TASBEConfig.m b/code/TASBEConfig.m index c742e01..060b0b4 100644 --- a/code/TASBEConfig.m +++ b/code/TASBEConfig.m @@ -365,6 +365,8 @@ doc.histogram.about = 'Settings controlling histogram plotting preferences'; doc.histogram.displayLegend = 'If true, displays legend in bin statistics graphs'; s.histogram.displayLegend = true; + doc.histogram.plotGMM = 'If true, plots gaussian mixture model in bin statistics graphs'; + s.histogram.plotGMM = false; % Excel wrapper preferences s.template = struct(); diff --git a/code/plot_batch_histograms.m b/code/plot_batch_histograms.m index a5e4470..c001bd7 100644 --- a/code/plot_batch_histograms.m +++ b/code/plot_batch_histograms.m @@ -84,7 +84,6 @@ function plot_batch_histograms(results,sampleresults,CM,linespecs) maxcount = max(maxcount,max(max(counts))); end - for j=1:numReplicates for k=1:n_colors ls = linespecs{k}; @@ -96,6 +95,36 @@ function plot_batch_histograms(results,sampleresults,CM,linespecs) end end + % add the plot of the GMM fit if it's available + if TASBEConfig.get('histogram.plotGMM') + for k=1:n_colors + replicates = sampleresults{i}; + numReplicates = numel(replicates); + for j=1:numReplicates + fp_dist.mu = replicates{j}.PopComponentMeans; + fp_dist.Sigma(1,1,:) = replicates{j}.PopComponentStandardDevs; + fp_dist.weight = replicates{j}.PopComponentWeights; + bin_widths = get_bin_widths(getBins(replicates{j}.AnalysisParameters)); + counts = replicates{j}.BinCounts; + multiplier = sum(counts)*log10(bin_widths); + + model = gmm_pdf(fp_dist, log10(bin_centers)')*multiplier; + ls = linespecs{k}; + if(ischar(ls) && length(ls)==1 && length(findstr(ls, 'rgbcmykw')) == 1) + plot(bin_centers,model,[ls '--']); hold on; + for l=1:numel(fp_dist.mu) + loglog([10^fp_dist.mu(l) 10^fp_dist.mu(l)],[1 maxcount],[ls ':']); + end + else + plot(bin_centers,model,'Color', ls, 'LineStyle', '--'); hold on; + for l=1:numel(fp_dist.mu) + loglog([10^fp_dist.mu(l) 10^fp_dist.mu(l)],[1 maxcount],'Color', ls, 'LineStyle', ':'); + end + end + end + end + end + xlabel(unitlegend); ylabel('Count'); legend(lines, legendentries,'Location','Best'); if(TASBEConfig.isSet('OutputSettings.FixedBinningAxis')), xlim(TASBEConfig.get('OutputSettings.FixedBinningAxis')); end