use of ij.gui.Plot in project mcib3d-core by mcib3d.
the class HistogramUtil method plotCumulHistogram.
/**
* @param title
*/
public void plotCumulHistogram(String title) {
if (ycumul == null) {
this.computeCumulHistogram();
}
Plot plot = new Plot(title, "values", "nb", xbin, ycumul);
plot.show();
}
use of ij.gui.Plot in project GDSC-SMLM by aherbert.
the class SpotInspector method plotScore.
private void plotScore(float[] xValues, float[] yValues, double yMin, double yMax) {
if (settings.plotScore) {
final String title = TITLE + " Score";
final Plot plot = new Plot(title, "Rank", Settings.SORT_ORDER[settings.sortOrderIndex]);
plot.addPoints(xValues, yValues, Plot.LINE);
plot.setLimits(1, xValues.length, yMin, yMax);
ImageJUtils.display(title, plot);
}
}
use of ij.gui.Plot in project GDSC-SMLM by aherbert.
the class TcPalmAnalysis method runClusterPlotSelection.
/**
* Select the data for the first cluster in the provided list on the cumulative activations plot.
*
* @param clusters the clusters
*/
private void runClusterPlotSelection(List<ClusterData> clusters) {
final Plot plot = activationsPlotData.plot;
// We are expecting only a single cluster
if (clusters.isEmpty()) {
plot.getImagePlus().deleteRoi();
return;
}
final int[] plotFrames = activationsPlotData.data.plotFrames;
final int[] plotCounts = activationsPlotData.data.plotCounts;
final ClusterData data = clusters.get(0);
final int is = Arrays.binarySearch(plotFrames, data.start);
final int ie = Arrays.binarySearch(plotFrames, data.end);
final int low = plotCounts[is];
final int high = plotCounts[ie];
// Pad slightly. This handles the case where start == end to create a width and height
final float[] x = activationsPlotData.timeConverter.apply(new float[] { data.start - 1, data.end + 1 });
final double x1 = plot.scaleXtoPxl(x[0]);
final double x2 = plot.scaleXtoPxl(x[1]);
final double y1 = plot.scaleYtoPxl(high + 1);
final double y2 = plot.scaleYtoPxl(low - 1);
plot.getImagePlus().setRoi(new Roi(x1, y1, x2 - x1, y2 - y1));
}
use of ij.gui.Plot in project GDSC-SMLM by aherbert.
the class TcPalmAnalysis method runPlot.
/**
* Create the activations and total activations plots.
*
* @param settings the settings
*/
private void runPlot(TcPalmAnalysisSettings settings) {
final WindowOrganiser wo = new WindowOrganiser();
String timeLabel = "Time";
UnaryOperator<float[]> timeConverter;
double timeScale;
if (settings.getTimeInSeconds()) {
timeLabel += " (s)";
timeScale = 1.0 / results.getCalibration().getTimeCalibration().getExposureTime();
timeConverter = frames -> {
SimpleArrayUtils.apply(frames, f -> f *= timeScale);
return frames;
};
} else {
timeLabel += " (frame)";
timeConverter = UnaryOperator.identity();
timeScale = 1;
}
final CumulativeCountData data = this.countData;
String title = TITLE + " Activations vs Time";
final Plot plot1 = new Plot(title, timeLabel, "Count");
plot1.addLabel(0, 0, TextUtils.pleural(clusters.size(), "cluster"));
for (int i = 0; i < data.frames.length; i++) {
final int t = data.frames[i];
final int c = data.counts[i];
plot1.addPoints(timeConverter.apply(new float[] { t, t }), new float[] { 0, c }, Plot.LINE);
}
plot1.draw();
plot1.setLimitsToFit(true);
if (settings.getFixedTimeAxis()) {
final double[] limits = plot1.getLimits();
limits[0] = timeScale * (minT - 1);
limits[1] = timeScale * (maxT + 1);
plot1.setLimits(limits);
plot1.updateImage();
}
final PlotWindow pw1 = ImageJUtils.display(title, plot1, ImageJUtils.NO_TO_FRONT, wo);
title = TITLE + " Total Activations vs Time";
final Plot plot2 = new Plot(title, timeLabel, "Cumulative count");
final int localisations = data.counts.length == 0 ? 0 : data.plotCounts[data.plotCounts.length - 1];
final int clashes = localisations - data.counts.length;
plot2.addLabel(0, 0, TextUtils.pleural(localisations, "localisation") + " : " + clashes + TextUtils.pleuralise(clashes, " clash", " clashes"));
plot2.addPoints(timeConverter.apply(SimpleArrayUtils.toFloat(data.plotFrames)), SimpleArrayUtils.toFloat(data.plotCounts), Plot.LINE);
if (settings.getFixedTimeAxis()) {
plot2.setLimits(timeScale * (minT - 1), timeScale * (maxT + 1), Double.NaN, Double.NaN);
}
final PlotWindow pw2 = ImageJUtils.display(title, plot2, ImageJUtils.NO_TO_FRONT, wo);
activationsPlotData = new ActivationsPlotData(plot2, timeConverter, data);
// Simple tile one window above the other only if both are new.
if (wo.size() == 2) {
final Point p = pw1.getLocation();
p.y += pw1.getHeight();
pw2.setLocation(p);
}
}
use of ij.gui.Plot in project GDSC-SMLM by aherbert.
the class TcPalmAnalysis method createCumulativeCountData.
/**
* Creates the cumulative count data.
*
* @param createPlotData set to true to create the plot data arrays
* @return the cumulative count data
*/
private CumulativeCountData createCumulativeCountData(LocalList<ClusterData> clusters, boolean createPlotData) {
final TIntIntHashMap all = new TIntIntHashMap(maxT - minT + 1);
clusters.forEach(c -> c.results.forEach(peak -> all.adjustOrPutValue(peak.getFrame(), 1, 1)));
final int[] frames = all.keys();
final int[] counts = all.values();
SortUtils.sortData(counts, frames, true, false);
return new CumulativeCountData(frames, counts, createPlotData);
}
Aggregations