Class JDialogAAMClassification

  • All Implemented Interfaces:
    AlgorithmInterface, DialogDefaultsInterface, java.awt.event.ActionListener, java.awt.event.FocusListener, java.awt.event.ItemListener, java.awt.event.WindowListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants

    public class JDialogAAMClassification
    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:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      (package private) class  JDialogAAMClassification.ModelString  
      (package private) class  JDialogAAMClassification.PolygonShapeInfo
      Polygon shape info class to do shape comparison after the AAM classification applied to do the segmentation.
      (package private) class  JDialogAAMClassification.Range
      Ending slice start and end indexes.
      (package private) class  JDialogAAMClassification.ShapeFactor
      shape descriptor class.
      • Nested classes/interfaces inherited from class javax.swing.JDialog

        javax.swing.JDialog.AccessibleJDialog
      • Nested classes/interfaces inherited from class java.awt.Dialog

        java.awt.Dialog.AccessibleAWTDialog, java.awt.Dialog.ModalExclusionType, java.awt.Dialog.ModalityType
      • Nested classes/interfaces inherited from class java.awt.Window

        java.awt.Window.AccessibleAWTWindow, java.awt.Window.Type
      • Nested classes/interfaces inherited from class java.awt.Container

        java.awt.Container.AccessibleAWTContainer
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
    • Constructor Summary

      Constructors 
      Constructor Description
      JDialogAAMClassification​(java.awt.Frame theParentFrame)
      Constructor. the parent frame
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void actionPerformed​(java.awt.event.ActionEvent event)
      actionPerformed handler.
      void algorithmPerformed​(AlgorithmBase algorithm)
      Called after an algorithm this listener is registered to exits (maybe successfully, maybe not).
      void checkEndSlices()
      From the target 2D slice, compare it with end slices based atlas.
      void computeShapeDescriptor()
      Compute the shape descriptor with roundness, compactness, aspectRatio, and eccentricity.
      void createTargetDialog()
      First time this dialog is called, init() will be called to create the GUI.
      void cropImage()
      When we to NMI based image similarity measure, we crop the prostate 2D slice image first, then apply the measure.
      ModelImage cropTargetImage()
      Crop the target image 2D slice to focus on central gland.
      void disposeLocal()  
      void doSegmentation()
      First time the dialog called, this function is invoked to do segmentation.
      void evaluateShapeDescriptor()
      Evaluate the auto segmentation generated VOIs shapes.
      private void findBestImageNMI​(int targetImageSliceNumber, int[] bestImageNumber, int[] bestSliceNumber)
      NMI based 2D slice image similarity measure.
      void fixErrorVOI()
      Replace the irregular shape or wrong shape VOI with adjacent neighbor VOI.
      private java.util.Vector<java.util.Vector<java.lang.String>> getStatsData​(java.util.Vector<VOIStatisticalProperties> statsList, VOIVector VOIs, ModelImage img)
      Generate the VOI shape statistics.
      void init()
      Init() function to create the GUI dialog.
      void markErrorOne()
      Go through the auto segmented VOIs, filter out the irregular shape or wrong shapes.
      static void pause()
      Pauses the display until the user hits enter.
      private void processDir​(java.io.File dir, java.util.Vector<JDialogAAMClassification.ModelString> modelNameVector)
      Process dir, read AAM model and pivot images.
      private void processingData​(java.lang.String modelDir)
      Process AAM atlas directory.
      private void processingEndSliceData​(java.lang.String endSliceModelDir)
      Process the ending slice atlas directory.
      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.
      private void readEndingSlice()
      update the ending slices.
      private void readEndingSlicesDir()
      Read the ending slice index to guide the segmentation towards apex and base.
      void readImagesAndVOIs()
      read target image.
      private void readKeyImageDir()
      Read the AAM atlas directory.
      private void readSampleImages()
      When read the AAM model atlas, read corresponding pivot images from atlas direction.
      private void readTargetImage()
      File chooser to select target image directory.
      void segmentationAuto()
      Driver to do the auto segmenation with AAM model.
      void transformVOI()
      BSpline smooth the final auto segmentation VOI contours.
      private void traverse​(java.io.File dir)
      Recursivly traverse the AAM atlas directory.
      void updateTargetImage​(int sliceNumber, ModelImage targetImageSlice)
      After auto segmentation, update the target image with corresponding segmented VOIs.
      • Methods inherited from class javax.swing.JDialog

        addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
      • Methods inherited from class java.awt.Dialog

        addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setBackground, setModal, setModalityType, setOpacity, setResizable, setShape, setTitle, setUndecorated, show, toBack
      • Methods inherited from class java.awt.Window

        addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, toFront
      • Methods inherited from class java.awt.Container

        add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTree
      • Methods inherited from class java.awt.Component

        action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • model

        private C_AAMMODEL model
        AAM model reference.
      • labelModel

        private javax.swing.JLabel labelModel
        key image directory.
      • textFieldModel

        private javax.swing.JTextField textFieldModel
      • buttonModel

        private javax.swing.JButton buttonModel
      • labelImageTarget

        private javax.swing.JLabel labelImageTarget
        Target image directory.
      • textFieldImageTarget

        private javax.swing.JTextField textFieldImageTarget
      • buttonImageTarget

        private javax.swing.JButton buttonImageTarget
      • imageSelectionPanel

        private javax.swing.JPanel imageSelectionPanel
      • buttonPanel

        private javax.swing.JPanel buttonPanel
      • modelChooser

        private javax.swing.JFileChooser modelChooser
        key images variables.
      • modelDirectory

        private java.lang.String modelDirectory
      • targetImageChooser

        private javax.swing.JFileChooser targetImageChooser
        target image variables.
      • targetImageName

        private java.lang.String targetImageName
      • targetImageDirectory

        private java.lang.String targetImageDirectory
      • 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 javax.swing.JComboBox axisList
        axis region
      • labelAxis

        private javax.swing.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
      • groupRefImages

        private java.util.Hashtable<java.lang.Integer,​java.util.Vector<ModelImage>> groupRefImages
      • groupCropImages

        private java.util.Hashtable<java.lang.Integer,​java.util.Vector<ModelImage>> groupCropImages
      • markedVOI

        private java.util.Hashtable<java.lang.Integer,​java.lang.Integer> markedVOI
      • statData

        private java.util.Vector<java.util.Vector<java.lang.Float>> statData
      • statsToCalculate

        private static final java.lang.String[] statsToCalculate
      • checkList

        private static final boolean[] checkList
      • mainPanel

        private javax.swing.JPanel mainPanel
      • startSlice

        private int startSlice
      • endSlice

        private int endSlice
      • endSliceImageNames

        private java.util.Vector<java.lang.String> endSliceImageNames
      • endSliceRangeNames

        private java.util.Vector<java.lang.String> endSliceRangeNames
      • endSliceImages

        private java.util.Vector<ModelImage> endSliceImages
    • Constructor Detail

      • JDialogAAMClassification

        public JDialogAAMClassification​(java.awt.Frame theParentFrame)
        Constructor. the parent frame
        Parameters:
        theParentFrame -
    • Method Detail

      • 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​(java.awt.event.ActionEvent event)
        actionPerformed handler.
        Specified by:
        actionPerformed in interface java.awt.event.ActionListener
        Overrides:
        actionPerformed in class JDialogBase
      • 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 java.util.Vector<java.util.Vector<java.lang.String>> getStatsData​(java.util.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​(java.lang.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​(java.lang.String modelDir)
        Process AAM atlas directory.
        Parameters:
        modelDir -
      • traverse

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

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

        public void disposeLocal()