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

public class JDialogAAMplusSVM extends JDialogBase implements AlgorithmInterface
This class is the combined Atlas based AAM and SVM model to automatically segment the MRI prostate. Atlas based AAM model initializes the coarser level VOI contour, then atlas based SVM model refines the prostate boundary. With the new image ( target image ), the AAM model try different pose configurations ( scale, translation, rotation, etc ) to find the closest VOI contour. This contour is the initialization contour to the SVM model. The SVM model generate the non-prostate regions and prostate boundary binary mask images. By copying the initial contour to non-prostate and prostate boundary images, and Coherence Enhanced Diffusion (CED) image, a dynamic narrow band tracing algorithm stretches the initial contour toward the correct prostate boundary based on a voting mechanism from the three images.
Author:
Ruida Cheng
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • featureArray

      private Features[] featureArray
    • featureArraySVM

      private FeaturesSVM[] featureArraySVM
    • 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
      image panel.
    • 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
      target image references.
    • cropTargetImage

      private ModelImage cropTargetImage
    • boxYmin

      private int boxYmin
      cropped image boundary info.
    • boxYmax

      private int boxYmax
      cropped image boundary info.
    • boxXmin

      private int boxXmin
    • boxXmax

      private int boxXmax
    • xBounds

      private int[] xBounds
    • yBounds

      private int[] yBounds
    • zBounds

      private int[] zBounds
    • axisList

      private JComboBox axisList
      axis panel.
    • labelAxis

      private JLabel labelAxis
    • Axial

      private static int Axial
      axis oritentation.
    • Saggital

      private static int Saggital
    • Coronal

      private static int Coronal
    • axis

      private int axis
    • sampleImage

      private ModelImage sampleImage
    • groupTable

    • groupRefImages

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

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

      private JFileChooser svmModelChooser
      SVM model panel.
    • svmModelName

      private String svmModelName
    • svmModelDirectory

      private String svmModelDirectory
    • labelSVMModel

      private JLabel labelSVMModel
    • textFieldSVMModel

      private JTextField textFieldSVMModel
    • buttonSVMModel

      private JButton buttonSVMModel
    • modelStructure

      SVM model vector.
    • sortModelStructure

      SVM model vector after sorted by name.
    • models

      SVM model.
    • modelsSVM

      SVM model vector.
    • finalImage

      private ModelImage finalImage
    • voiVectorNewFinal

      private VOIVector voiVectorNewFinal
    • voiNewFinal

      private VOI voiNewFinal
    • markedVOI

      private Hashtable<Integer,Integer> markedVOI
      VOI vector to fix the wrong segmentation contour after AAM segmentation.
    • shapeDescriptor

      private Vector<JDialogAAMplusSVM.ShapeFactor> shapeDescriptor
      shape descriptor vector of VOI contours after AAM segmentation.
    • statData

      private Vector<Vector<Float>> statData
      statistic data corresponding to marked VOI vector.
    • statsToCalculate

      private static final String[] statsToCalculate
      MIPAV VOI properties parameters.
    • mainPanel

      private JPanel mainPanel
    • featureDirName

      private static final String featureDirName
      See Also:
    • startSlice

      private int startSlice
      Current segmentation processing slice range, which is between silce 3 and 20. This constraint is imposed by the SVM training model. Due to the manual drawing the non-prostate regions for SVM training, the human guided training process is time consuming. Currently, we only train the SVM models from slice 3 to slice 20. Later, if we have time, we will apply to more slices.
    • endSlice

      private int endSlice
    • checkList

      private static final boolean[] checkList
      VOI properties check list.
    • endSliceImageNames

      private Vector<String> endSliceImageNames
      Ending slice check references for apex and base.
    • endSliceRangeNames

      private Vector<String> endSliceRangeNames
    • endSliceImages

      private Vector<ModelImage> endSliceImages
    • endSliceRange

      private Vector<JDialogAAMplusSVM.Range> endSliceRange
  • Constructor Details

    • JDialogAAMplusSVM

      public JDialogAAMplusSVM(Frame theParentFrame)
      Constructor
      Parameters:
      theParentFrame - parent frame reference.
  • 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
    • init

      public void init()
      GUI panel initialization.
    • createTargetDialog

      public void createTargetDialog()
      First time, the dialog is invoked, the init() method is called to create the GUI. Afterward, when the dialog is invoked again, this method is called, which save the Atlas AAM model and SVM model loading process.
    • doSegmentation

      public void doSegmentation()
      Driver to do automatic prostate segmentation.
    • 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.
    • evaluateShapeDescriptor

      public void evaluateShapeDescriptor()
      Evaluate the AAM segmented VOIs with MIPAV VOI properties.
    • getStatsData

      private Vector<Vector<String>> getStatsData(Vector<VOIStatisticalProperties> statsList, VOIVector VOIs, ModelImage img)
      Generate the VOI statistics data.
      Parameters:
      statsList -
      VOIs -
      img -
      Returns:
    • computeShapeDescriptor

      public void computeShapeDescriptor()
      Compute VOI shape descriptors.
    • markErrorOne

      public void markErrorOne()
      Mark the error segmented VOIs.
    • transformVOIAAM

      public void transformVOIAAM()
      BSpline to smooth the final segmented VOIs.
    • fixErrorVOI

      public void fixErrorVOI()
      Fix the error VOIs from the Marked VOI vector.
    • AAMinitialization

      public void AAMinitialization()
      Atlas based AAM segmentation.
    • cropImage

      public void cropImage()
      Crop image for SVM classification.
    • readTargetImageFeature

      public void readTargetImageFeature()
      We pre-processing target image with coherence enhance diffusion (CED) filter, then extract SVM features from it and save it to the corresponding target image directory. Before apply the automatic segmentation, this method load the pre-processing CED SVM features by default. If we do CED filter and SVM feature extraction in the segmentation process, it will take much, much longer time to process the segmentation.
    • readModels

      private void readModels()
      Read SVM model atlas.
    • exit_input_error

      private static void exit_input_error(int line_num, Throwable cause)
    • exit_input_error

      private static void exit_input_error(int line_num)
    • atof

      public static double atof(String s)
    • atoi

      public static int atoi(String s) throws NumberFormatException
      Parameters:
      s - the string to parse for the integer value
      Throws:
      IllegalArgumentException - if s is empty
      NumberFormatException - see Integer.parseInt(String)
    • mergedClassifier

      public void mergedClassifier()
      After apply the AAM segmentation. We copy the resulting contour to SVM generated non-prostate binary mask image, prostate boundary image, and corresponding CED image. This method uses atlas SVM model to generate the binary maske image, and call a dynamic narrow band tracking algorithm to refine the final prostate boundary.
    • boundaryFinding

      public void boundaryFinding(ModelImage nonProstateImage, ModelImage boundaryImage, ModelImage targetImageSlice, int sliceNumber)
      Dynamic narrow band tracing algorithm. Based on the target CED image, non-prostate binary mask image and prostate boundary mask image, the algorithm stretches the AAM initialization contour, and generate the final prostate contour.
      Parameters:
      nonProstateImage - non-prostate binary mask image
      boundaryImage - prostate boundary mask image.
      targetImageSlice - target CED image
      sliceNumber - current processing slice number.
    • smoothVOI30

      public void smoothVOI30(ModelImage maskImage, ModelImage resultImage)
      Smooth VOI with 30 points.
      Parameters:
      maskImage - mask image with VOI
      resultImage - resulting image to hold the smoothed VOI.
    • maskDisplay

      public ModelImage maskDisplay(int[] mask, int sliceNumber)
      Display binary mask images. Debugging purpose.
      Parameters:
      mask -
      sliceNumber -
      Returns:
    • findBestImageNMI

      private void findBestImageNMI(int targetImageSliceNumber, int[] bestImageNumber, int[] bestSliceNumber)
      NMI searching between target image and AAM atlas.
      Parameters:
      targetImageSliceNumber - target 2D slice number
      bestImageNumber - best matched image number
      bestSliceNumber - best matched slice number.
    • cropTargetImage

      public ModelImage cropTargetImage()
      Crop target image for SVM classification.
      Returns:
    • updateResultImage

      public void updateResultImage(int sliceNumber, ModelImage targetImageSlice)
      After the target image with final segmented VOI.
      Parameters:
      sliceNumber -
      targetImageSlice -
    • updateTargetImage

      public void updateTargetImage(int sliceNumber, ModelImage targetImageSlice)
      Copy the 2D slice segmented VOI to target image silce.
      Parameters:
      sliceNumber - corresponding slice number
      targetImageSlice - target slice number.
    • pause

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

      public void readImagesAndVOIs()
      Read target image
    • readSVMModelDir

      private void readSVMModelDir()
      Read SVM model atlas.
    • svmTraverseDir

      private void svmTraverseDir(File dir)
      Processing SVM model atlas.
      Parameters:
      dir -
    • svmSortModelStructure

      private void svmSortModelStructure()
      sort SVM model with names.
    • readTargetImage

      private void readTargetImage()
      Read target image.
    • 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 AAM model atlas.
    • readEndingSlice

      private void readEndingSlice()
      Read the end slices and update the segmentation processing range.
    • readSampleImages

      private void readSampleImages()
      Read the AAM model.
    • processingData

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

      private void traverse(File dir)
      Recursively read AAM dir, and update the AAM model structure.
      Parameters:
      dir -
    • processDir

      private void processDir(File dir, Vector<JDialogAAMplusSVM.ModelString> modelNameVector)
      Processing the AAM dir with AAM model string and pivot sample image name.
      Parameters:
      dir -
      modelNameVector -
    • disposeLocal

      public void disposeLocal()