Ejemplo n.º 1
0
  /** Calls the algorithm. */
  protected void callAlgorithm() {

    try {
      resultImage =
          new ModelImage(imageA.getType(), imageA.getExtents(), (imageA.getImageName() + "_isn"));
      resultImage.copyFileTypeInfo(imageA);

      // Make algorithm
      isnAlgo = new PlugInAlgorithmISN(resultImage, imageA);

      // This is very important. Adding this object as a listener allows the algorithm to
      // notify this object when it has completed of failed. See algorithm performed event.
      // This is made possible by implementing AlgorithmedPerformed interface
      isnAlgo.addListener(this);

      createProgressBar(imageA.getImageName(), " ...", isnAlgo);

      // Hide dialog
      setVisible(false);

      if (isRunInSeparateThread()) {

        // Start the thread as a low priority because we wish to still have user interface work
        // fast.
        if (isnAlgo.startMethod(Thread.MIN_PRIORITY) == false) {
          MipavUtil.displayError("A thread is already running on this object");
        }
      } else {
        isnAlgo.run();
      }
    } catch (OutOfMemoryError x) {
      System.gc();
      MipavUtil.displayError("AlgorithmAbsoluteValue: unable to allocate enough memory");

      return;
    }
  }
Ejemplo n.º 2
0
  /** Starts the program. */
  public void runAlgorithm() {

    if ((srcImage1 == null) || (srcImage2 == null) || (destImage == null)) {
      displayError("Source Image(s) is null");
      setCompleted(false);

      return;
    }

    if (srcImage1.getType() != srcImage2.getType()) {
      displayError("Source Images must be of the same data type.");
      setCompleted(false);

      return;
    }

    float[] resols1 = srcImage1.getResolutions(0);
    float[] resols2 = srcImage2.getResolutions(0);

    if ((srcImage1.getNDims() == 2) && (srcImage2.getNDims() == 2)) {
      if (resols1[0] == resols2[0] && resols1[1] == resols2[1]) {
        cat2D_2D_3D();
      } else {
        displayError("Resolutions must match up");
        setCompleted(false);
        return;
      }

    } else if (((srcImage1.getNDims() == 2) && (srcImage2.getNDims() == 3))
        || ((srcImage1.getNDims() == 3) && (srcImage2.getNDims() == 2))) {
      if (resols1[0] == resols2[0] && resols1[1] == resols2[1]) {
        cat2D_3D_3D();
      } else {
        displayError("Resolutions must match up");
        setCompleted(false);
        return;
      }
    } else if ((srcImage1.getNDims() == 3)
        && (srcImage2.getNDims() == 3)
        && (destImage.getNDims() == 3)) {
      if (resols1[0] == resols2[0] && resols1[1] == resols2[1] && resols1[2] == resols2[2]) {
        cat3D_3D_3D();
      } else {
        displayError("Resolutions must match up");
        setCompleted(false);
        return;
      }
    } else if ((srcImage1.getNDims() == 3)
        && (srcImage2.getNDims() == 3)
        && (destImage.getNDims() == 4)) {
      if (resols1[0] == resols2[0] && resols1[1] == resols2[1] && resols1[2] == resols2[2]) {
        cat3D_3D_4D();
      } else {
        displayError("Resolutions must match up");
        setCompleted(false);
        return;
      }
    } else if (((srcImage1.getNDims() == 3) && (srcImage2.getNDims() == 4))
        || ((srcImage1.getNDims() == 4) && (srcImage2.getNDims() == 3))) {
      if (resols1[0] == resols2[0] && resols1[1] == resols2[1] && resols1[2] == resols2[2]) {
        cat3D_4D_4D();
      } else {
        displayError("Resolutions must match up");
        setCompleted(false);
        return;
      }

    } else if ((srcImage1.getNDims() == 4) && (srcImage2.getNDims() == 4)) {
      if (resols1[0] == resols2[0]
          && resols1[1] == resols2[1]
          && resols1[2] == resols2[2]
          && resols1[3] == resols2[3]) {
        cat4D_4D_4D();
      } else {
        displayError("Resolutions must match up");
        setCompleted(false);
        return;
      }
    } else {
      displayError("Source Image(s) dimensionality not supported.");
    }
  }
Ejemplo n.º 3
0
  /**
   * Once all the necessary variables are set, call the Concat algorithm based on what type of image
   * this is and whether or not there is a separate destination image.
   */
  protected void callAlgorithm() {
    int destExtents[] = new int[3];
    ModelImage destImage = null;

    destExtents[0] = subXDim;
    destExtents[1] = subYDim;
    destExtents[2] = numberOfImagesInMosaic;

    destImage =
        new ModelImage(
            image.getType(), destExtents, makeImageName(image.getImageName(), "_mosaic_to_slices"));

    try {

      // Make algorithm
      mathAlgo = new AlgorithmMosaicToSlices(image, destImage);

      // This is very important. Adding this object as a listener allows the algorithm to
      // notify this object when it has completed of failed. See algorithm performed event.
      // This is made possible by implementing AlgorithmedPerformed interface
      mathAlgo.addListener(this);

      createProgressBar(image.getImageName(), mathAlgo);

      // Hide dialog
      setVisible(false);

      if (displayLoc == REPLACE) {

        // These next lines set the titles in all frames where the source image is displayed to
        // "locked - " image name so as to indicate that the image is now read/write locked!
        // The image frames are disabled and then unregisted from the userinterface until the
        // algorithm has completed.
        Vector<ViewImageUpdateInterface> imageFrames = image.getImageFrameVector();
        titles = new String[imageFrames.size()];

        for (int i = 0; i < imageFrames.size(); i++) {
          titles[i] = ((Frame) (imageFrames.elementAt(i))).getTitle();
          ((Frame) (imageFrames.elementAt(i))).setTitle("Locked: " + titles[i]);
          ((Frame) (imageFrames.elementAt(i))).setEnabled(false);
          userInterface.unregisterFrame((Frame) (imageFrames.elementAt(i)));
        }
      }

      if (isRunInSeparateThread()) {

        // Start the thread as a low priority because we wish to still have user interface work
        // fast.
        if (mathAlgo.startMethod(Thread.MIN_PRIORITY) == false) {
          MipavUtil.displayError("A thread is already running on this object");
        }

      } else {

        mathAlgo.run();
      }
    } catch (OutOfMemoryError x) {
      System.gc();
      MipavUtil.displayError("Dialog Concatenation: unable to allocate enough memory");

      return;
    }
  }