/**
   * Use the GUI results to set up the variables needed to run the algorithm.
   *
   * @return <code>true</code> if parameters set successfully, <code>false</code> otherwise.
   */
  private boolean setVariables() {
    String tmpStr;
    int i;

    int totLength = image.getExtents()[0];

    for (i = 1; i < image.getNDims(); i++) {
      totLength *= image.getExtents()[i];
    }

    tmpStr = greenMergingText.getText();
    mergingDistance = Float.parseFloat(tmpStr);
    if (mergingDistance < 0.0f) {
      MipavUtil.displayError("Merging distance cannot be less than 0");
      greenMergingText.requestFocus();
      greenMergingText.selectAll();
      return false;
    }

    tmpStr = redMinText.getText();
    redMin = Integer.parseInt(tmpStr);

    if (redMin < 1) {
      MipavUtil.displayError("red minimum must be at least 1");
      redMinText.requestFocus();
      redMinText.selectAll();

      return false;
    } else if (redMin > totLength) {
      MipavUtil.displayError("red minimum must not exceed " + totLength);
      redMinText.requestFocus();
      redMinText.selectAll();

      return false;
    }

    tmpStr = redFractionText.getText();
    redFraction = Float.parseFloat(tmpStr);

    if (redFraction <= 0.0f) {
      MipavUtil.displayError("red fraction must be greater than zero");
      redFractionText.requestFocus();
      redFractionText.selectAll();

      return false;
    } else if (redFraction > 1.0f) {
      MipavUtil.displayError("red fraction must not exceed one");
      redFractionText.requestFocus();
      redFractionText.selectAll();

      return false;
    }

    tmpStr = greenMinText.getText();
    greenMin = Integer.parseInt(tmpStr);

    if (greenMin < 1) {
      MipavUtil.displayError("green minimum must be at least 1");
      greenMinText.requestFocus();
      greenMinText.selectAll();

      return false;
    } else if (greenMin > totLength) {
      MipavUtil.displayError("green minimum must not exceed " + totLength);
      greenMinText.requestFocus();
      greenMinText.selectAll();

      return false;
    }

    tmpStr = greenFractionText.getText();
    greenFraction = Float.parseFloat(tmpStr);

    if (greenFraction <= 0.0f) {
      MipavUtil.displayError("green fraction must be greater than zero");
      greenFractionText.requestFocus();
      greenFractionText.selectAll();

      return false;
    } else if (greenFraction > 1.0f) {
      MipavUtil.displayError("green fraction must not exceed one");
      greenFractionText.requestFocus();
      greenFractionText.selectAll();

      return false;
    }

    tmpStr = blueMinText.getText();
    blueMin = Integer.parseInt(tmpStr);
    if (blueMin <= 0) {
      MipavUtil.displayError("Number of blue pixels must be greater than 0");
      blueMinText.requestFocus();
      blueMinText.selectAll();
      return false;
    } else if (blueMin > totLength) {
      MipavUtil.displayError("blue minimum must not exceed " + totLength);
      blueMinText.requestFocus();
      blueMinText.selectAll();

      return false;
    }

    if (oneButton.isSelected()) {
      greenRegionNumber = 1;
    } else if (twoButton.isSelected()) {
      greenRegionNumber = 2;
    } else if (threeButton.isSelected()) {
      greenRegionNumber = 3;
    } else {
      greenRegionNumber = 4;
    }

    twoGreenLevels = twoBox.isSelected();

    tmpStr = blueValueText.getText();
    blueBoundaryFraction = Float.parseFloat(tmpStr);
    if (blueBoundaryFraction < 0.0f) {
      MipavUtil.displayError("Blue boundary fraction cannot be less than 0.0");
      blueValueText.requestFocus();
      blueValueText.selectAll();
      return false;
    } else if (blueBoundaryFraction > 1.0f) {
      MipavUtil.displayError("Blue boundary value cannot be greater than 1.0");
      blueValueText.requestFocus();
      blueValueText.selectAll();
      return false;
    }

    blueSmooth = blueSmoothBox.isSelected();

    tmpStr = interpolationText.getText();
    interpolationDivisor = Float.parseFloat(tmpStr);
    if (interpolationDivisor <= 1.0f) {
      MipavUtil.displayError("Interpolation divisor must be greater than 1");
      interpolationText.requestFocus();
      interpolationText.selectAll();
      return false;
    }

    return true;
  } // end setVariables()
  /**
   * Use the GUI results to set up the variables needed to run the algorithm.
   *
   * @return <code>true</code> if parameters set successfully, <code>false</code> otherwise.
   */
  private boolean setVariables() {
    String tmpStr;

    System.gc();

    if (replaceImage.isSelected()) {
      displayLoc = REPLACE;
    } else if (newImage.isSelected()) {
      displayLoc = NEW;
    }

    tmpStr = textSearchWindowSide.getText();

    if (testParameter(tmpStr, 5, 101)) {
      searchWindowSide = Integer.valueOf(tmpStr).intValue();
    } else {
      MipavUtil.displayError("Search window side must be between 5 and 101");
      textSearchWindowSide.requestFocus();
      textSearchWindowSide.selectAll();

      return false;
    }

    if ((searchWindowSide % 2) == 0) {
      MipavUtil.displayError("Search window side must be an odd number");
      textSearchWindowSide.requestFocus();
      textSearchWindowSide.selectAll();
      return false;
    }

    tmpStr = textSimilarityWindowSide.getText();

    if (testParameter(tmpStr, 3, 99)) {
      similarityWindowSide = Integer.valueOf(tmpStr).intValue();
    } else {
      MipavUtil.displayError("Similarity window side must be between 3 and 99");
      textSimilarityWindowSide.requestFocus();
      textSimilarityWindowSide.selectAll();

      return false;
    }

    if ((similarityWindowSide % 2) == 0) {
      MipavUtil.displayError("Similarity window side must be an odd number");
      textSimilarityWindowSide.requestFocus();
      textSimilarityWindowSide.selectAll();
      return false;
    }

    if (similarityWindowSide >= searchWindowSide) {
      MipavUtil.displayError("Similarity window side must be less than search window side");
      textSimilarityWindowSide.requestFocus();
      textSimilarityWindowSide.selectAll();
      return false;
    }

    tmpStr = textNoiseStandardDeviation.getText();

    if (testParameter(tmpStr, 0.001, 1000.0)) {
      noiseStandardDeviation = Float.valueOf(tmpStr).floatValue();
    } else {
      MipavUtil.displayError("Radius must be between 0.001 and 1000.0");
      textNoiseStandardDeviation.requestFocus();
      textNoiseStandardDeviation.selectAll();

      return false;
    }

    doRician = doRicianCheckBox.isSelected();

    if (doRician) {
      tmpStr = textDegree.getText();
      if (testParameter(tmpStr, 1.0, 10.0)) {
        degreeOfFiltering = Float.valueOf(tmpStr).floatValue();
      } else {
        MipavUtil.displayError("Degree of filtering must be between 1.0 and 10.0");
        textDegree.requestFocus();
        textDegree.selectAll();
      }
    }

    if (image.getNDims() > 2) {
      image25D = image25DCheckBox.isSelected();
    }

    return true;
  }
Exemplo n.º 3
0
  /**
   * Use the GUI results to set up the variables needed to run the algorithm.
   *
   * @return <code>true</code> if parameters set successfully, <code>false</code> otherwise.
   */
  private boolean setVariables() {
    String tmpStr;

    tmpStr = textXDim.getText();
    try {
      subXDim = Integer.parseInt(tmpStr);
    } catch (NumberFormatException e) {
      MipavUtil.displayError("New XDIM string is not a valid integer");
      textXDim.requestFocus();
      textXDim.selectAll();

      return false;
    }
    if (subXDim < 3) {
      MipavUtil.displayError("New XDIM must be at least 3");
      textXDim.requestFocus();
      textXDim.selectAll();

      return false;
    } else if (subXDim > image.getExtents()[0]) {
      MipavUtil.displayError("New XDIM cannot exceed " + image.getExtents()[0]);
      textXDim.requestFocus();
      textXDim.selectAll();

      return false;
    }

    tmpStr = textYDim.getText();
    try {
      subYDim = Integer.parseInt(tmpStr);
    } catch (NumberFormatException e) {
      MipavUtil.displayError("New YDIM string is not a valid integer");
      textYDim.requestFocus();
      textYDim.selectAll();

      return false;
    }
    if (subYDim < 3) {
      MipavUtil.displayError("New YDIM must be at least 3");
      textYDim.requestFocus();
      textYDim.selectAll();

      return false;
    } else if (subYDim > image.getExtents()[1]) {
      MipavUtil.displayError("New YDIM cannot exceed " + image.getExtents()[1]);
      textYDim.requestFocus();
      textYDim.selectAll();

      return false;
    }

    tmpStr = textNumberImages.getText();
    try {
      numberOfImagesInMosaic = Integer.parseInt(tmpStr);
    } catch (NumberFormatException e) {
      MipavUtil.displayError("New numberOfImagesInMosaic string is not a valid integer");
      textNumberImages.requestFocus();
      textNumberImages.selectAll();

      return false;
    }
    if (numberOfImagesInMosaic < 1) {
      MipavUtil.displayError("New numberOfImagesInMosaic must be at least 1");
      textNumberImages.requestFocus();
      textNumberImages.selectAll();

      return false;
    } else if (numberOfImagesInMosaic > (subXDim * subYDim)) {
      MipavUtil.displayError("New numberOfImagesInMosaic cannot exceed (newXDim) * (newYDim)");
      textNumberImages.requestFocus();
      textNumberImages.selectAll();

      return false;
    }

    displayLoc = NEW;

    return true;
  }