Example usage for java.lang Double POSITIVE_INFINITY

List of usage examples for java.lang Double POSITIVE_INFINITY

Introduction

In this page you can find the example usage for java.lang Double POSITIVE_INFINITY.

Prototype

double POSITIVE_INFINITY

To view the source code for java.lang Double POSITIVE_INFINITY.

Click Source Link

Document

A constant holding the positive infinity of type double .

Usage

From source file:org.jfree.data.xy.XYSeriesCollection.java

/**
 * Returns the range of the values in this dataset's domain.
 *
 * @param includeInterval  a flag that determines whether or not the
 *                         x-interval is taken into account.
 *
 * @return The range (or <code>null</code> if the dataset contains no
 *     values).//from   www .ja v a  2  s .co  m
 */
@Override
public Range getDomainBounds(boolean includeInterval) {
    if (includeInterval) {
        return this.intervalDelegate.getDomainBounds(includeInterval);
    } else {
        double lower = Double.POSITIVE_INFINITY;
        double upper = Double.NEGATIVE_INFINITY;
        int seriesCount = getSeriesCount();
        for (int s = 0; s < seriesCount; s++) {
            XYSeries series = getSeries(s);
            double minX = series.getMinX();
            if (!Double.isNaN(minX)) {
                lower = Math.min(lower, minX);
            }
            double maxX = series.getMaxX();
            if (!Double.isNaN(maxX)) {
                upper = Math.max(upper, maxX);
            }
        }
        if (lower > upper) {
            return null;
        } else {
            return new Range(lower, upper);
        }
    }
}

From source file:byps.BBufferJson.java

public double getDouble() {
    StringBuilder sbuf = new StringBuilder(30);
    for (;;) {//from  w  w w.  j a  va 2s . c  om
        char c = nextJsonChar(true);
        if ((c >= '0' && c <= '9') || (c == '.') || (c == 'e') || (c == 'E') || (c == '-') || (c == '+')) {
            sbuf.append(c);
        } else if (c == 'N') {
            internalSkip(2);
            nextJsonChar(false); // update this.lastChar
            return Double.NaN;
        } else if (c == 'I') {
            boolean neg = sbuf.length() != 0 && sbuf.charAt(0) == '-';
            internalSkip(7);
            nextJsonChar(false); // update this.lastChar
            return neg ? Double.NEGATIVE_INFINITY : Double.POSITIVE_INFINITY;
        } else {
            oneCharBack();
            break;
        }
    }
    return Double.parseDouble(sbuf.toString());
}

From source file:cc.redberry.core.number.Complex.java

public double absNumeric() {
    if (isNaN())//from   w w  w .j ava 2  s .  c  o  m
        return Double.NaN;

    if (isInfinite())
        return Double.POSITIVE_INFINITY;

    final double real = this.real.doubleValue();
    final double imaginary = this.imaginary.doubleValue();

    return absNumeric(real, imaginary);
}

From source file:dbseer.gui.chart.DBSeerChartFactory.java

public static JFreeChart createXYLinePredictionChart(PredictionCenter center) throws Exception {
    StatisticalPackageRunner runner = DBSeerGUI.runner;

    String title = runner.getVariableString("title");
    Object[] legends = (Object[]) runner.getVariableCell("legends");
    Object[] xCellArray = (Object[]) runner.getVariableCell("Xdata");
    Object[] yCellArray = (Object[]) runner.getVariableCell("Ydata");
    String xLabel = runner.getVariableString("Xlabel");
    String yLabel = runner.getVariableString("Ylabel");

    XYSeriesCollection dataSet = new XYSeriesCollection();

    int numLegends = legends.length;
    int numXCellArray = xCellArray.length;
    int numYCellArray = yCellArray.length;
    int dataCount = 0;

    if (numXCellArray != numYCellArray) {
        JOptionPane.showMessageDialog(null, "The number of X dataset and Y dataset does not match.",
                "The number of X dataset and Y dataset does not match.", JOptionPane.ERROR_MESSAGE);
        System.out.println(numXCellArray + " : " + numYCellArray);
        return null;
    }/*from   w  w w.  j av a2s .c o m*/

    final java.util.List<String> transactionNames = center.getTrainConfig().getDataset(0)
            .getTransactionTypeNames();
    for (int i = 0; i < numLegends; ++i) {
        String legend = (String) legends[i];
        for (int j = 0; j < transactionNames.size(); ++j) {
            if (legend.contains("Type " + (j + 1))) {
                legends[i] = legend.replace("Type " + (j + 1), transactionNames.get(j));
                break;
            }
        }
    }
    for (int j = 0; j < transactionNames.size(); ++j) {
        if (xLabel.contains("Type " + (j + 1))) {
            xLabel = xLabel.replace("Type " + (j + 1), transactionNames.get(j));
            break;
        }
    }
    for (int j = 0; j < transactionNames.size(); ++j) {
        if (yLabel.contains("Type " + (j + 1))) {
            yLabel = yLabel.replace("Type " + (j + 1), transactionNames.get(j));
            break;
        }
    }

    for (int i = 0; i < numYCellArray; ++i) {
        double[] xArray = (double[]) xCellArray[i];
        runner.eval("yArraySize = size(Ydata{" + (i + 1) + "});");
        runner.eval("yArray = Ydata{" + (i + 1) + "};");
        double[] yArraySize = runner.getVariableDouble("yArraySize");
        double[] yArray = runner.getVariableDouble("yArray");

        int xLength = xArray.length;
        int row = (int) yArraySize[0];
        int col = (int) yArraySize[1];

        for (int c = 0; c < col; ++c) {
            XYSeries series;
            int legendIdx = (dataCount >= numLegends) ? numLegends - 1 : dataCount;
            String legend = (String) legends[legendIdx];
            if (numLegends == 0) {
                series = new XYSeries("Data " + dataCount + 1);
            } else if (dataCount >= numLegends) {
                series = new XYSeries(legend + (dataCount + 1));
            } else {
                series = new XYSeries(legend);
            }

            for (int r = 0; r < row; ++r) {
                int xRow = (r >= xLength) ? xLength - 1 : r;
                double yValue = yArray[r + c * row];
                // remove negatives & NaN & infs.
                if (yValue < 0 || yValue == Double.NaN || yValue == Double.POSITIVE_INFINITY
                        || yValue == Double.NEGATIVE_INFINITY) {
                    yValue = 0.0;
                }
                series.add(xArray[xRow], yValue);
            }
            dataSet.addSeries(series);
            ++dataCount;
        }
    }

    JFreeChart chart = ChartFactory.createXYLineChart(title, xLabel, yLabel, dataSet);

    // change 'predicted' data to have dotted lines.
    BasicStroke dashStroke = toStroke(STYLE_DASH);
    BasicStroke dotStroke = toStroke(STYLE_DOT);
    BasicStroke lineStroke = toStroke(STYLE_LINE);
    for (int i = 0; i < dataSet.getSeriesCount(); ++i) {
        String legend = (String) dataSet.getSeriesKey(i);
        XYPlot plot = chart.getXYPlot();
        XYItemRenderer renderer = plot.getRenderer();
        if (legend.contains("predicted") || legend.contains("Predicted")) {
            renderer.setSeriesStroke(i, dotStroke);
        } else {
            renderer.setSeriesStroke(i, lineStroke);
        }
    }

    return chart;
}

From source file:edu.cmu.tetrad.search.FastIca.java

private TetradMatrix icaDeflation(TetradMatrix X, int numComponents, double tolerance, int function,
        double alpha, int maxIterations, boolean verbose, TetradMatrix wInit) {
    if (verbose && function == LOGCOSH) {
        TetradLogger.getInstance().log("info",
                "Deflation FastIca using lgcosh approx. to neg-entropy function");
    }/* w  ww .ja  va2  s.  c  om*/

    if (verbose && function == EXP) {
        TetradLogger.getInstance().log("info",
                "Deflation FastIca using exponential approx. to neg-entropy function");
    }

    int p = X.columns();
    TetradMatrix W = new TetradMatrix(numComponents, numComponents);

    for (int i = 0; i < numComponents; i++) {
        if (verbose) {
            TetradLogger.getInstance().log("fastIcaDetails", "Component " + (i + 1));
        }

        TetradVector w = wInit.getRow(i);

        if (i > 0) {
            TetradVector t = w.like();

            for (int u = 0; u < i; u++) {
                double k = 0.0;

                for (int j = 0; j < numComponents; j++) {
                    k += w.get(j) * W.get(u, j);
                }

                for (int j = 0; j < numComponents; j++) {
                    t.set(j, t.get(j) + k * W.get(u, j));
                }
            }

            for (int j = 0; j < numComponents; j++) {
                w.set(j, w.get(j) - t.get(j));
            }
        }

        double rms = rms(w);

        for (int j = 0; j < numComponents; j++) {
            w.set(j, w.get(j) / rms);
        }

        int it = 0;
        double _tolerance = Double.POSITIVE_INFINITY;

        if (function == LOGCOSH) {
            while (_tolerance > tolerance && ++it <= maxIterations) {
                TetradVector wx = X.transpose().times(w);

                TetradVector gwx0 = new TetradVector(p);

                for (int j = 0; j < p; j++) {
                    gwx0.set(j, Math.tanh(alpha * wx.get(j)));
                }

                TetradMatrix gwx = new TetradMatrix(numComponents, p);

                for (int _i = 0; _i < numComponents; _i++) {
                    for (int j = 0; j < p; j++) {
                        gwx.set(_i, j, gwx0.get(j));
                    }
                }

                TetradMatrix xgwx = new TetradMatrix(numComponents, p);

                for (int _i = 0; _i < numComponents; _i++) {
                    for (int j = 0; j < p; j++) {
                        xgwx.set(_i, j, X.get(_i, j) * gwx0.get(j));
                    }
                }

                TetradVector v1 = new TetradVector(numComponents);

                for (int k = 0; k < numComponents; k++) {
                    v1.set(k, mean(xgwx.getRow(k)));
                }

                TetradVector g_wx = new TetradVector(p);

                for (int k = 0; k < p; k++) {
                    double tmp1 = Math.tanh(alpha * wx.get(k));
                    g_wx.set(k, alpha * (1.0 - tmp1 * tmp1));
                }

                TetradVector v2 = w.copy();
                double meanGwx = mean(g_wx);
                v2 = v2.scalarMult(meanGwx);

                TetradVector w1 = v1.copy();
                //                    w1.assign(v2, PlusMult.plusMult(-1));
                w1 = w1.minus(v2);

                if (i > 0) {
                    TetradVector t = w1.like();

                    for (int u = 0; u < i; u++) {
                        double k = 0.0;

                        for (int j = 0; j < numComponents; j++) {
                            k += w1.get(j) * W.get(u, j);
                        }

                        for (int j = 0; j < numComponents; j++) {
                            t.set(j, t.get(j) + k * W.get(u, j));
                        }
                    }

                    for (int j = 0; j < numComponents; j++) {
                        w1.set(j, w1.get(j) - t.get(j));
                    }
                }

                double _rms = rms(w1);

                for (int k = 0; k < numComponents; k++) {
                    w1.set(k, w1.get(k) / _rms);
                }

                _tolerance = 0.0;

                for (int k = 0; k < numComponents; k++) {
                    _tolerance += w1.get(k) * w.get(k);
                }

                _tolerance = Math.abs(Math.abs(_tolerance) - 1.0);

                if (verbose) {
                    TetradLogger.getInstance().log("fastIcaDetails",
                            "Iteration " + it + " tol = " + _tolerance);
                }

                w = w1;
            }
        } else if (function == EXP) {
            while (_tolerance > tolerance && ++it <= maxIterations) {
                TetradVector wx = X.transpose().times(w);

                TetradVector gwx0 = new TetradVector(p);

                for (int j = 0; j < p; j++) {
                    gwx0.set(j, wx.get(j) * Math.exp(-(wx.get(j) * wx.get(j)) / 2));
                }

                TetradMatrix gwx = new TetradMatrix(numComponents, p);

                for (int _i = 0; _i < numComponents; _i++) {
                    for (int j = 0; j < p; j++) {
                        gwx.set(_i, j, gwx0.get(j));
                    }
                }

                TetradMatrix xgwx = new TetradMatrix(numComponents, p);

                for (int _i = 0; _i < numComponents; _i++) {
                    for (int j = 0; j < p; j++) {
                        xgwx.set(_i, j, X.get(_i, j) * gwx0.get(j));
                    }
                }

                TetradVector v1 = new TetradVector(numComponents);

                for (int k = 0; k < numComponents; k++) {
                    v1.set(k, mean(xgwx.getRow(k)));
                }

                TetradVector g_wx = new TetradVector(p);

                for (int j = 0; j < p; j++) {
                    g_wx.set(j, (1.0 - wx.get(j) * wx.get(j)) * Math.exp(-(wx.get(j) * wx.get(j)) / 2));
                }

                TetradVector v2 = w.copy();
                double meanGwx = mean(g_wx);
                TetradVector w1 = v2.scalarMult(meanGwx).minus(v2);

                //                    TetradVector w1 = v1.copy();
                //                    w1.assign(v2, PlusMult.plusMult(-1));

                if (i > 0) {
                    TetradVector t = w1.like();

                    for (int u = 0; u < i; u++) {
                        double k = 0.0;

                        for (int j = 0; j < numComponents; j++) {
                            k += w1.get(j) * W.get(u, j);
                        }

                        for (int j = 0; j < numComponents; j++) {
                            t.set(j, t.get(j) + k * W.get(u, j));
                        }
                    }

                    for (int j = 0; j < numComponents; j++) {
                        w1.set(j, w1.get(j) - t.get(j));
                    }
                }

                double _rms = rms(w1);

                for (int k = 0; k < numComponents; k++) {
                    w1.set(k, w1.get(k) / _rms);
                }

                _tolerance = 0.0;

                for (int k = 0; k < numComponents; k++) {
                    _tolerance += w1.get(k) * w.get(k);
                }

                _tolerance = Math.abs(Math.abs(_tolerance) - 1.0);

                if (verbose) {
                    TetradLogger.getInstance().log("fastIcaDetails",
                            "Iteration " + it + " tol = " + _tolerance);
                }

                w = w1;
            }
        }

        W.assignRow(i, w);
    }

    return W;
}

From source file:delfos.rs.trustbased.WeightedGraph.java

public static final AdjMatrixEdgeWeightedDigraph inverseOfEdgeValue(
        AdjMatrixEdgeWeightedDigraph distanceGraph) {

    AdjMatrixEdgeWeightedDigraph weightGraph = new AdjMatrixEdgeWeightedDigraph(distanceGraph.V());

    List<DirectedEdge> allEdges = IntStream.range(0, distanceGraph.V()).boxed().map(vertex -> {
        Iterable<DirectedEdge> iterator = distanceGraph.adj(vertex);
        ArrayList<DirectedEdge> listOfEdges = new ArrayList<>();
        for (DirectedEdge edge : iterator) {
            listOfEdges.add(edge);// ww w .j  a  va2  s.  co  m
        }
        return listOfEdges;
    }).flatMap(listOfEdges -> listOfEdges.stream()).collect(Collectors.toList());

    List<DirectedEdge> allEdgesConverted = allEdges.stream().map(edge -> {
        final double weight = edge.weight();

        double distance = 1 / weight;

        if (weight == 0) {
            distance = Double.POSITIVE_INFINITY;
        }

        return new DirectedEdge(edge.from(), edge.to(), distance);
    }).collect(Collectors.toList());

    allEdgesConverted.forEach(edge -> weightGraph.addEdge(edge));
    return weightGraph;
}

From source file:gov.nih.nci.caarray.util.CaArrayUtils.java

private static double xmlStringToDouble(String value) {
    if ("NaN".equals(value)) {
        return Double.NaN;
    } else if ("INF".equals(value)) {
        return Double.POSITIVE_INFINITY;
    } else if ("-INF".equals(value)) {
        return Double.NEGATIVE_INFINITY;
    } else {/*from  w w  w.ja  va2s  . c o m*/
        return Double.parseDouble(value);
    }
}

From source file:automenta.vivisect.dimensionalize.HyperassociativeMap.java

/** vertices is passed as a list because the Set iterator from JGraphT is slow */
public ArrayRealVector align(V nodeToAlign, ObjectDoubleHashMap<V> neighbors, V[] vertices) {

    double nodeSpeed = getSpeedFactor(nodeToAlign);

    ArrayRealVector originalPosition = new ArrayRealVector(new double[2], true);
    //getPosition(nodeToAlign);
    //getCurrentPosition(nodeToAlign);
    getPosition(nodeToAlign, originalPosition.getDataRef());

    if (nodeSpeed == 0)
        return originalPosition;

    // calculate equilibrium with neighbors
    ArrayRealVector position = (ArrayRealVector) originalPosition.mapMultiplyToSelf(1.0 / scale);

    getNeighbors(nodeToAlign, neighbors);

    ArrayRealVector delta = newVector();

    double radius = getRadius(nodeToAlign);
    double targetDistance = radius + equilibriumDistance;
    double learningRate = this.learningRate;

    ArrayRealVector tmpAttractVector = newVector();

    // align with neighbours
    neighbors.forEachKeyValue((neighbor, distToNeighbor) -> {

        ArrayRealVector attractVector = getThePosition(neighbor, tmpAttractVector).combineToSelf(1, -1,
                position);/*  w  w w.j a va2 s.c  o  m*/

        double oldDistance = magnitude(attractVector);

        double newDistance;
        double factor = 0;
        double deltaDist = oldDistance - distToNeighbor;
        if (oldDistance > distToNeighbor) {
            newDistance = Math.pow(deltaDist, attractionStrength);

        } else {

            newDistance = -targetDistance * atanh((-deltaDist) / distToNeighbor);

            if (Math.abs(newDistance) > (Math.abs(deltaDist))) {
                newDistance = -targetDistance * (-deltaDist);
            }

        }

        newDistance *= learningRate;
        if (oldDistance != 0) {
            factor = newDistance / oldDistance;
        }

        add(delta, attractVector, factor);
    });

    ArrayRealVector repelVector = newVector();
    double maxEffectiveDistance = targetDistance * maxRepulsionDistance;

    ArrayRealVector nodePos = newVector();

    // calculate repulsion with all non-neighbors

    DistanceMetric distanceFunction = this.distanceFunction;
    double minDistance = this.minDistance;
    double repulsiveWeakness = this.repulsiveWeakness;

    for (V node : vertices) {

        if (node == null)
            continue;

        //vertices.forEach((Consumer<N>)node -> {
        //for (final N node : vertices) {
        if ((node == nodeToAlign) || (neighbors.containsKey(node)))
            continue;

        double oldDistance = distanceFunction.subtractIfLessThan(getThePosition(node, nodePos), position,
                repelVector, maxEffectiveDistance);

        if (oldDistance == Double.POSITIVE_INFINITY)
            continue; //too far to matter

        if (oldDistance < minDistance)
            oldDistance = minDistance; //continue;
        //throw new RuntimeException("invalid oldDistance");

        double newDistance = -targetDistance * Math.pow(oldDistance, -repulsiveWeakness);

        if (Math.abs(newDistance) > targetDistance) {
            newDistance = Math.copySign(targetDistance, newDistance);
        }
        newDistance *= learningRate;

        add(delta, repelVector, newDistance / oldDistance);
    }

    /*if (normalizeRepulsion)
    nodeSpeed/=delta.getNorm(); //TODO check when norm = 0*/

    if (nodeSpeed != 1.0) {
        delta.mapMultiplyToSelf(nodeSpeed);
    }

    double moveDistance = magnitude(delta);
    if (!Double.isFinite(moveDistance))
        throw new RuntimeException("invalid magnitude");

    if (moveDistance > targetDistance * acceptableMaxDistanceFactor) {
        double newLearningRate = ((targetDistance * acceptableMaxDistanceFactor) / moveDistance);
        if (newLearningRate < learningRate) {
            this.learningRate = newLearningRate;
        } else {
            this.learningRate *= LEARNING_RATE_INCREASE_FACTOR / vertices.length;
        }

        moveDistance = DEFAULT_TOTAL_MOVEMENT;
    } else {
        add(position, delta);
    }

    if (moveDistance > maxMovement) {
        maxMovement = moveDistance;
    }
    totalMovement += moveDistance;

    originalPosition.mapMultiplyToSelf(scale);
    move(nodeToAlign, originalPosition.getEntry(0), originalPosition.getEntry(1));
    return originalPosition;
}

From source file:de.tuberlin.uebb.jbop.example.DerivativeStructure.java

/**
 * Returns the hypotenuse of a triangle with sides {@code x} and {@code y} -
 * sqrt(<i>x</i><sup>2</sup>&nbsp;+<i>y</i><sup>2</sup>)<br/>
 * avoiding intermediate overflow or underflow.
 * /*from  w w  w.  ja  v  a 2s.com*/
 * <ul>
 * <li>If either argument is infinite, then the result is positive infinity.</li>
 * <li>else, if either argument is NaN then the result is NaN.</li>
 * </ul>
 * 
 * @param x
 *          a value
 * @param y
 *          a value
 * @return sqrt(<i>x</i><sup>2</sup>&nbsp;+<i>y</i><sup>2</sup>)
 * @throws DimensionMismatchException
 *           if number of free parameters or orders are inconsistent
 */
public static DerivativeStructure hypot(final DerivativeStructure x, final DerivativeStructure y)
        throws DimensionMismatchException {

    x.compiler.checkCompatibility(y.compiler);

    if (Double.isInfinite(x.data[0]) || Double.isInfinite(y.data[0])) {
        return new DerivativeStructure(x.compiler.getFreeParameters(), x.compiler.getFreeParameters(),
                Double.POSITIVE_INFINITY);
    } else if (Double.isNaN(x.data[0]) || Double.isNaN(y.data[0])) {
        return new DerivativeStructure(x.compiler.getFreeParameters(), x.compiler.getFreeParameters(),
                Double.NaN);
    } else {

        final int expX = x.getExponent();
        final int expY = y.getExponent();
        if (expX > (expY + 27)) {
            // y is neglectible with respect to x
            return x.abs();
        } else if (expY > (expX + 27)) {
            // x is neglectible with respect to y
            return y.abs();
        } else {

            // find an intermediate scale to avoid both overflow and underflow
            final int middleExp = (expX + expY) / 2;

            // scale parameters without losing precision
            final DerivativeStructure scaledX = x.scalb(-middleExp);
            final DerivativeStructure scaledY = y.scalb(-middleExp);

            // compute scaled hypotenuse
            final DerivativeStructure scaledH = scaledX.multiply(scaledX).add(scaledY.multiply(scaledY)).sqrt();

            // remove scaling
            return scaledH.scalb(middleExp);

        }

    }
}

From source file:gdsc.smlm.ij.plugins.SpotAnalysis.java

private void createProfile(ImagePlus imp, Rectangle bounds, double psfWidth, double blur) {
    areaBounds = bounds;//w  ww.jav a2 s.c  o  m
    this.imp = imp;
    area = bounds.width * bounds.height;
    clearSelectedFrames();

    // Get a profile through the images
    IJ.showStatus("Calculating raw profile");

    final int nSlices = imp.getStackSize();

    ImageStack rawSpot = new ImageStack(bounds.width, bounds.height, nSlices);
    double[][] profile = extractSpotProfile(imp, bounds, rawSpot);

    // Retain the existing display range
    double min = 0, max = Double.POSITIVE_INFINITY;
    if (rawImp != null) {
        min = rawImp.getDisplayRangeMin();
        max = rawImp.getDisplayRangeMax();
    }
    rawImp = showSpot(rawSpotTitle, rawSpot);
    if (max != Double.POSITIVE_INFINITY) {
        rawImp.setDisplayRange(min, max);
    }

    rawMean = profile[0];
    rawSd = profile[1];

    // Check if there are fitted results in memory
    addCandidateFrames(imp.getTitle());

    updateProfilePlots();

    if (blur > 0) {
        IJ.showStatus("Calculating blur ...");

        ImageStack stack = imp.getImageStack();
        ImageStack newStack = new ImageStack(stack.getWidth(), stack.getHeight(), stack.getSize());
        // Multi-thread the blur stage
        ExecutorService threadPool = Executors.newFixedThreadPool(Prefs.getThreads());
        List<Future<?>> futures = new LinkedList<Future<?>>();

        Utils.setShowProgress(false);
        blurCount = 0;
        // TODO - See if this is faster if processing multiple slices in each worker
        int slices = 5;
        for (int n = 1; n <= nSlices; n += slices) {
            futures.add(threadPool.submit(new BlurWorker(stack, n, slices, bounds, blur * psfWidth, newStack)));
        }

        IJ.showStatus("Calculating blur ... Finishing");
        Utils.waitForCompletion(futures);
        threadPool.shutdown();
        Utils.setShowProgress(false);
        IJ.showStatus("Calculating blur ... Drawing");

        ImageStack blurSpot = new ImageStack(bounds.width, bounds.height, nSlices);
        extractSpotProfile(new ImagePlus("Blur", newStack), bounds, blurSpot);
        // Retain the existing display range
        max = Double.POSITIVE_INFINITY;
        if (blurImp != null) {
            min = blurImp.getDisplayRangeMin();
            max = blurImp.getDisplayRangeMax();
        }
        blurImp = showSpot(blurSpotTitle, blurSpot);
        if (max != Double.POSITIVE_INFINITY) {
            blurImp.setDisplayRange(min, max);
        }
        IJ.showStatus("");
    } else {
        blurImp = null;
    }

    // Add a z-projection of the blur/original image
    ZProjector project = new ZProjector((blurImp == null) ? rawImp : blurImp);
    project.setMethod(ZProjector.AVG_METHOD);
    project.doProjection();
    showSpot(avgSpotTitle, project.getProjection().getImageStack());

    if (!candidateFrames.isEmpty())
        // Set the first candidate frame
        rawImp.setSlice(candidateFrames.get(0));
    else
        updateCurrentSlice(rawImp.getCurrentSlice());

    IJ.showStatus("");
}