Class LatticeModel


  • public class LatticeModel
    extends java.lang.Object
    Supports the worm-straightening algorithms that use a 3D lattice as the basis of the straightening process.
    • Field Detail

      • imageDims

        private WildMagic.LibFoundation.Mathematics.Vector3f imageDims
      • outputDirectory

        private java.lang.String outputDirectory
      • sharedOutputDir

        private java.lang.String sharedOutputDir
      • left

        protected VOI left
      • leftContour

        protected VOI leftContour
      • right

        protected VOI right
      • rightContour

        protected VOI rightContour
      • latticeSlices

        protected int[] latticeSlices
      • afTimeC

        protected float[] afTimeC
      • allTimes

        protected float[] allTimes
      • splineRangeIndex

        protected int[] splineRangeIndex
      • centerSpline

        protected WildMagic.LibFoundation.Curves.NaturalSpline3 centerSpline
      • centerPositions

        protected VOIContour centerPositions
      • leftPositions

        protected VOIContour leftPositions
      • rightPositions

        protected VOIContour rightPositions
      • leftLine

        private VOI leftLine
      • rightLine

        private VOI rightLine
      • centerLine

        private VOI centerLine
      • wormDiameters

        protected java.util.Vector<java.lang.Float> wormDiameters
      • extent

        protected int extent
      • rightVectors

        protected java.util.Vector<WildMagic.LibFoundation.Mathematics.Vector3f> rightVectors
      • normalVectors

        protected java.util.Vector<WildMagic.LibFoundation.Mathematics.Vector3f> normalVectors
      • upVectors

        protected java.util.Vector<WildMagic.LibFoundation.Mathematics.Vector3f> upVectors
      • curvatureNormals

        java.util.Vector<WildMagic.LibFoundation.Mathematics.Vector3f> curvatureNormals
      • curvature

        java.util.Vector<java.lang.Float> curvature
      • boxBounds

        protected java.util.Vector<WildMagic.LibFoundation.Mathematics.Box3f> boxBounds
      • ellipseBounds

        protected java.util.Vector<WildMagic.LibFoundation.Mathematics.Ellipsoid3f> ellipseBounds
      • latticeInterpolationInit

        private boolean latticeInterpolationInit
      • samplingPlanes

        protected VOI samplingPlanes
      • maxSplineLength

        private int maxSplineLength
      • displayContours

        private VOI[] displayContours
      • displayContours2

        private VOI displayContours2
      • ellipseCurvesVOI

        private VOI ellipseCurvesVOI
      • ellipseCurves

        protected VOIContour[] ellipseCurves
      • displayInterpolatedContours

        protected VOI displayInterpolatedContours
      • pickedPoint

        private WildMagic.LibFoundation.Mathematics.Vector3f pickedPoint
      • showSelectedVOI

        private VOI showSelectedVOI
      • leftMarker

        private VOI leftMarker
      • rightMarker

        private VOI rightMarker
      • annotationVOIs

        protected VOI annotationVOIs
      • wormOrigin

        protected WildMagic.LibFoundation.Mathematics.Vector3f wormOrigin
      • transformedOrigin

        protected WildMagic.LibFoundation.Mathematics.Vector3f transformedOrigin
      • neuriteData

        private java.util.Vector<VOI> neuriteData
      • voiID

        protected java.lang.Short voiID
      • seamCellIDs

        private int[][] seamCellIDs
      • allSeamCellIDs

        private int[][] allSeamCellIDs
      • colorAnnotations

        private boolean colorAnnotations
      • curveListeners

        private java.util.Vector<CurveListener> curveListeners
      • latticeListeners

        private java.util.Vector<LatticeListener> latticeListeners
      • annotationPrefix

        private java.lang.String annotationPrefix
      • paddingFactor

        private int paddingFactor
      • numEllipsePts

        private int numEllipsePts
      • latticeContours

        private VOI latticeContours
      • markerNames

        private java.util.Vector<java.lang.String> markerNames
      • markerCenters

        private java.util.Vector<WildMagic.LibFoundation.Mathematics.Vector3f> markerCenters
      • markerLatticeSegments

        private java.util.Vector<java.lang.Integer> markerLatticeSegments
      • markerSlices

        private java.util.Vector<java.lang.Integer> markerSlices
      • annotationsStraight

        private VOI annotationsStraight
      • latticeStraight

        private VOIVector latticeStraight
      • previewMode

        private boolean previewMode
      • clipMask

        private java.util.Vector<boolean[]> clipMask
      • numSurfaceSegments

        private int numSurfaceSegments
      • currentMesh

        private WildMagic.LibGraphics.SceneGraph.TriMesh currentMesh
      • modelDisplayed

        private boolean modelDisplayed
        Enables the user to visualize the simple ellipse-based model of the worm during lattice construction.
      • splineModel

        private boolean splineModel
      • ellipseCross

        private boolean ellipseCross
      • ellipseScale

        private float ellipseScale
      • displayLatticeLabels

        private boolean displayLatticeLabels
    • Constructor Detail

      • LatticeModel

        public LatticeModel​(ModelImage image)
        Creates a new LatticeModel
        Parameters:
        imageA -
      • LatticeModel

        public LatticeModel​(ModelImage image,
                            VOIVector lattice)
        Creats a new LatticeModel with the given input lattice.
        Parameters:
        imageA -
        lattice -
    • Method Detail

      • checkParentDir

        public static void checkParentDir​(java.lang.String parentDir)
      • getImageName

        private static java.lang.String getImageName​(ModelImage image)
      • match

        public static boolean match​(java.awt.Color c1,
                                    java.awt.Color c2)
      • checkName

        public static boolean checkName​(java.lang.String name,
                                        VOI annotationVOIs)
      • readAnnotationsCSV

        public static VOI readAnnotationsCSV​(java.lang.String fileName)
        Read a list of annotations from a CSV file: name,x,y,z,radius (optional)
        Parameters:
        fileName -
        Returns:
        VOI containing list of annotations.
      • readLatticeCSV

        public static VOIVector readLatticeCSV​(java.lang.String fileName)
      • readLatticeCSV

        public static VOIVector readLatticeCSV​(java.lang.String fileName,
                                               boolean saveSeamCells)
      • saveAllVOIsTo

        public static void saveAllVOIsTo​(java.lang.String voiDir,
                                         ModelImage image)
        Saves all VOIs to the specified file.
        Parameters:
        voiDir -
        image -
      • saveAnnotationsAsCSV

        public static void saveAnnotationsAsCSV​(java.lang.String dir,
                                                java.lang.String fileName,
                                                VOI annotations)
      • saveAnnotationsAsCSV

        public static void saveAnnotationsAsCSV​(java.lang.String dir,
                                                java.lang.String fileName,
                                                VOI annotations,
                                                boolean isCurve)
        Saves the input annotations to the CSV file in the following format: name,x,y,z
        Parameters:
        dir -
        fileName -
        annotations -
      • inverseDiagonal

        private static WildMagic.LibFoundation.Mathematics.Vector3f inverseDiagonal​(ModelImage image,
                                                                                    int slice,
                                                                                    int extent,
                                                                                    WildMagic.LibFoundation.Mathematics.Vector3f[] verts,
                                                                                    WildMagic.LibFoundation.Mathematics.Vector3f target)
      • addAnnotation

        public void addAnnotation​(VOI textVOI,
                                  boolean multiSelect)
        Add an annotation to the annotation list.
        Parameters:
        textVOI -
      • addAnnotation

        public void addAnnotation​(VOIWormAnnotation newText,
                                  boolean multiSelect)
      • removeListeners

        public void removeListeners()
      • addAnnotationListener

        public void addAnnotationListener​(AnnotationListener listener)
        Adds an annotation listener. The annotation listeners are updated when the annotations change in any way.
        Parameters:
        listener -
      • addSplineControlPts

        public void addSplineControlPts​(java.util.Vector<VOIWormAnnotation> controlPts)
        Add a curve to the list.
        Parameters:
        textVOI -
      • addCurveListener

        public void addCurveListener​(CurveListener listener)
      • addLatticeListener

        public void addLatticeListener​(LatticeListener listener)
      • addLeftRightMarker

        public void addLeftRightMarker​(WildMagic.LibFoundation.Mathematics.Vector3f pt,
                                       boolean isSeam)
        Adds a new left/right marker to the worm image.
        Parameters:
        pt -
      • addNeurite

        public void addNeurite​(VOI annotionVOI,
                               java.lang.String name)
        Generates a natural spline curve to fit the input set of annotation points to model a neurite.
      • clear3DSelection

        public void clear3DSelection()
        Clears the selected VOI or Annotation point.
      • clearAddLeftRightMarkers

        public void clearAddLeftRightMarkers()
        Enables user to start editing the lattice.
      • colorAnnotations

        public void colorAnnotations​(boolean setColor)
      • deleteAnnotations

        public void deleteAnnotations()
      • deleteSelectedPoint

        public void deleteSelectedPoint​(boolean doAnnotation)
        Deletes the selected annotation or lattice point.
        Parameters:
        doAnnotation -
      • displayAnnotation

        public void displayAnnotation​(java.lang.String name,
                                      boolean display)
      • dispose

        public void dispose()
        Deletes this LatticeModel
      • flipLattice

        public void flipLattice()
      • flipLattice

        public static void flipLattice​(VOI left,
                                       VOI right)
      • generateTriMesh

        public WildMagic.LibGraphics.SceneGraph.TriMesh generateTriMesh​(boolean returnMesh,
                                                                        boolean saveMesh)
      • generateTriMesh2

        public WildMagic.LibGraphics.SceneGraph.TriMesh generateTriMesh2​(boolean returnMesh,
                                                                         boolean saveMesh,
                                                                         int stepSize)
      • getAnnotationPrefix

        public java.lang.String getAnnotationPrefix()
      • getAnnotations

        public VOI getAnnotations()
      • getAnnotationsStraight

        public VOI getAnnotationsStraight()
      • getSplineCurves

        public java.util.Vector<java.lang.String> getSplineCurves()
      • deleteSelectedCurve

        public void deleteSelectedCurve()
      • isCurveSelected

        public boolean isCurveSelected​(java.lang.String name)
      • setCurveName

        public void setCurveName​(java.lang.String oldName,
                                 java.lang.String newName)
      • setCurveSelected

        public void setCurveSelected​(java.lang.String name,
                                     boolean selected)
      • setCurveVisible

        public void setCurveVisible​(java.lang.String name,
                                    boolean visible)
      • getCurrentIndex

        public int getCurrentIndex()
      • getLatticeStraight

        public VOIVector getLatticeStraight()
      • getPlanes

        public VOI getPlanes()
      • getEllipseCurves

        public VOIContour[] getEllipseCurves()
      • getLatticeCurveLength

        public int getLatticeCurveLength()
      • getCenter

        public WildMagic.LibFoundation.Mathematics.Vector3f getCenter​(int i)
      • showMarker

        public void showMarker​(int i)
      • getDiameter

        public int getDiameter​(int i)
      • getBasisVectors

        public WildMagic.LibFoundation.Mathematics.Vector3f[] getBasisVectors​(int i)
      • getRightCurve

        public VOIContour getRightCurve()
      • getCenterControlPoints

        public VOIContour getCenterControlPoints()
      • getNormalVectors

        public java.util.Vector<WildMagic.LibFoundation.Mathematics.Vector3f> getNormalVectors()
      • getRightVectors

        public java.util.Vector<WildMagic.LibFoundation.Mathematics.Vector3f> getRightVectors()
      • getUpVectors

        public java.util.Vector<WildMagic.LibFoundation.Mathematics.Vector3f> getUpVectors()
      • getPicked

        public WildMagic.LibFoundation.Mathematics.Vector3f getPicked()
        Returns the currently selected point, either on the lattice or from the annotation list.
        Returns:
      • getPicked

        public WildMagic.LibFoundation.Mathematics.Vector3f getPicked​(WildMagic.LibFoundation.Mathematics.Vector3f pt,
                                                                      boolean doAnnotation)
        Finds the closest point to the input point and sets it as the currently selected lattice or annotation point.
        Parameters:
        pt -
        doAnnotation -
        Returns:
      • getPickedAnnotation

        public java.util.Vector<VOIWormAnnotation> getPickedAnnotation()
      • getSamplingPlanes

        public VOI getSamplingPlanes​(boolean scale)
      • hasPicked

        public boolean hasPicked()
      • initializeInterpolation

        public void initializeInterpolation​(boolean saveStats)
      • interpolateLattice

        public void interpolateLattice​(boolean displayResult,
                                       boolean useModel,
                                       boolean untwistImage,
                                       boolean untwistMarkers)
        Entry point in the lattice-based straightening algorithm. At this point a lattice must be defined, outlining how the worm curves in 3D. A lattice is defined ad a VOI with two curves of equal length marking the left-hand and right-hand sides or the worm.
        Parameters:
        displayResult - , when true intermediate volumes and results are displayed as well as the final straightened image.
      • modifyAnnotation

        public boolean modifyAnnotation​(WildMagic.LibFoundation.Mathematics.Vector3f pt)
        Enables the user to move an annotation point with the mouse.
        Parameters:
        startPt - 3D start point of a ray intersecting the volume.
        endPt - 3D end point of a ray intersecting the volume.
        pt - point along the ray with the maximum intensity value.
      • modifyLattice

        public boolean modifyLattice​(WildMagic.LibFoundation.Mathematics.Vector3f startPt,
                                     WildMagic.LibFoundation.Mathematics.Vector3f endPt,
                                     WildMagic.LibFoundation.Mathematics.Vector3f pt)
        Enables the user to modify the lattice point with the mouse.
        Parameters:
        startPt - 3D start point of a ray intersecting the volume.
        endPt - 3D end point of a ray intersecting the volume.
        pt - point along the ray with the maximum intensity value.
      • modifyLeftRightMarker

        public void modifyLeftRightMarker​(WildMagic.LibFoundation.Mathematics.Vector3f pt)
        Sets the currently selected point (lattice or annotation).
        Parameters:
        pt -
        doAnnotation -
      • moveSelectedPoint

        public void moveSelectedPoint​(WildMagic.LibFoundation.Mathematics.Vector3f direction,
                                      boolean doAnnotation)
        Enables the user to move the selected point (lattice or annotation) with the arrow keys.
        Parameters:
        direction -
        doAnnotation -
      • redo

        public void redo()
        VOI operation redo
      • retwistAnnotations

        public VOI retwistAnnotations​(VOIVector lattice)
      • saveLattice

        public void saveLattice()
        Enables the user to save the lattice to a user-selected file.
      • saveLattice

        public void saveLattice​(java.lang.String directory,
                                java.lang.String fileName)
        Saves the lattice to the specified file and directory.
        Parameters:
        directory -
        fileName -
      • getContourFile

        private boolean getContourFile()
      • saveMeshContoursCSV

        private void saveMeshContoursCSV()
      • readMeshContoursCSV

        private void readMeshContoursCSV()
      • openNeuriteCurves

        public void openNeuriteCurves​(java.lang.String outputDirectory)
      • saveNeuriteCurves

        public void saveNeuriteCurves()
      • untwistNeuriteCurves

        public void untwistNeuriteCurves​(boolean useLatticeModel)
      • openStraightNeuriteCurves

        public static void openStraightNeuriteCurves​(ModelImage image,
                                                     java.lang.String outputDirectory)
      • segmentLattice

        public ModelImage segmentLattice​(ModelImage image,
                                         boolean saveContourImage,
                                         int paddingFactor,
                                         boolean segmentLattice)
      • selectAnnotation

        public boolean selectAnnotation​(WildMagic.LibFoundation.Mathematics.Vector3f startPt,
                                        WildMagic.LibFoundation.Mathematics.Vector3f endPt,
                                        WildMagic.LibFoundation.Mathematics.Vector3f pt,
                                        boolean rightMouse,
                                        boolean multiSelect)
      • selectLattice

        public boolean selectLattice​(WildMagic.LibFoundation.Mathematics.Vector3f startPt,
                                     WildMagic.LibFoundation.Mathematics.Vector3f endPt,
                                     WildMagic.LibFoundation.Mathematics.Vector3f pt,
                                     boolean isSeam)
      • setAnnotationPrefix

        public void setAnnotationPrefix​(java.lang.String s)
      • setAnnotations

        public void setAnnotations​(VOI newAnnotations)
        Called when new annotations are loaded from file, replaces current annotations.
        Parameters:
        newAnnotations -
      • addAnnotations

        public void addAnnotations​(VOI newAnnotations)
        Called when new annotations are loaded from file, replaces current annotations.
        Parameters:
        newAnnotations -
      • setImage

        public void setImage​(ModelImage image)
        Change the underlying image for the latticeModel. Update the output directories.
        Parameters:
        image -
      • setSharedDirectory

        public void setSharedDirectory​(java.lang.String dir)
      • setLattice

        public void setLattice​(VOIVector newLattice)
        Called when a new lattice is loaded from file, replaces the current lattice.
        Parameters:
        newLattice -
      • setMarkers

        public void setMarkers​(VOI markerVOIs)
      • setPaddingFactor

        public void setPaddingFactor​(int padding)
      • isPreview

        public boolean isPreview()
      • setPreviewMode

        public void setPreviewMode​(boolean preview,
                                   VOIVector lattice,
                                   VOI annotations)
      • showModel

        public void showModel​(boolean display)
      • isModelDisplayed

        public boolean isModelDisplayed()
      • updateCrossSection

        public void updateCrossSection​(boolean useSpline,
                                       boolean ellipse,
                                       float percent)
      • showLatticeLabels

        public void showLatticeLabels​(boolean display)
      • showLattice

        public void showLattice​(boolean display)
        Turns on/off lattice display:
      • undo

        public void undo()
        VOI operation undo.
      • untwistImage

        public void untwistImage​(boolean mainImage)
        Entry point in the lattice-based straightening algorithm. At this point a lattice must be defined, outlining how the worm curves in 3D. A lattice is defined ad a VOI with two curves of equal length marking the left-hand and right-hand sides or the worm.
        Parameters:
        displayResult - , when true intermediate volumes and results are displayed as well as the final straightened image.
      • untwistMarkers

        public void untwistMarkers​(boolean untwistAll)
        Entry point in the lattice-based straightening algorithm. At this point a lattice must be defined, outlining how the worm curves in 3D. A lattice is defined ad a VOI with two curves of equal length marking the left-hand and right-hand sides or the worm.
        Parameters:
        displayResult - , when true intermediate volumes and results are displayed as well as the final straightened image.
      • untwistTest

        public ModelImage[] untwistTest​(VolumeImage[] stack)
        Untwists the worm image quickly for the preview mode - without saving any images or statistics
        Returns:
        untwisted image.
      • updateSelectedPoint

        public void updateSelectedPoint​(java.awt.Color color)
      • generateCurves

        protected boolean generateCurves​(float stepSize)
        Generates the set of natural spline curves to fit the current lattice.
      • updateEllipseModel

        private void updateEllipseModel​(float stepSize)
      • GetSquared

        protected double GetSquared​(WildMagic.LibFoundation.Mathematics.Vector3f point,
                                    WildMagic.LibFoundation.Mathematics.Ellipsoid3f ellipsoid)
      • interpolateContour

        protected void interpolateContour​(VOIContour contour)
        Interpolates the input contour so that the spacing between contour points is <= 1 voxel.
        Parameters:
        contour -
      • loadDiameters

        protected java.util.Vector<java.lang.Float> loadDiameters​(java.lang.String imageDir)
      • loadPositions

        protected VOIContour loadPositions​(java.lang.String imageDir,
                                           java.lang.String name)
      • loadSamplePlanes

        protected VOI loadSamplePlanes​(java.lang.String imageDir)
      • makeEllipse

        protected WildMagic.LibFoundation.Mathematics.Ellipsoid3f makeEllipse​(WildMagic.LibFoundation.Mathematics.Vector3f right,
                                                                              WildMagic.LibFoundation.Mathematics.Vector3f up,
                                                                              WildMagic.LibFoundation.Mathematics.Vector3f center,
                                                                              float diameterA,
                                                                              float diameterB,
                                                                              VOIContour ellipse)
        Generates the 3D 1-voxel thick ellipsoids used in the intial worm model.
        Parameters:
        right -
        up -
        center -
        diameterA -
        diameterB -
        ellipse -
        Returns:
      • makeEllipse2DA

        protected void makeEllipse2DA​(WildMagic.LibFoundation.Mathematics.Vector3f right,
                                      WildMagic.LibFoundation.Mathematics.Vector3f up,
                                      WildMagic.LibFoundation.Mathematics.Vector3f center,
                                      float radius,
                                      VOIContour ellipse)
      • makeEllipse2DA

        protected void makeEllipse2DA​(WildMagic.LibFoundation.Mathematics.Vector3f right,
                                      WildMagic.LibFoundation.Mathematics.Vector3f up,
                                      WildMagic.LibFoundation.Mathematics.Vector3f center,
                                      float radius,
                                      WildMagic.LibFoundation.Mathematics.Vector3f normal,
                                      float curvature,
                                      VOIContour ellipse,
                                      boolean ellipseCross,
                                      float scale)
      • originToStraight

        protected WildMagic.LibFoundation.Mathematics.Vector3f originToStraight​(ModelImage model,
                                                                                ModelImage originToStraight,
                                                                                WildMagic.LibFoundation.Mathematics.Vector3f pt,
                                                                                java.lang.String text)
        Given a point in the twisted volume, calculates and returns the corresponding point in the straightened image.
        Parameters:
        model -
        originToStraight -
        pt -
        text -
        Returns:
      • saveAnnotationStatistics

        protected VOI saveAnnotationStatistics​(java.lang.String imageDir,
                                               ModelImage model,
                                               ModelImage originToStraight,
                                               int[] outputDim,
                                               java.lang.String postFix)
        Saves the annotation statistics to a file.
        Parameters:
        image -
        model -
        originToStraight -
        outputDim -
        postFix -
        Returns:
      • saveDiameters

        protected void saveDiameters​(java.util.Vector<java.lang.Float> diameters,
                                     java.lang.String imageDir)
      • saveLatticeStatistics

        protected void saveLatticeStatistics​(java.lang.String imageDir,
                                             float length,
                                             VOI left,
                                             VOI right,
                                             float[] leftPairs,
                                             float[] rightPairs,
                                             java.lang.String postFix)
        Saves the lattice statistics to a file.
        Parameters:
        image -
        length -
        left -
        right -
        leftPairs -
        rightPairs -
        postFix -
      • savePositions

        protected void savePositions​(VOIContour contour,
                                     java.lang.String imageDir,
                                     java.lang.String name)
      • saveSamplePlanes

        protected void saveSamplePlanes​(VOI planes,
                                        java.lang.String imageDir)
      • smoothCurve

        protected WildMagic.LibFoundation.Curves.NaturalSpline3 smoothCurve​(VOIContour curve,
                                                                            float[] time)
        Generates the Natural Spline for the lattice center-line curve. Sets the time values for each point on the curve.
        Parameters:
        curve -
        time -
        Returns:
      • smoothCurve

        public static WildMagic.LibFoundation.Curves.NaturalSpline3 smoothCurve​(java.util.Vector<VOIWormAnnotation> controlPts)
      • straightenFrame

        protected WildMagic.LibFoundation.Mathematics.Vector3f[] straightenFrame​(ModelImage image,
                                                                                 int slice,
                                                                                 int[] extents,
                                                                                 WildMagic.LibFoundation.Mathematics.Vector3f[] verts,
                                                                                 WildMagic.LibFoundation.Mathematics.Vector3f centerPos,
                                                                                 WildMagic.LibFoundation.Mathematics.Vector3f leftPos,
                                                                                 WildMagic.LibFoundation.Mathematics.Vector3f rightPos)
      • writeDiagonal

        protected WildMagic.LibFoundation.Mathematics.Vector3f writeDiagonal​(ModelImage image,
                                                                             int slice,
                                                                             int[] extents,
                                                                             WildMagic.LibFoundation.Mathematics.Vector3f[] verts,
                                                                             WildMagic.LibFoundation.Mathematics.Vector3f target,
                                                                             float[] minDistance)
      • writeDiagonal

        protected void writeDiagonal​(ModelImage image,
                                     ModelImage result,
                                     int tSlice,
                                     int slice,
                                     int[] extents,
                                     WildMagic.LibFoundation.Mathematics.Vector3f[] verts)
      • writeDiagonalSampleCount

        protected void writeDiagonalSampleCount​(ModelImage image,
                                                ModelImage result,
                                                int tSlice,
                                                int slice,
                                                int[] extents,
                                                WildMagic.LibFoundation.Mathematics.Vector3f[] verts)
      • writeDiagonalTest

        protected void writeDiagonalTest​(ModelImage image,
                                         ModelImage result,
                                         int tSlice,
                                         int slice,
                                         int[] extents,
                                         WildMagic.LibFoundation.Mathematics.Vector3f[] verts,
                                         float radiusSq)
      • addInsertionPoint

        private boolean addInsertionPoint​(WildMagic.LibFoundation.Mathematics.Vector3f startPt,
                                          WildMagic.LibFoundation.Mathematics.Vector3f endPt,
                                          WildMagic.LibFoundation.Mathematics.Vector3f maxPt,
                                          boolean isSeam)
        Adds a point to the lattice.
        Parameters:
        startPt -
        endPt -
        maxPt -
      • clearCurves

        private void clearCurves​(boolean clearGrid)
        Resets the natural spline curves when the lattice changes.
      • colorAnnotations

        private void colorAnnotations()
        Counts the annotations and colors them based on the number of annotations. This is only used when the user is labeling seam-cells as an aid in determining if 20 pairs of seam cells have been found.
      • generateEllipses

        private void generateEllipses​(int extent)
      • makeSelectionFrame

        private void makeSelectionFrame​(WildMagic.LibFoundation.Mathematics.Vector3f right,
                                        WildMagic.LibFoundation.Mathematics.Vector3f up,
                                        WildMagic.LibFoundation.Mathematics.Vector3f center,
                                        float diameter,
                                        VOIContour ellipse)
        Generates the VOI that highlights which point (lattice or annotation) is currently selected by the user.
        Parameters:
        right -
        up -
        center -
        diameter -
        ellipse -
      • retwistAnnotation

        private WildMagic.LibFoundation.Mathematics.Vector3f retwistAnnotation​(VOIWormAnnotation annotation)
      • saveImage

        private void saveImage​(java.lang.String imageName,
                               ModelImage image,
                               boolean saveAsTif)
      • saveImage

        public static void saveImage​(ModelImage originalImage,
                                     ModelImage image,
                                     java.lang.String subDir,
                                     java.lang.String postScript)
      • saveLatticeStatistics

        private void saveLatticeStatistics()
      • saveContourAsCSV

        public static void saveContourAsCSV​(ModelImage image,
                                            java.lang.String subDir,
                                            java.lang.String postScript,
                                            VOIContour contour)
      • saveBasisVectorsAsCSV

        public static void saveBasisVectorsAsCSV​(ModelImage image,
                                                 java.lang.String subDir,
                                                 java.lang.String postScript,
                                                 VOIContour positions,
                                                 java.util.Vector<WildMagic.LibFoundation.Mathematics.Vector3f> normals,
                                                 java.util.Vector<WildMagic.LibFoundation.Mathematics.Vector3f> rightVectors,
                                                 java.util.Vector<WildMagic.LibFoundation.Mathematics.Vector3f> upVectors)
      • saveContours

        private void saveContours​(ModelImage image,
                                  WildMagic.LibFoundation.Mathematics.Box3f[] contours)
      • readContours

        public static WildMagic.LibFoundation.Mathematics.Box3f[] readContours​(ModelImage image,
                                                                               java.lang.String subDir,
                                                                               java.lang.String postScript)
      • saveTriMesh

        public static void saveTriMesh​(ModelImage image,
                                       java.lang.String outputDirectory,
                                       java.lang.String subDir,
                                       java.lang.String postScript,
                                       WildMagic.LibGraphics.SceneGraph.TriMesh mesh)
      • saveSpline

        private void saveSpline​(java.lang.String outputDirectory,
                                VOI data,
                                WildMagic.LibFoundation.Mathematics.Vector3f transformedOrigin,
                                java.lang.String postFix)
      • untwist

        private void untwist​(ModelImage image,
                             int[] resultExtents,
                             boolean saveTif)
        Straightens the worm image based on the input lattice positions. The image is straightened without first building a worm model. The image is segmented after clipping based on surface markers or the lattice shape.
        Parameters:
        image -
        resultExtents -
      • untwistSampleCount

        private void untwistSampleCount​(ModelImage image,
                                        int[] resultExtents,
                                        boolean saveTif)
      • untwistLattice

        private void untwistLattice​(ModelImage image,
                                    int[] resultExtents)
        Untwists the lattice and lattice interpolation curves, writing the straightened data to spreadsheet format .csv files and the straightened lattice to a VOI file. The target slices for the lattice and curve data is generated from the distance along the curve. No segmentation or interpolation is necessary:
        Parameters:
        image -
        resultExtents -
      • untwistMarkers

        private void untwistMarkers​(ModelImage image,
                                    int[] resultExtents)
      • untwistAnnotations

        public ModelImage untwistAnnotations​(java.lang.String dir,
                                             ModelImage contourImage)
      • untwistTest

        private ModelImage[] untwistTest​(VolumeImage[] stack,
                                         int[] resultExtents)
        Untwists the worm image quickly for the preview mode - without saving any images or statistics Straightens the worm image based on the input lattice positions. The image is straightened without first building a worm model. The image is segmented after clipping based on surface markers or the lattice shape.
        Parameters:
        image -
        resultExtents -
      • getPrefix

        private static java.lang.String getPrefix​(java.lang.String name)
      • containsAnnotation

        private boolean containsAnnotation​(VOI annotationsList,
                                           VOIWormAnnotation text)
      • updateSplineControlPoints

        private void updateSplineControlPoints()
      • updateAnnotationListeners

        private void updateAnnotationListeners()
        Updates the list of listeners that the annotations have changed. This is how the latticeModel communicates changes to the different plugins that display lists of annotations, etc.
      • updateCurveListeners

        private void updateCurveListeners()
      • updateLatticeListeners

        private void updateLatticeListeners()
      • makeLatticeContours

        private void makeLatticeContours()
      • updateLattice

        private void updateLattice​(boolean rebuild)
        Updates the lattice data structures for rendering whenever the user changes the lattice.
        Parameters:
        rebuild -
      • updateLinks

        private void updateLinks()
        Updates the lattice data structures on undo/redo.
      • updateSelected

        private void updateSelected()
        Updates the VOI displaying which point (lattice or annotation) is currently selected when the selection changes.
      • findPoint

        private int findPoint​(VOI left,
                              WildMagic.LibFoundation.Mathematics.Vector3f pickedPoint)
      • updateSeamCount

        private void updateSeamCount()
      • renameLatticeOnLoad

        public static boolean renameLatticeOnLoad​(ModelImage image,
                                                  VOIVector latticeVector)
      • saveLattice

        public static void saveLattice​(java.lang.String directory,
                                       java.lang.String fileName,
                                       VOIVector latticeVector)
      • saveLattice

        public static void saveLattice​(java.lang.String directory,
                                       java.lang.String fileName,
                                       java.lang.String latticeFileName,
                                       VOIVector latticeVector)
      • annotationChanged

        private static VOI annotationChanged​(VOI annotationsNew,
                                             VOI annotationOld)
      • latticeChanged

        private boolean latticeChanged()
      • testLatticeMeshIntersection

        private void testLatticeMeshIntersection()
      • getInsideMeshImage

        private ModelImage getInsideMeshImage​(java.util.BitSet surfaceMask)
      • getInsideMeshImage

        private ModelImage getInsideMeshImage​(WildMagic.LibGraphics.SceneGraph.TriMesh mesh)
      • blur

        private static ModelImage blur​(ModelImage image,
                                       int sigma)
        Returns a blurred image of the input image.
        Parameters:
        image -
        sigma -
        Returns:
      • getCorrectionFactor

        private static float getCorrectionFactor​(ModelImage image)
        Returns the amount of correction which should be applied to the z-direction sigma (assuming that correction is requested).
        Returns:
        the amount to multiply the z-sigma by to correct for resolution differences
      • fill

        private static int fill​(java.util.BitSet surfaceMask,
                                java.util.Vector<WildMagic.LibFoundation.Mathematics.Vector3f> seedList,
                                java.util.BitSet visited,
                                WildMagic.LibFoundation.Mathematics.Vector3f min,
                                WildMagic.LibFoundation.Mathematics.Vector3f max,
                                int dimX,
                                int dimY,
                                int dimZ)