Search in sources :

Example 51 with Plot

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();
}
Also used : Plot(ij.gui.Plot)

Example 52 with Plot

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);
    }
}
Also used : Plot(ij.gui.Plot)

Example 53 with 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));
}
Also used : Plot(ij.gui.Plot) PolygonRoi(ij.gui.PolygonRoi) PointRoi(ij.gui.PointRoi) OffsetPointRoi(uk.ac.sussex.gdsc.core.ij.gui.OffsetPointRoi) Roi(ij.gui.Roi) Point(java.awt.Point)

Example 54 with Plot

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);
    }
}
Also used : Plot(ij.gui.Plot) PlotWindow(ij.gui.PlotWindow) WindowOrganiser(uk.ac.sussex.gdsc.core.ij.plugin.WindowOrganiser) Point(java.awt.Point) Point(java.awt.Point)

Example 55 with Plot

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);
}
Also used : Color(java.awt.Color) Arrays(java.util.Arrays) Calibration(uk.ac.sussex.gdsc.smlm.data.config.CalibrationProtos.Calibration) IntUnaryOperator(java.util.function.IntUnaryOperator) Rectangle2D(java.awt.geom.Rectangle2D) HistogramPlotBuilder(uk.ac.sussex.gdsc.core.ij.HistogramPlot.HistogramPlotBuilder) IdFramePeakResultComparator(uk.ac.sussex.gdsc.smlm.results.sort.IdFramePeakResultComparator) UnaryOperator(java.util.function.UnaryOperator) Hull(uk.ac.sussex.gdsc.core.math.hull.Hull) TableCellRenderer(javax.swing.table.TableCellRenderer) ResultsSettings(uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsSettings) FloatUnaryOperator(uk.ac.sussex.gdsc.core.utils.function.FloatUnaryOperator) MemoryPeakResults(uk.ac.sussex.gdsc.smlm.results.MemoryPeakResults) RoiManager(ij.plugin.frame.RoiManager) RowSorter(javax.swing.RowSorter) SoftLock(uk.ac.sussex.gdsc.core.utils.SoftLock) JFrame(javax.swing.JFrame) LutHelper(uk.ac.sussex.gdsc.core.ij.process.LutHelper) KeyStroke(javax.swing.KeyStroke) TableModelEvent(javax.swing.event.TableModelEvent) InputSource(uk.ac.sussex.gdsc.smlm.ij.plugins.ResultsManager.InputSource) DistanceUnit(uk.ac.sussex.gdsc.smlm.data.config.UnitProtos.DistanceUnit) KeyEvent(java.awt.event.KeyEvent) WindowAdapter(java.awt.event.WindowAdapter) ConcurrencyUtils(uk.ac.sussex.gdsc.core.utils.concurrent.ConcurrencyUtils) Component(java.awt.Component) Hull2d(uk.ac.sussex.gdsc.core.math.hull.Hull2d) TextUtils(uk.ac.sussex.gdsc.core.utils.TextUtils) Plot(ij.gui.Plot) Executors(java.util.concurrent.Executors) CalibrationHelper(uk.ac.sussex.gdsc.smlm.data.config.CalibrationHelper) ImagePlus(ij.ImagePlus) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) ToDoubleFunction(java.util.function.ToDoubleFunction) TcPalmAnalysisSettings(uk.ac.sussex.gdsc.smlm.ij.settings.GUIProtos.TcPalmAnalysisSettings) FileUtils(uk.ac.sussex.gdsc.core.utils.FileUtils) PlugIn(ij.plugin.PlugIn) ListSelectionModel(javax.swing.ListSelectionModel) ActionListener(java.awt.event.ActionListener) PolygonRoi(ij.gui.PolygonRoi) StoredData(uk.ac.sussex.gdsc.core.utils.StoredData) FrameCounter(uk.ac.sussex.gdsc.smlm.results.count.FrameCounter) WindowManager(ij.WindowManager) ConvexHull2d(uk.ac.sussex.gdsc.core.math.hull.ConvexHull2d) PeakResult(uk.ac.sussex.gdsc.smlm.results.PeakResult) PointRoi(ij.gui.PointRoi) Trace(uk.ac.sussex.gdsc.smlm.results.Trace) GenericDialog(ij.gui.GenericDialog) AbstractTableModel(javax.swing.table.AbstractTableModel) SortUtils(uk.ac.sussex.gdsc.core.utils.SortUtils) RounderUtils(uk.ac.sussex.gdsc.core.data.utils.RounderUtils) Overlay(ij.gui.Overlay) Files(java.nio.file.Files) BufferedWriter(java.io.BufferedWriter) Window(java.awt.Window) IOException(java.io.IOException) JScrollPane(javax.swing.JScrollPane) RoiListener(ij.gui.RoiListener) Paths(java.nio.file.Paths) ConcurrentMonoStack(uk.ac.sussex.gdsc.core.utils.concurrent.ConcurrentMonoStack) ListSelectionListener(javax.swing.event.ListSelectionListener) TIntArrayList(gnu.trove.list.array.TIntArrayList) IdentityTypeConverter(uk.ac.sussex.gdsc.core.data.utils.IdentityTypeConverter) Point(java.awt.Point) CoordinatePredicateUtils(uk.ac.sussex.gdsc.core.ij.roi.CoordinatePredicateUtils) ResultsImageSettings(uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsImageSettings) ImageJPluginLoggerHelper(uk.ac.sussex.gdsc.core.ij.ImageJPluginLoggerHelper) LocalCollectors(uk.ac.sussex.gdsc.core.utils.LocalCollectors) ImageJImagePeakResults(uk.ac.sussex.gdsc.smlm.ij.results.ImageJImagePeakResults) NonBlockingExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.NonBlockingExtendedGenericDialog) ScreenDimensionHelper(uk.ac.sussex.gdsc.core.ij.gui.ScreenDimensionHelper) PlotWindow(ij.gui.PlotWindow) ListSelectionEvent(javax.swing.event.ListSelectionEvent) SettingsManager(uk.ac.sussex.gdsc.smlm.ij.settings.SettingsManager) JMenuBar(javax.swing.JMenuBar) CoordinatePredicate(uk.ac.sussex.gdsc.core.ij.roi.CoordinatePredicate) ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog) PeakResultsList(uk.ac.sussex.gdsc.smlm.results.PeakResultsList) JMenu(javax.swing.JMenu) TIntIntHashMap(gnu.trove.map.hash.TIntIntHashMap) OffsetPointRoi(uk.ac.sussex.gdsc.core.ij.gui.OffsetPointRoi) WindowEvent(java.awt.event.WindowEvent) DoubleStream(java.util.stream.DoubleStream) Objects(java.util.Objects) List(java.util.List) SimpleArrayUtils(uk.ac.sussex.gdsc.core.utils.SimpleArrayUtils) JTable(javax.swing.JTable) LUT(ij.process.LUT) TypeConverter(uk.ac.sussex.gdsc.core.data.utils.TypeConverter) Roi(ij.gui.Roi) Rectangle(java.awt.Rectangle) WindowOrganiser(uk.ac.sussex.gdsc.core.ij.plugin.WindowOrganiser) AtomicReference(java.util.concurrent.atomic.AtomicReference) SwingConstants(javax.swing.SwingConstants) TextField(java.awt.TextField) Level(java.util.logging.Level) AWTEvent(java.awt.AWTEvent) BiPredicate(java.util.function.BiPredicate) SwingUtilities(javax.swing.SwingUtilities) JMenuItem(javax.swing.JMenuItem) ImagePeakResultsFactory(uk.ac.sussex.gdsc.smlm.ij.results.ImagePeakResultsFactory) UnitHelper(uk.ac.sussex.gdsc.smlm.data.config.UnitHelper) ExecutorService(java.util.concurrent.ExecutorService) LutColour(uk.ac.sussex.gdsc.core.ij.process.LutHelper.LutColour) ActionEvent(java.awt.event.ActionEvent) Rounder(uk.ac.sussex.gdsc.core.data.utils.Rounder) TimeUnit(uk.ac.sussex.gdsc.smlm.data.config.UnitProtos.TimeUnit) Consumer(java.util.function.Consumer) Counter(uk.ac.sussex.gdsc.smlm.results.count.Counter) ImageJUtils(uk.ac.sussex.gdsc.core.ij.ImageJUtils) TableColumnAdjuster(uk.ac.sussex.gdsc.smlm.ij.gui.TableColumnAdjuster) IJ(ij.IJ) DoublePredicate(java.util.function.DoublePredicate) Collections(java.util.Collections) LocalList(uk.ac.sussex.gdsc.core.utils.LocalList) TIntIntHashMap(gnu.trove.map.hash.TIntIntHashMap)

Aggregations

Plot (ij.gui.Plot)89 HistogramPlot (uk.ac.sussex.gdsc.core.ij.HistogramPlot)20 Point (java.awt.Point)19 PlotWindow (ij.gui.PlotWindow)17 Color (java.awt.Color)13 WindowOrganiser (uk.ac.sussex.gdsc.core.ij.plugin.WindowOrganiser)13 HistogramPlotBuilder (uk.ac.sussex.gdsc.core.ij.HistogramPlot.HistogramPlotBuilder)12 BasePoint (uk.ac.sussex.gdsc.core.match.BasePoint)12 ExtendedGenericDialog (uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog)11 MemoryPeakResults (uk.ac.sussex.gdsc.smlm.results.MemoryPeakResults)11 Rectangle (java.awt.Rectangle)9 ArrayList (java.util.ArrayList)9 GenericDialog (ij.gui.GenericDialog)8 NonBlockingExtendedGenericDialog (uk.ac.sussex.gdsc.core.ij.gui.NonBlockingExtendedGenericDialog)7 LocalList (uk.ac.sussex.gdsc.core.utils.LocalList)7 Statistics (uk.ac.sussex.gdsc.core.utils.Statistics)7 StoredData (uk.ac.sussex.gdsc.core.utils.StoredData)7 StoredDataStatistics (uk.ac.sussex.gdsc.core.utils.StoredDataStatistics)7 ImagePlus (ij.ImagePlus)6 TDoubleArrayList (gnu.trove.list.array.TDoubleArrayList)5