Class JDialogPatellaTraceSectionsNIH

  • 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 JDialogPatellaTraceSectionsNIH
    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
    • 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
      • labelImageFAT

        private javax.swing.JLabel labelImageFAT
        Target image directory.
      • textFieldImageFAT

        private javax.swing.JTextField textFieldImageFAT
      • buttonImageFAT

        private javax.swing.JButton buttonImageFAT
      • labelImageGRE

        private javax.swing.JLabel labelImageGRE
        GRE image directory.
      • textFieldImageGRE

        private javax.swing.JTextField textFieldImageGRE
      • buttonImageGRE

        private javax.swing.JButton buttonImageGRE
      • 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
      • fatImageChooser

        private javax.swing.JFileChooser fatImageChooser
        target image variables.
      • fatImageName

        private java.lang.String fatImageName
      • fatImageDirectory

        private java.lang.String fatImageDirectory
      • greImageChooser

        private javax.swing.JFileChooser greImageChooser
      • greImageName

        private java.lang.String greImageName
      • greImageDirectory

        private java.lang.String greImageDirectory
      • 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
      • statsToCalculate

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

        private static final boolean[] checkList
      • MipavCoordinateSystem

        private static final java.lang.String MipavCoordinateSystem
      • 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
      • imageStackFuzzyC

        private java.util.Vector<java.util.Vector<ModelImage>> imageStackFuzzyC
      • rowNumber

        private static int[] rowNumber
      • colNumber

        private static int[] colNumber
      • startPt

        private int startPt
      • midPt

        private int midPt
      • endPt

        private int endPt
      • voiVectorFinal

        private VOIVector voiVectorFinal
      • voiNewFinal

        VOI voiNewFinal
      • FuzzyC

        private static int FuzzyC
      • Class1

        private static int Class1
      • Class2

        private static int Class2
      • Class3

        private static int Class3
      • GRE

        private static int GRE
      • Class1_weak

        private static int Class1_weak
      • Class1_lowInten

        private static int Class1_lowInten
      • Class1_corner

        private static int Class1_corner
      • section1_degree_start

        static float section1_degree_start
      • section1_degree_end

        static float section1_degree_end
      • section2_degree_start

        static float section2_degree_start
      • section2_degree_end

        static float section2_degree_end
      • section3_degree_start

        static float section3_degree_start
      • section3_degree_end

        static float section3_degree_end
      • section4_degree_start

        static float section4_degree_start
      • section4_degree_end

        static float section4_degree_end
      • section5_degree_upperHalf_start

        static float section5_degree_upperHalf_start
      • section5_degree_upperHalf_end

        static float section5_degree_upperHalf_end
      • section5_degree_lowerHalf_start

        static float section5_degree_lowerHalf_start
      • section5_degree_lowerHalf_end

        static float section5_degree_lowerHalf_end
      • section6_degree_start

        static float section6_degree_start
      • section6_degree_end

        static float section6_degree_end
      • firstAssigned

        boolean firstAssigned
      • numSteps

        int numSteps
      • tenPercent

        int tenPercent
      • twentyPercent

        int twentyPercent
    • Constructor Detail

      • JDialogPatellaTraceSectionsNIH

        public JDialogPatellaTraceSectionsNIH​(java.awt.Frame theParentFrame,
                                              ModelImage srcImage)
        Constructor. the parent frame
        Parameters:
        theParentFrame -
    • Method Detail

      • configVOIsNumbers

        public void configVOIsNumbers​(ModelImage image,
                                      int[] slices)
      • 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
      • init

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

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

        public ModelImage generateGaussianMap()
      • doFuzzyCmean

        public void doFuzzyCmean​(ModelImage coherenceEnhancingDiffusionImage,
                                 java.util.Vector<java.util.Vector<ModelImage>> imageStackFuzzyC)
      • transformVOI

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

        public void generateInOutContours​(VOIBase startVOI,
                                          float[] innerDist,
                                          float[] outerDist,
                                          WildMagic.LibFoundation.Mathematics.Vector3f[] pt_inner,
                                          WildMagic.LibFoundation.Mathematics.Vector3f[] pt_outer,
                                          WildMagic.LibFoundation.Mathematics.Vector3f[] pt_voi,
                                          float[] center)
      • segmentationAuto

        public void segmentationAuto()
        Driver to do the auto segmentation with AAM model.
      • strain1

        private void strain1()
      • strain

        private void strain()
      • runLevelSet

        private void runLevelSet​(ModelImage fuzzyCImage)
      • createOneContours

        public void createOneContours​(ModelImage targetImageSlice)
      • generateInnerContour

        private void generateInnerContour​(VOIBase srcContour,
                                          ModelImage targetImageSlice)
      • createTwoContours

        public void createTwoContours​(ModelImage targetImageSlice)
      • generateBoundaryContours

        private void generateBoundaryContours​(VOIBase srcContour,
                                              ModelImage targetImageSlice)
      • condenseVOI

        public void condenseVOI​(ModelImage targetImageSlice,
                                int voiNumber)
      • findBestGradientChange

        private void findBestGradientChange​(WildMagic.LibFoundation.Mathematics.Vector3f interpPt,
                                            WildMagic.LibFoundation.Mathematics.Vector3f normStep,
                                            float sliceZ,
                                            float[] x,
                                            float[] y,
                                            ModelImage targetImageSlice)
      • computeGradient

        private void computeGradient​(float xCoord,
                                     float yCoord,
                                     float zCoord,
                                     double[] result,
                                     double[] grad,
                                     double[] gradDir,
                                     ModelImage targetImageSlice)
      • computeNormalLine

        private void computeNormalLine​(WildMagic.LibFoundation.Mathematics.Vector3f startPt,
                                       WildMagic.LibFoundation.Mathematics.Vector3f endPt,
                                       WildMagic.LibFoundation.Mathematics.Vector3f midPt,
                                       WildMagic.LibFoundation.Mathematics.Vector3f outNormPt,
                                       WildMagic.LibFoundation.Mathematics.Vector3f inNormPt,
                                       float stepPct,
                                       WildMagic.LibFoundation.Mathematics.Vector3f normStep,
                                       WildMagic.LibFoundation.Mathematics.Vector3f interpPt)
      • smoothVOI60Single

        public void smoothVOI60Single​(ModelImage maskImage,
                                      ModelImage resultImage)
      • smoothVOI150Single

        public void smoothVOI150Single​(ModelImage maskImage,
                                       ModelImage resultImage)
      • smoothVOI120Single

        public void smoothVOI120Single​(ModelImage maskImage,
                                       ModelImage resultImage)
      • smoothVOI60DualContour

        public void smoothVOI60DualContour​(ModelImage maskImage,
                                           ModelImage resultImage)
      • smoothVOI60Special

        public void smoothVOI60Special​(ModelImage maskImage,
                                       ModelImage resultImage)
      • 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.
      • readFATImagesAndVOIs

        public void readFATImagesAndVOIs()
        read target image.
      • readFATImage

        private void readFATImage()
        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.
      • disposeLocal

        public void disposeLocal()
      • computeGradient

        private void computeGradient​(ModelImage image,
                                     float xCoord,
                                     float yCoord,
                                     float zCoord,
                                     double[] result,
                                     double[] grad,
                                     double[] gradDir)
      • displaySlicesRadical

        private void displaySlicesRadical​(ModelImage fuzzyCImage,
                                          ModelImage class1Image,
                                          ModelImage greImageSlice,
                                          ModelImage gaussianImageSlice,
                                          int sliceNumber,
                                          WildMagic.LibFoundation.Mathematics.Vector3f pos)
      • traceSection6

        private WildMagic.LibFoundation.Mathematics.Vector2f traceSection6​(float posX,
                                                                           float posY,
                                                                           float stepX,
                                                                           float stepY,
                                                                           WildMagic.LibFoundation.Mathematics.Vector3f center,
                                                                           float degree,
                                                                           int sliceNumber,
                                                                           int currentStep,
                                                                           float distCurrent,
                                                                           float distOuter,
                                                                           ModelImage greImageSlice,
                                                                           ModelImage class1Image,
                                                                           ModelImage class2Image,
                                                                           ModelImage class3Image,
                                                                           ModelImage fuzzyCImage)
      • traceSection1

        private WildMagic.LibFoundation.Mathematics.Vector2f traceSection1​(float posX,
                                                                           float posY,
                                                                           float stepX,
                                                                           float stepY,
                                                                           WildMagic.LibFoundation.Mathematics.Vector3f center,
                                                                           float degree,
                                                                           int sliceNumber,
                                                                           int currentStep,
                                                                           float distCurrent,
                                                                           float distOuter,
                                                                           ModelImage greImageSlice,
                                                                           ModelImage class1Image,
                                                                           ModelImage class2Image,
                                                                           ModelImage class3Image,
                                                                           ModelImage fuzzyCImage)
      • traceSection2

        private WildMagic.LibFoundation.Mathematics.Vector2f traceSection2​(float posX,
                                                                           float posY,
                                                                           float stepX,
                                                                           float stepY,
                                                                           WildMagic.LibFoundation.Mathematics.Vector3f center,
                                                                           float degree,
                                                                           int sliceNumber,
                                                                           int currentStep,
                                                                           float distCurrent,
                                                                           float distOuter,
                                                                           ModelImage greImageSlice,
                                                                           ModelImage class1Image,
                                                                           ModelImage class2Image,
                                                                           ModelImage class3Image,
                                                                           ModelImage fuzzyCImage)
      • traceSection3

        private WildMagic.LibFoundation.Mathematics.Vector2f traceSection3​(float posX,
                                                                           float posY,
                                                                           float stepX,
                                                                           float stepY,
                                                                           WildMagic.LibFoundation.Mathematics.Vector3f center,
                                                                           float degree,
                                                                           int sliceNumber,
                                                                           int currentStep,
                                                                           float distCurrent,
                                                                           float distOuter,
                                                                           ModelImage greImageSlice,
                                                                           ModelImage class1Image,
                                                                           ModelImage class2Image,
                                                                           ModelImage class3Image,
                                                                           ModelImage fuzzyCImage)
      • traceSection4

        private WildMagic.LibFoundation.Mathematics.Vector2f traceSection4​(float posX,
                                                                           float posY,
                                                                           float stepX,
                                                                           float stepY,
                                                                           WildMagic.LibFoundation.Mathematics.Vector3f center,
                                                                           float degree,
                                                                           int sliceNumber,
                                                                           int currentStep,
                                                                           float distCurrent,
                                                                           float distOuter,
                                                                           ModelImage greImageSlice,
                                                                           ModelImage class1Image,
                                                                           ModelImage class2Image,
                                                                           ModelImage class3Image,
                                                                           ModelImage fuzzyCImage)
      • traceSection5

        private WildMagic.LibFoundation.Mathematics.Vector2f traceSection5​(float posX,
                                                                           float posY,
                                                                           float stepX,
                                                                           float stepY,
                                                                           WildMagic.LibFoundation.Mathematics.Vector3f center,
                                                                           float degree,
                                                                           int sliceNumber,
                                                                           int currentStep,
                                                                           float distCurrent,
                                                                           float distOuter,
                                                                           ModelImage greImageSlice,
                                                                           ModelImage class1Image,
                                                                           ModelImage class2Image,
                                                                           ModelImage class3Image,
                                                                           ModelImage fuzzyCImage)
      • smoothVOISingle

        public void smoothVOISingle​(ModelImage maskImage,
                                    ModelImage resultImage,
                                    int nPts)
      • distance

        public static final double distance​(WildMagic.LibFoundation.Mathematics.Vector3f pt1,
                                            WildMagic.LibFoundation.Mathematics.Vector3f pt2,
                                            float[] res)
      • findBoundingContour

        private void findBoundingContour​(int sliceNumber,
                                         VOI resultVOIBoundary,
                                         VOI resultVOIInner,
                                         VOI resultVOIOuter,
                                         WildMagic.LibFoundation.Mathematics.Vector3f center,
                                         ModelImage fatImageSlice)
      • findSections

        private void findSections​(VOI boundary,
                                  float[][] sections,
                                  WildMagic.LibFoundation.Mathematics.Vector3f center)
      • tracingDFS_mid

        private void tracingDFS_mid​(ModelImage greImageSlice,
                                    ModelImage fatImageSliceMid,
                                    VOI boundary,
                                    VOI inner,
                                    VOI outer,
                                    boolean first)
      • findCornerEdgeOnImage

        private boolean findCornerEdgeOnImage​(int x,
                                              int y,
                                              ModelImage imageSlice,
                                              int range,
                                              double intensity,
                                              int type)
      • findWeakConnectedEdgeOnImageHorizontal

        private boolean findWeakConnectedEdgeOnImageHorizontal​(int x,
                                                               int y,
                                                               ModelImage imageSlice,
                                                               int range,
                                                               int type,
                                                               boolean searchOnRight,
                                                               int[] xResult)
      • findWeakConnectedEdgeOnImageVertical

        private boolean findWeakConnectedEdgeOnImageVertical​(int x,
                                                             int y,
                                                             ModelImage imageSlice,
                                                             int range,
                                                             int type,
                                                             boolean searchOnRight,
                                                             int[] xResult)
      • findHolesOnImage

        private boolean findHolesOnImage​(int x,
                                         int y,
                                         ModelImage imageSlice,
                                         int range,
                                         double intensity,
                                         int type)
      • findEdgeOnImage

        private boolean findEdgeOnImage​(int x,
                                        int y,
                                        ModelImage imageSlice,
                                        int range,
                                        double intensity,
                                        int type)
      • generateMap

        void generateMap​(int x,
                         int y,
                         ModelImage imageSlice,
                         int[][] visited,
                         int[][] map,
                         int Xmin,
                         int Xmax,
                         int Ymin,
                         int Ymax,
                         int type)
      • isSafe

        boolean isSafe​(int x,
                       int y,
                       int[][] visited,
                       ModelImage fatImageSlice,
                       int Xmin,
                       int Xmax,
                       int Ymin,
                       int Ymax,
                       int xDim,
                       int yDim)
      • DFS

        void DFS​(int row,
                 int col,
                 ModelImage fuzzyCImage,
                 int[][] visited,
                 int[] xmin,
                 int[] xmax,
                 int[] ymin,
                 int[] ymax)
      • isSafe

        boolean isSafe​(int row,
                       int col,
                       int[][] visited,
                       ModelImage fuzzyCImage,
                       int[] xmin,
                       int[] xmax,
                       int[] ymin,
                       int[] ymax)