Commit 50d1c92f authored by gonciarz's avatar gonciarz

First part of code using old JavaML refactored

parent 8a11b267
......@@ -5,7 +5,7 @@ import java.awt.Color;
import ij.gui.Plot;
import ij.gui.PlotWindow;
import mosaic.ia.Potentials.Potential;
import net.sf.javaml.utils.ArrayUtils;
import mosaic.utils.ArrayOps;
/**
* Class responsible for plotting calculated distributions
......@@ -13,7 +13,7 @@ import net.sf.javaml.utils.ArrayUtils;
*/
public class DistributionsPlot extends BasePlot {
public DistributionsPlot(double[] aContextQdDistancesGrid, double[] aContextQdPdf, double[] aNearestNeighborDistancesXtoYPdf) {
double max = Math.max(ArrayUtils.max(aContextQdPdf), ArrayUtils.max(aNearestNeighborDistancesXtoYPdf));
double max = Math.max(ArrayOps.findMinMax(aContextQdPdf).getMax(), ArrayOps.findMinMax(aNearestNeighborDistancesXtoYPdf).getMax());
plot = new Plot("Result: Estimated distance distributions", "Distance", "Probability density");
plot.setLimits(aContextQdDistancesGrid[0], aContextQdDistancesGrid[aContextQdDistancesGrid.length - 1], 0, max);
......@@ -22,7 +22,7 @@ public class DistributionsPlot extends BasePlot {
}
public DistributionsPlot(double[] aContextQdDistancesGrid, double[] aObservedModelFitPdPdf, double[] aContextQdPdf, double[] aNearestNeighborDistancesXtoYPdf, Potential aPotential, double[] aBestPointFound, double aBestFunctionValue) {
double max = Math.max(ArrayUtils.max(aContextQdPdf), Math.max(ArrayUtils.max(aNearestNeighborDistancesXtoYPdf), ArrayUtils.max(aObservedModelFitPdPdf)));
double max = Math.max(ArrayOps.findMinMax(aContextQdPdf).getMax(), Math.max(ArrayOps.findMinMax(aNearestNeighborDistancesXtoYPdf).getMax(), ArrayOps.findMinMax(aObservedModelFitPdPdf).getMax()));
plot = new Plot("Distance distributions", "Distance", "Probability density");
plot.setLimits(aContextQdDistancesGrid[0], aContextQdDistancesGrid[aContextQdDistancesGrid.length - 1], 0, max);
plot.setLineWidth(2);
......
......@@ -17,7 +17,8 @@ import ij.gui.PlotWindow;
import ij.measure.ResultsTable;
import ij.process.ByteProcessor;
import mosaic.core.detection.Particle;
import net.sf.javaml.utils.ArrayUtils;
import mosaic.utils.ArrayOps;
import mosaic.utils.ArrayOps.MinMax;
/**
......@@ -125,10 +126,14 @@ class TrajectoryAnalysisPlot extends ImageWindow implements ActionListener {
// Calculate X/Y min/max for plot
final double minX = aX[0];
final double maxX = aX[aX.length-1];
double minY = ArrayUtils.min(aY);
double maxY = ArrayUtils.max(aY);
minY = Math.min(minY, ArrayUtils.min(slopeLine));
maxY = Math.max(maxY, ArrayUtils.max(slopeLine));
MinMax<Double> mmY = ArrayOps.findMinMax(aY);
double minY = mmY.getMin();
double maxY = mmY.getMax();
MinMax<Double> mmSlopeLine = ArrayOps.findMinMax(slopeLine);
minY = Math.min(minY, mmSlopeLine.getMin());
maxY = Math.max(maxY, mmSlopeLine.getMax());
// Create plot with slope line
PlotWindow.noGridLines = false; // draw grid lines
......
package mosaic.utils;
import static org.junit.Assert.*;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
......@@ -189,4 +190,12 @@ public class ArrayOpsTest extends CommonBase {
for (int z = 0; z < input[0][0].length; ++z)
assertEquals(1.3, input[i][j][z], 1e-9);
}
@Test
public void testFindMinMax1D() {
double input[] = {-1.5, 4, 2, -2.1, 10, 2};
MinMax<Double> mm = ArrayOps.findMinMax(input);
assertEquals(-2.1, mm.getMin().doubleValue(), 1e-9);
assertEquals(10.0, mm.getMax().doubleValue(), 1e-9);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment