Class AlgorithmFaceAnonymizerBET

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.awt.event.WindowListener, java.lang.Runnable, java.util.EventListener

    public class AlgorithmFaceAnonymizerBET
    extends AlgorithmBase
    Anonymize an image of a patient's head by removing the face.

    This version of of the de-facer uses BET to find the brain, the brain's location is then used to calculate a plane. This plane is then used to remove the patient's face from the image.

    Author:
    mccreedy
    • Field Detail

      • REMOVED_INTENSITY

        public static final int REMOVED_INTENSITY
        Eventually won't be necessary.
        See Also:
        Constant Field Values
      • MIN_RADIUS

        public static final int MIN_RADIUS
        May no longer be necessary.
        See Also:
        Constant Field Values
      • FACING_RIGHT

        public static final int FACING_RIGHT
        For indicating the sagittal image is facing right.
        See Also:
        Constant Field Values
      • FACING_LEFT

        public static final int FACING_LEFT
        For indicating the sagittal image is facing left.
        See Also:
        Constant Field Values
      • FACING_DOWN

        public static final int FACING_DOWN
        For indicating the axial image is facing down.
        See Also:
        Constant Field Values
      • FACING_UP

        public static final int FACING_UP
        For indicating the axial image is facing up.
        See Also:
        Constant Field Values
      • FACING_INTO_SCREEN

        public static final int FACING_INTO_SCREEN
        For indicating the coronal image is facing into the screen.
        See Also:
        Constant Field Values
      • FACING_OUT_OF_SCREEN

        public static final int FACING_OUT_OF_SCREEN
        For indicating the coronal image is facing out of the screen.
        See Also:
        Constant Field Values
      • mmToPad

        private int mmToPad
        Length to buffer brain by in millimeters.
      • faceOrientation

        private int faceOrientation
        The orientation of an image.
      • estimateWithSphereBET

        private boolean estimateWithSphereBET
        Parameter for brain extraction by default set to false
      • imageInfluenceBET

        private float imageInfluenceBET
        Parameter for brain extraction by default set to .1
      • stiffnessBET

        private float stiffnessBET
        Parameter for brain extraction by default set to .15
      • sliceSize

        private final int sliceSize
        Computed as xDim*yDim
      • volumeSize

        private final int volumeSize
        Computed as xDim*yDim*zDim
      • xDim

        private final int xDim
        Length of the x dimension in pixels.
      • yDim

        private final int yDim
        Length of the y dimension in pixels.
      • zDim

        private final int zDim
        Length of the z dimension in pixels.
    • Constructor Detail

      • AlgorithmFaceAnonymizerBET

        public AlgorithmFaceAnonymizerBET​(ModelImage srcImg,
                                          int faceDirection,
                                          int extraMMsToPad)
        Construct the face anonymizer, but do not run it yet.
        Parameters:
        srcImg - The image to de-face
        faceDirection - the orientation of the patient's face, as determined by the dialog
        extraMMsToPad - the number of millimeters to buffer brain by after extraction
    • Method Detail

      • finalize

        public void finalize()
        Clean up memory used by the algorithm.
        Overrides:
        finalize in class AlgorithmBase
      • setBETParameters

        public void setBETParameters​(boolean estimateWithSphere,
                                     float imageInfluence,
                                     float stiffness)
        Changes the BET algorithm parameters from their defaults (which we choose).
        Parameters:
        estimateWithSphere - whether to estimate the brain with a sphere initially
        imageInfluence - the image influence ratio
        stiffness - the mesh stiffness
      • anonymizeFace

        private void anonymizeFace()
        Executes the de-facing algorithm.
      • extractBrain

        private java.util.BitSet extractBrain()
        Performs the BET brain extraction using parameters specified from JDialogFaceAnonymizer.
        Returns:
        A BitSet of size srcImage.getSize() where set values are the location of brain.
      • bufferBrain

        private java.util.BitSet bufferBrain​(java.util.BitSet brainMaskTemp,
                                             int mmToPad)
        Appends the given brainMaskTemp by mmToPad in pixels in all directions. TODO: Use Algorithms -> Morphological -> Dilate
        Parameters:
        brainMaskTemp - The BitSet returned by this.extractBrain().
        mmToPad - Length in millimeters that the brain's BitSet should be extended.
        Returns:
        The original BitSet with mmToPad in pixels appended to this BitSet
      • defineInterestRegion

        private java.util.BitSet defineInterestRegion()
        Defines the bounding region for face de-identification.
        Returns:
        A BitSet of size srcImage.getSize() where set values are the inital shape's location.
      • defineInitialRegion

        private java.util.BitSet defineInitialRegion​(java.util.BitSet interestRegion)
        Defines an initial region for face de-identification.
        Parameters:
        interestRegion - The bounding area of the face de-identification.
        Returns:
        A BitSet of size srcImage.getSize() where set values are the inital shape's location.
      • extractFace

        private java.util.BitSet extractFace​(java.util.BitSet interestRegion,
                                             java.util.BitSet initialRegion,
                                             java.util.BitSet brainMask)
        Performs the face de-identification within the bounding area by approximating the given shape using a geometry suitable for the given shape. For example, the approximation of a quarter cylinder is performed using spheres with centers on the boundary points of the initialRegion with further iterations on the boundary points of the resulting shape.
        Parameters:
        interestRegion - The bounding area for face de-identification.
        initialRegion - Initial area.
        brainMask - Brain extraction derived from BET and apended by this.bufferBrain(BitSet, int)
        Returns:
        A BitSet of size srcImage.getSize() where set values denote face de-identification may be performed.
      • smoothFace

        private java.util.BitSet smoothFace​(java.util.BitSet removeRegion)
        Connects near neighbors of set values in removeRegion. Near neighbors are those values which are set and are within five percent of the image resolution.
        Parameters:
        removeRegion - The original BitSet for face de-identification.
        interestRegion - The bounding region.
        brainMask - The location of the brain in this image.
        Returns:
        A BitSet of size srcImage.getSize() where set values denote face de-identification may be performed.