/**
   * Can be called with values[ 3 ], i.e. [initialsigma, sigma2, threshold] or values[ 2 ], i.e.
   * [initialsigma, threshold]
   *
   * <p>The results are stored in the same array. If called with values[ 2 ], sigma2 changing will
   * be disabled
   *
   * @param text - the text which is shown when asking for the file
   * @param values - the initial values and also contains the result
   * @param sigmaMax - the maximal sigma allowed by the interactive app
   * @return {@link InteractiveDoG} - the instance for querying additional parameters
   */
  public static InteractiveDoG getInteractiveDoGParameters(
      final ImagePlus imp, final int channel, final double values[], final float sigmaMax) {
    if (imp.isDisplayedHyperStack())
      imp.setPosition(imp.getStackIndex(channel + 1, imp.getNSlices() / 2 + 1, 1));
    else imp.setSlice(imp.getStackIndex(channel + 1, imp.getNSlices() / 2 + 1, 1));

    imp.setRoi(0, 0, imp.getWidth() / 3, imp.getHeight() / 3);

    final InteractiveDoG idog = new InteractiveDoG(imp, channel);
    idog.setSigmaMax(sigmaMax);
    idog.setLookForMaxima(defaultInteractiveMaxima);
    idog.setLookForMinima(defaultInteractiveMinima);

    if (values.length == 2) {
      idog.setSigma2isAdjustable(false);
      idog.setInitialSigma((float) values[0]);
      idog.setThreshold((float) values[1]);
    } else {
      idog.setInitialSigma((float) values[0]);
      idog.setThreshold((float) values[2]);
    }

    idog.run(null);

    while (!idog.isFinished()) SimpleMultiThreading.threadWait(100);

    if (values.length == 2) {
      values[0] = idog.getInitialSigma();
      values[1] = idog.getThreshold();
    } else {
      values[0] = idog.getInitialSigma();
      values[1] = idog.getSigma2();
      values[2] = idog.getThreshold();
    }

    // remove the roi
    imp.killRoi();

    defaultInteractiveMaxima = idog.getLookForMaxima();
    defaultInteractiveMinima = idog.getLookForMinima();

    return idog;
  }