Class JDialogProstateSegmentationRegBSpline3DFast

java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Dialog
javax.swing.JDialog
gov.nih.mipav.view.dialogs.JDialogBase
gov.nih.mipav.view.renderer.WildMagic.ProstateFramework.JDialogProstateSegmentationRegBSpline3DFast
All Implemented Interfaces:
AlgorithmInterface, DialogDefaultsInterface, ActionListener, FocusListener, ItemListener, WindowListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants

public class JDialogProstateSegmentationRegBSpline3DFast extends JDialogBase implements AlgorithmInterface
Semi-automatic MR Prostate segmentation - Registration guided segmentation model. The algorithm uses B-Spline registration to guide the MR prostate segmentation. Basic steps: 1) User open the axial, sagittal, coronal images in the MIPAV frame. 2) User manually outline the three contours on separate slices for each axial, sagittal, and coronal images to define the middle, the apex and the base of the prostate. 3) User click the OK button to let a fully automatic registration guided algorithm to segment the prostate of all the three images.
Author:
Ruida Cheng
See Also:
  • Field Details

    • UI

      private ViewUserInterface UI
      global user interface to get the three active images.
    • tracingSliceNumber

      private int tracingSliceNumber
      number of slices to trace, start from the apex and base VOIs
    • Axial

      private static int Axial
      Axial image type
    • Sagittal

      private static int Sagittal
      Sagittal image type
    • Coronal

      private static int Coronal
      Coronal image type
    • labelAxis

      private JLabel labelAxis
    • labelStartVOIAxial

      private JLabel labelStartVOIAxial
    • textFieldStartVOIAxial

      private JTextField textFieldStartVOIAxial
    • labelEndVOIAxial

      private JLabel labelEndVOIAxial
    • textFieldEndVOIAxial

      private JTextField textFieldEndVOIAxial
    • labelMidVOIAxial

      private JLabel labelMidVOIAxial
    • textFieldMidVOIAxial

      private JTextField textFieldMidVOIAxial
    • startVOIAxial

      int startVOIAxial
    • endVOIAxial

      int endVOIAxial
    • midVOIAxial

      int midVOIAxial
    • labelSagittal

      private JLabel labelSagittal
    • labelStartVOISagittal

      private JLabel labelStartVOISagittal
    • textFieldStartVOISagittal

      private JTextField textFieldStartVOISagittal
    • labelEndVOISagittal

      private JLabel labelEndVOISagittal
    • textFieldEndVOISagittal

      private JTextField textFieldEndVOISagittal
    • labelMidVOISagittal

      private JLabel labelMidVOISagittal
    • textFieldMidVOISagittal

      private JTextField textFieldMidVOISagittal
    • startVOISagittal

      int startVOISagittal
    • endVOISagittal

      int endVOISagittal
    • midVOISagittal

      int midVOISagittal
    • labelCoronal

      private JLabel labelCoronal
    • labelStartVOICoronal

      private JLabel labelStartVOICoronal
    • textFieldStartVOICoronal

      private JTextField textFieldStartVOICoronal
    • labelEndVOICoronal

      private JLabel labelEndVOICoronal
    • textFieldEndVOICoronal

      private JTextField textFieldEndVOICoronal
    • labelMidVOICoronal

      private JLabel labelMidVOICoronal
    • textFieldMidVOICoronal

      private JTextField textFieldMidVOICoronal
    • radioBSpline

      private JRadioButton radioBSpline
    • radioOAR

      private JRadioButton radioOAR
    • startVOICoronal

      private int startVOICoronal
    • endVOICoronal

      private int endVOICoronal
    • midVOICoronal

      private int midVOICoronal
    • imageAxial

      private ModelImage imageAxial
    • imageSagittal

      private ModelImage imageSagittal
    • imageCoronal

      private ModelImage imageCoronal
    • useBSpline

      private boolean useBSpline
      Flag to indicate to use B-Spline registration or OAR registration
  • Constructor Details

    • JDialogProstateSegmentationRegBSpline3DFast

      public JDialogProstateSegmentationRegBSpline3DFast(Frame theParentFrame)
      GUI interface for semi-automatic MR prostate segmentation.
      Parameters:
      theParentFrame - the MIPAV main frame.
  • Method Details

    • autoConfigVOIsNumbers

      public void autoConfigVOIsNumbers()
      After user manually draw the three VOIs on each axial, sagittal, coronal image, the drawn VOIs slices number is auto configured to appear in the dialog GUI interface.
    • configVOIsNumbers

      public void configVOIsNumbers(ModelImage image, int[] slices)
      Configure the mid, apex and base VOIs, sort them in order.
      Parameters:
      image - oringial MRI image
      slices - Slice array to store the mid, apex and base VOIs slice number.
    • actionPerformed

      public void actionPerformed(ActionEvent event)
      Just handle GUI button clicks event.
      Specified by:
      actionPerformed in interface ActionListener
      Overrides:
      actionPerformed in class JDialogBase
    • calculateVOIsVolume

      public void calculateVOIsVolume()
      Compute the VOIs binary mask based volumes.
    • printVolume

      public void printVolume(ModelImage srcImage, VOIVector voiVector, int viewOrientation)
      Print out the three VOIs volume in system console out.
      Parameters:
      srcImage - original MRI image
      voiVector - segmented resulting VOIs contours
      viewOrientation - view axis orientation: axial, or sagittal or coronal.
    • removeContourFromOtherOrientation

      public void removeContourFromOtherOrientation()
      User central gland contours projection to remove the extra interpolated VOIs contours at the apex and base. Parallel processing the algorithm with axial, sagittal and coronal images concurrently.
    • trimVOIsInSingleImage

      public Runnable trimVOIsInSingleImage(ModelImage image, int startVOI, int endVOI, Vector<WildMagic.LibFoundation.Mathematics.Vector3f> firstVOI, Vector<WildMagic.LibFoundation.Mathematics.Vector3f> secondVOI, int viewOrientation)
      In Dicom space, central contours projections to eliminate the extra contours at the apex and base. For example, axial image, project the sagittal, coronal VOIs onto the axial image Dicom space. The central gland part sagittal, coronal VOIs contours is projected on the axial image slices as points based contours. If there is no points on the corresponding axial image slice, however it has contour, the contour is eliminated.
      Parameters:
      image - original MRI image. i.e. axial image
      startVOI - apex VOI slice number
      endVOI - base VOI slice number
      firstVOI - sagittal image VOIs in Dicom space
      secondVOI - coronal image VOIs in Dicom space.
      viewOrientation - image axis orientation
      Returns:
    • removeVOIsInDicomSpace

      public void removeVOIsInDicomSpace(int zSlice, float zDicom, ModelImage image, Vector<WildMagic.LibFoundation.Mathematics.Vector3f> firstVOI, Vector<WildMagic.LibFoundation.Mathematics.Vector3f> secondVOI, int viewOrientation)
      Remove the extra VOIs contours in Dicom space.
      Parameters:
      zSlice - axial z slice number
      zDicom - z slice number corresponding Dicom value
      image - original MRI image
      firstVOI - sagittal VOI
      secondVOI - coronal VOI
      viewOrientation - view axis
    • convertVOIToDicomSpace

      public void convertVOIToDicomSpace(VOIVector src, Vector<WildMagic.LibFoundation.Mathematics.Vector3f> target, ModelImage image, int startSlice, int endSlice)
      Conver the VOIs from image space to Dicom space
      Parameters:
      src - source VOIs
      target - converted target VOIs
      image - original MRI image
      startSlice - starting slice
      endSlice - ending slice
    • createTask

      private Runnable createTask(ModelImage image, int midVOI, int startVOI, int endVOI)
      Parallel processing the automatic segmentation algorithm to all the three images concurrently.
      Parameters:
      image - original MRI image
      midVOI - mid slice VOI
      startVOI - apex slice VOI
      endVOI - base slice VOI
      axis - view axis
      Returns:
    • algorithmPerformed

      public void algorithmPerformed(AlgorithmBase algorithm)
      This method is required if the AlgorithmPerformed interface is implemented. It is called by the algorithms when it has completed or failed to to complete, so that the dialog can be display the result image and/or clean up.
      Specified by:
      algorithmPerformed in interface AlgorithmInterface
      Parameters:
      algorithm - Algorithm that caused the event.
    • pause

      public static void pause()
      Pauses the display until the user hits enter.
    • calculateCoherenceEnhancingDiffusion

      private ModelImage calculateCoherenceEnhancingDiffusion(ModelImage cropImage)
      Apply the coherence enhancing diffusion filter to the croppred MR image.
      Parameters:
      cropImage - cropped image
      Returns:
      the coherence enhancing diffusion image.
    • isVOIsCloseEnough

      private boolean isVOIsCloseEnough(int currentSlice, ModelImage resultImage, ModelImage refImage)
      Check the registration accuracy. Check to see if the registration runs into errors. Check criterion include VOI area, VOI center, etc. If area and center difference exceed specified threshold, registration runs into error.
      Parameters:
      currentSlice - current image slice
      resultImage - result image after registration
      refImage - registration reference slice
      Returns:
      true registration wrong, false, registration wrong.
    • smoothVOI50

      public void smoothVOI50(ModelImage resultImage)
      Convert the mask image to VOI with 50 points
      Parameters:
      resultImage - result image
      maskImage - binary mask image
    • smoothVOI120

      public void smoothVOI120(ModelImage resultImage)
      Convert the mask image to VOI with 120 points.
      Parameters:
      resultImage - result image
      maskImage - binary mask image
    • transformVOI

      public void transformVOI(ModelImage image, ModelImage resultImage, ModelImage refImage, ModelImage testImage, int[] boundingBox, int currentSlice)
      Transform the the resulting VOI from cropped image to oringal MR image.
      Parameters:
      image - original MR image
      resultImage - resulting image after segmentation
      boundingBox - cropped image bounding box
      currentSlice - current image slice
    • sortImageVOIs

      public void sortImageVOIs(ModelImage image)
      Sorting image VOI
      Parameters:
      image - original MR image
    • sortImageVOIsInit

      public void sortImageVOIsInit(ModelImage image, int midVOI, int startVOI, int endVOI)
      Sort the original MR image's specified VOIs
      Parameters:
      image - original MR image
      midVOI - mid slice VOI
      startVOI - apex slice VOI
      endVOI - base slice VOI
    • sortCEDImageVOIs

      public void sortCEDImageVOIs(ModelImage coherenceEnhancingDiffusionImage, int midVOI, int startVOI, int endVOI)
      Sort the CED image VOIs
      Parameters:
      coherenceEnhancingDiffusionImage - CED image
      midVOI - mid slice VOI
      startVOI - apex slice VOI
      endVOI - base slice VOI
    • doFuzzyCmean

      public void doFuzzyCmean(ModelImage coherenceEnhancingDiffusionImage, Vector<Vector<ModelImage>> imageStackFuzzyC)
      Generate the Fuzzy-C means classes from the CED image
      Parameters:
      coherenceEnhancingDiffusionImage - CED image
      imageStackFuzzyC - Fuzzy-C means classes image stack.
    • getCentroids

      private float[] getCentroids(ModelImage srcImage, AlgorithmFuzzyCMeans fcmAlgo, float[] centroids)
      Gets the minimum and maximum of each image and initializes the centroids dialog appropriately.
      Returns:
      Flag indicating a successful get.
    • doRegistrationMid

      public void doRegistrationMid(ModelImage image, ModelImage coherenceEnhancingDiffusionImage, Vector<Vector<ModelImage>> imageStackFuzzyC, int midVOI, int startVOI, int endVOI, int[] boundingBox)
      The proposed model uses 2D registration to register 2D slices from the middle slice to the adjacent slice. It then generates a new VOI, and takes the VOI as the new initial estimate for the next slice in the series. This process is then iteratively propagated in both forward and backward directions.
      Parameters:
      image - original MR image
      coherenceEnhancingDiffusionImage - coherence enhance diffusion filter
      imageStackFuzzyC - Fuzzy-C segmentation stack
      midVOI - mid slice VOI
      startVOI - apex slice VOI
      endVOI - base slice VOI
      boundingBox - Cropped image bounding box
      axis - axis orientation
    • doRegistrationStart

      public void doRegistrationStart(ModelImage image, ModelImage coherenceEnhancingDiffusionImage, Vector<Vector<ModelImage>> imageStackFuzzyC, int startVOI, int[] boundingBox)
      Near the apex, apex contour starts as the initial estimate, and repeat the same process toward the end slices.
      Parameters:
      image - original MR image
      coherenceEnhancingDiffusionImage - coherence enhance diffusion filter
      imageStackFuzzyC - Fuzzy-C segmentation stack
      startVOI - apex starting slice VOI number
      boundingBox - Cropped image bounding box
      axis - axis orientation
    • doRegistrationEnd

      public void doRegistrationEnd(ModelImage image, ModelImage coherenceEnhancingDiffusionImage, Vector<Vector<ModelImage>> imageStackFuzzyC, int endVOI, int[] boundingBox)
      Near the base, base contour starts as the initial estimate, and repeat the same process toward the end slices.
      Parameters:
      image - original MR image
      coherenceEnhancingDiffusionImage - coherence enhance diffusion filter
      imageStackFuzzyC - Fuzzy-C segmentation stack
      boundingBox - Cropped image bounding box
      startVOI - apex starting slice VOI number
      axis - axis orientation
    • adjustVOIs

      public void adjustVOIs(ModelImage image)
      When user draws the 3 VOIs out of order, adjust the VOIs in ascending order
      Parameters:
      image - source image, axial, sagittal or coronal
    • cropROI

      public ModelImage cropROI(ModelImage image, int[] xBounds, int[] yBounds, int[] zBounds, int[] boundingBox, int midVOI)
      Crop MR image with specified X, Y, Z bounds Use the mid slice as the initial guidance to find the bounds.
      Parameters:
      image - Original MR image
      xBounds - X bounds
      yBounds - Y bounds
      zBounds - Z bounds
      boundingBox - Cropped region rounding box
      midVOI - mid slice VOI
      Returns:
    • init

      public void init()
      Create the dialog interface.