Class JDialogAAMClassificationExt

All Implemented Interfaces:
AlgorithmInterface, DialogDefaultsInterface, ActionListener, FocusListener, ItemListener, WindowListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants

public class JDialogAAMClassificationExt extends JDialogBase implements AlgorithmInterface
The class is the driver for the AAM classification. User specifies the AAM trained Atlas directory and target image. The algorithm performs NMI based similarity measure between each 2D slice in target image and the 2D slices atlas, find the closed image, then invoke the corresponding AAM model to do automatic segmentation on prostate MRI image.
Author:
Ruida Cheng
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • UI

      private ViewUserInterface UI
      The main user interface.
    • model

      private C_AAMMODEL model
      AAM model reference.
    • labelModel

      private JLabel labelModel
      key image directory.
    • textFieldModel

      private JTextField textFieldModel
    • buttonModel

      private JButton buttonModel
    • labelImageTarget

      private JLabel labelImageTarget
      Target image directory.
    • textFieldImageTarget

      private JTextField textFieldImageTarget
    • buttonImageTarget

      private JButton buttonImageTarget
    • imageSelectionPanel

      private JPanel imageSelectionPanel
    • buttonPanel

      private JPanel buttonPanel
    • modelChooser

      private JFileChooser modelChooser
      key images variables.
    • modelDirectory

      private String modelDirectory
    • targetImageChooser

      private JFileChooser targetImageChooser
      target image variables.
    • targetImageName

      private String targetImageName
    • targetImageDirectory

      private String targetImageDirectory
    • targetImage

      private ModelImage targetImage
    • cropTargetImage

      private ModelImage cropTargetImage
    • boxYmin

      private int boxYmin
      Cropped image region.
    • boxYmax

      private int boxYmax
      Cropped image region.
    • boxXmin

      private int boxXmin
    • boxXmax

      private int boxXmax
    • xBounds

      private int[] xBounds
      Cropped region bounding.
    • yBounds

      private int[] yBounds
    • zBounds

      private int[] zBounds
    • axisList

      private JComboBox axisList
      axis region
    • labelAxis

      private JLabel labelAxis
    • Axial

      private static int Axial
      axis orientation. Will be used later.
    • Saggital

      private static int Saggital
    • Coronal

      private static int Coronal
    • axis

      private int axis
    • shapeVector

    • sampleImage

      private ModelImage sampleImage
    • groupTable

    • groupRefImages

      private Hashtable<Integer,Vector<ModelImage>> groupRefImages
    • groupCropImages

      private Hashtable<Integer,Vector<ModelImage>> groupCropImages
    • markedVOI

      private Hashtable<Integer,Integer> markedVOI
    • shapeDescriptor

    • statData

      private Vector<Vector<Float>> statData
    • statsToCalculate

      private static final String[] statsToCalculate
    • checkList

      private static final boolean[] checkList
    • mainPanel

      private JPanel mainPanel
    • startSlice

      private int startSlice
    • endSlice

      private int endSlice
    • endSliceImageNames

      private Vector<String> endSliceImageNames
    • endSliceRangeNames

      private Vector<String> endSliceRangeNames
    • endSliceImages

      private Vector<ModelImage> endSliceImages
    • endSliceRange

      private Vector<JDialogAAMClassificationExt.Range> endSliceRange
    • keyImageVector

      private Vector<String> keyImageVector
      image vector to hold the image names.
    • keyImages

      private Vector<ModelImage> keyImages
      image vector to hold the actual images.
    • testImageDir

      private String testImageDir
  • Constructor Details

    • JDialogAAMClassificationExt

      public JDialogAAMClassificationExt(Frame theParentFrame)
      Constructor. the parent frame
      Parameters:
      theParentFrame -
  • Method Details

    • algorithmPerformed

      public void algorithmPerformed(AlgorithmBase algorithm)
      Description copied from interface: AlgorithmInterface
      Called after an algorithm this listener is registered to exits (maybe successfully, maybe not). If the algorithm is run in a separate thread, this call will be made within that thread. If not, this call will be made from that same, shared thread.
      Specified by:
      algorithmPerformed in interface AlgorithmInterface
      Parameters:
      algorithm - the algorithm which has just completed
    • actionPerformed

      public void actionPerformed(ActionEvent event)
      actionPerformed handler.
      Specified by:
      actionPerformed in interface ActionListener
      Overrides:
      actionPerformed in class JDialogBase
    • loadFiles

      public void loadFiles()
      load image files and voi files
    • readFile

      public void readFile()
    • traverse_80

      private void traverse_80(File dir)
    • processDir_80

      private void processDir_80(File dir)
    • createTargetDialog

      public void createTargetDialog()
      First time this dialog is called, init() will be called to create the GUI. When user choose the dialog again, we don't need to reload the AAM atlas model again. So, we create this target dialog to allow user to just select the target image for AAM classification.
    • init

      public void init()
      Init() function to create the GUI dialog.
    • quickSegmentation

      public void quickSegmentation()
      After the first time the dialog is invoked, when user select the AAM segmentation from the menu item, the quick segmentation function is called to do the AAM classification. It omits the AAM atlas model re-loading procedure.
    • doSegmentation

      public void doSegmentation()
      First time the dialog called, this function is invoked to do segmentation.
    • evaluateShapeDescriptor

      public void evaluateShapeDescriptor()
      Evaluate the auto segmentation generated VOIs shapes.
    • getStatsData

      private Vector<Vector<String>> getStatsData(Vector<VOIStatisticalProperties> statsList, VOIVector VOIs, ModelImage img)
      Generate the VOI shape statistics.
      Parameters:
      statsList - VOI statistic properties carry out by MIPAV
      VOIs - VOIs contours
      img - image
      Returns:
      statistic data vetor.
    • computeShapeDescriptor

      public void computeShapeDescriptor()
      Compute the shape descriptor with roundness, compactness, aspectRatio, and eccentricity.
    • markErrorOne

      public void markErrorOne()
      Go through the auto segmented VOIs, filter out the irregular shape or wrong shapes. Mark those shapes with flag 1 to indicating the replacement.
    • transformVOI

      public void transformVOI()
      BSpline smooth the final auto segmentation VOI contours.
    • fixErrorVOI

      public void fixErrorVOI()
      Replace the irregular shape or wrong shape VOI with adjacent neighbor VOI.
    • checkEndSlices

      public void checkEndSlices()
      From the target 2D slice, compare it with end slices based atlas. Find the closed 2D slice image, and invoke the corresponding start and ending VOI index. This step is important, which eliminates the segmentation error toward apex and base to certain extents. There are still changes that apex and base ending index miss interpolated, resulting in the wrong segmentation. We need to improve this later.
    • segmentationAuto

      public void segmentationAuto()
      Driver to do the auto segmenation with AAM model.
    • cropImage

      public void cropImage()
      When we to NMI based image similarity measure, we crop the prostate 2D slice image first, then apply the measure. Two advantages, 1) cropped region focus on the central gland region of prostate, 2) cropped region comparison is much faster that the whole image slice (512x512) based comparison, yelding relative accurate NMI comparison results.
    • findBestImageNMI

      private void findBestImageNMI(int targetImageSliceNumber, int[] bestImageNumber, int[] bestSliceNumber)
      NMI based 2D slice image similarity measure. For each target image 2D slice, we use NMI to search the best match image 2D slice. The search range is 3 slices around the current 2D slice index. When find the best slice, we record it, and invoke the corresponding AAM Model to do segmentation.
      Parameters:
      targetImageSliceNumber - target image
      bestImageNumber - best match image number
      bestSliceNumber - best match slice number.
    • cropTargetImage

      public ModelImage cropTargetImage()
      Crop the target image 2D slice to focus on central gland.
      Returns:
    • updateTargetImage

      public void updateTargetImage(int sliceNumber, ModelImage targetImageSlice)
      After auto segmentation, update the target image with corresponding segmented VOIs.
      Parameters:
      sliceNumber - slice number.
      targetImageSlice - 2D target image slice.
    • pause

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

      public void readImagesAndVOIs()
      read target image.
    • readTargetImage

      private void readTargetImage()
      File chooser to select target image directory.
    • readEndingSlicesDir

      private void readEndingSlicesDir()
      Read the ending slice index to guide the segmentation towards apex and base.
    • processingEndSliceData

      private void processingEndSliceData(String endSliceModelDir)
      Process the ending slice atlas directory.
      Parameters:
      endSliceModelDir - atlas directory.
    • readKeyImageDir

      private void readKeyImageDir()
      Read the AAM atlas directory.
    • readEndingSlice

      private void readEndingSlice()
      update the ending slices.
    • readSampleImages

      private void readSampleImages()
      When read the AAM model atlas, read corresponding pivot images from atlas direction. This pivot 2D image slice will guide the NMI similarity searching.
    • processingData

      private void processingData(String modelDir)
      Process AAM atlas directory.
      Parameters:
      modelDir -
    • traverse

      private void traverse(File dir)
      Recursivly traverse the AAM atlas directory.
      Parameters:
      dir -
    • processDir

      private void processDir(File dir, Vector<JDialogAAMClassificationExt.ModelString> modelNameVector)
      Process dir, read AAM model and pivot images.
      Parameters:
      dir -
      modelNameVector -
    • disposeLocal

      public void disposeLocal()