Class JDialogAAMClassification
- 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.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 gov.nih.mipav.view.dialogs.JDialogBase
JDialogBase.CancelAction, JDialogBase.HelpAction, JDialogBase.OKAction
-
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
-
-
Field Summary
Fields Modifier and Type Field Description private static int
Axial
axis orientation.private int
axis
private javax.swing.JComboBox
axisList
axis regionprivate int
boxXmax
private int
boxXmin
private int
boxYmax
Cropped image region.private int
boxYmin
Cropped image region.private javax.swing.JButton
buttonImageTarget
private javax.swing.JButton
buttonModel
private javax.swing.JPanel
buttonPanel
private static boolean[]
checkList
private static int
Coronal
private ModelImage
cropTargetImage
private int
endSlice
private java.util.Vector<java.lang.String>
endSliceImageNames
private java.util.Vector<ModelImage>
endSliceImages
private java.util.Vector<JDialogAAMClassification.Range>
endSliceRange
private java.util.Vector<java.lang.String>
endSliceRangeNames
private java.util.Hashtable<java.lang.Integer,java.util.Vector<ModelImage>>
groupCropImages
private java.util.Hashtable<java.lang.Integer,java.util.Vector<ModelImage>>
groupRefImages
private java.util.Hashtable<java.lang.Integer,java.util.Vector<JDialogAAMClassification.ModelString>>
groupTable
private javax.swing.JPanel
imageSelectionPanel
private javax.swing.JLabel
labelAxis
private javax.swing.JLabel
labelImageTarget
Target image directory.private javax.swing.JLabel
labelModel
key image directory.private javax.swing.JPanel
mainPanel
private java.util.Hashtable<java.lang.Integer,java.lang.Integer>
markedVOI
private C_AAMMODEL
model
AAM model reference.private javax.swing.JFileChooser
modelChooser
key images variables.private java.lang.String
modelDirectory
private static int
Saggital
private ModelImage
sampleImage
private static long
serialVersionUID
private java.util.Vector<JDialogAAMClassification.ShapeFactor>
shapeDescriptor
private java.util.Vector<JDialogAAMClassification.PolygonShapeInfo>
shapeVector
private int
startSlice
private java.util.Vector<java.util.Vector<java.lang.Float>>
statData
private static java.lang.String[]
statsToCalculate
private ModelImage
targetImage
private javax.swing.JFileChooser
targetImageChooser
target image variables.private java.lang.String
targetImageDirectory
private java.lang.String
targetImageName
private javax.swing.JTextField
textFieldImageTarget
private javax.swing.JTextField
textFieldModel
private ViewUserInterface
UI
The main user interface.private int[]
xBounds
Cropped region bounding.private int[]
yBounds
private int[]
zBounds
-
Fields inherited from class gov.nih.mipav.view.dialogs.JDialogBase
applyButton, bar, cancelButton, cancelFlag, closeButton, HELP, helpButton, mainDialogPanel, NEW, OKButton, parentFrame, progressBar, REPLACE, runInSeparateThread, runningScriptFlag, runQuiet, serif12, serif12B, voiManager
-
Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
-
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
-
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 gov.nih.mipav.view.dialogs.JDialogBase
buildApplyButton, buildButtons, buildCancelButton, buildCancelButton, buildCloseButton, buildHelpButton, buildImageComboBox, buildOKButton, buildOKButton, buildOKCancelButtons, buildTitledBorder, buildTitledBorder, createLabel, createProgressBar, createProgressBar, createTextField, focusGained, focusLost, getDialogName, isCancelled, isQuietRunning, isRunInSeparateThread, isScriptRunning, itemStateChanged, loadDefaults, loadDefaults, makeImageName, makeString, openNewFrame, saveDefaults, saveDefaults, setLeftHandSystem, setQuietRunning, setScriptRunning, setSeparateThread, setVisible, setVisible, setVisibleMenuBar, setVisibleStandard, setVOIManager, setWCSystem, testParameter, testParameterMin, updateFFTFileInfo, updateFileInfo, updateFileInfoOtherModality, updateFileInfoStatic, updateFileInfoStatic, updateFileTypeInfo, updateFileTypeInfo, windowActivated, windowClosed, windowClosing, windowDeactivated, windowDeiconified, windowIconified, windowOpened
-
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
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
UI
private ViewUserInterface UI
The main user interface.
-
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
-
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 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
-
shapeVector
private java.util.Vector<JDialogAAMClassification.PolygonShapeInfo> shapeVector
-
sampleImage
private ModelImage sampleImage
-
groupTable
private java.util.Hashtable<java.lang.Integer,java.util.Vector<JDialogAAMClassification.ModelString>> groupTable
-
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
-
shapeDescriptor
private java.util.Vector<JDialogAAMClassification.ShapeFactor> shapeDescriptor
-
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
-
endSliceRange
private java.util.Vector<JDialogAAMClassification.Range> endSliceRange
-
-
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 interfaceAlgorithmInterface
- Parameters:
algorithm
- the algorithm which has just completed
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent event)
actionPerformed handler.- Specified by:
actionPerformed
in interfacejava.awt.event.ActionListener
- Overrides:
actionPerformed
in classJDialogBase
-
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 MIPAVVOIs
- VOIs contoursimg
- 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 imagebestImageNumber
- best match image numberbestSliceNumber
- 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()
-
-