Package gov.nih.mipav.model.algorithms
Class AlgorithmFaceAnonymizerBET
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
AlgorithmFaceAnonymizerBET.BitSetUtility
Private utility class for operations on BitSets
-
Field Summary
Fields Modifier and Type Field Description private boolean
estimateWithSphereBET
Parameter for brain extraction by default set tofalse
private int
faceOrientation
The orientation of an image.static int
FACING_DOWN
For indicating the axial image is facing down.static int
FACING_INTO_SCREEN
For indicating the coronal image is facing into the screen.static int
FACING_LEFT
For indicating the sagittal image is facing left.static int
FACING_OUT_OF_SCREEN
For indicating the coronal image is facing out of the screen.static int
FACING_RIGHT
For indicating the sagittal image is facing right.static int
FACING_UP
For indicating the axial image is facing up.private float
imageInfluenceBET
Parameter for brain extraction by default set to .1static int
MIN_RADIUS
May no longer be necessary.private int
mmToPad
Length to buffer brain by in millimeters.static int
REMOVED_INTENSITY
Eventually won't be necessary.private int
sliceSize
Computed as xDim*yDimprivate float
stiffnessBET
Parameter for brain extraction by default set to .15private int
volumeSize
Computed as xDim*yDim*zDimprivate int
xDim
Length of the x dimension in pixels.private int
yDim
Length of the y dimension in pixels.private int
zDim
Length of the z dimension in pixels.-
Fields inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
destFlag, destImage, image25D, mask, maxProgressValue, minProgressValue, multiThreadingEnabled, nthreads, progress, progressModulus, progressStep, runningInSeparateThread, separable, srcImage, threadStopped
-
-
Constructor Summary
Constructors Constructor Description AlgorithmFaceAnonymizerBET(ModelImage srcImg, int faceDirection, int extraMMsToPad)
Construct the face anonymizer, but do not run it yet.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
anonymizeFace()
Executes the de-facing algorithm.private java.util.BitSet
bufferBrain(java.util.BitSet brainMaskTemp, int mmToPad)
Appends the givenbrainMaskTemp
bymmToPad
in pixels in all directions.private java.util.BitSet
defineInitialRegion(java.util.BitSet interestRegion)
Defines an initial region for face de-identification.private java.util.BitSet
defineInterestRegion()
Defines the bounding region for face de-identification.private java.util.BitSet
extractBrain()
Performs the BET brain extraction using parameters specified from JDialogFaceAnonymizer.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.void
finalize()
Clean up memory used by the algorithm.void
runAlgorithm()
Run the de-facing algorithm.void
setBETParameters(boolean estimateWithSphere, float imageInfluence, float stiffness)
Changes the BET algorithm parameters from their defaults (which we choose).private java.util.BitSet
smoothFace(java.util.BitSet removeRegion)
Connects near neighbors of set values inremoveRegion
.-
Methods inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
actionPerformed, addListener, addProgressChangeListener, calculateImageSize, calculatePrincipleAxis, computeElapsedTime, computeElapsedTime, convertIntoFloat, delinkProgressToAlgorithm, delinkProgressToAlgorithmMulti, displayError, errorCleanUp, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, generateProgressValues, getDestImage, getElapsedTime, getMask, getMaxProgressValue, getMinProgressValue, getNumberOfThreads, getProgress, getProgressChangeListener, getProgressChangeListeners, getProgressModulus, getProgressStep, getProgressValues, getSrcImage, isCompleted, isImage25D, isMultiThreadingEnabled, isRunningInSeparateThread, isThreadStopped, linkProgressToAlgorithm, linkProgressToAlgorithm, makeProgress, notifyListeners, removeListener, removeProgressChangeListener, run, setCompleted, setImage25D, setMask, setMaxProgressValue, setMinProgressValue, setMultiThreadingEnabled, setNumberOfThreads, setProgress, setProgressModulus, setProgressStep, setProgressValues, setProgressValues, setRunningInSeparateThread, setSrcImage, setStartTime, setThreadStopped, startMethod, windowActivated, windowClosed, windowClosing, windowDeactivated, windowDeiconified, windowIconified, windowOpened
-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
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 tofalse
-
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-facefaceDirection
- the orientation of the patient's face, as determined by the dialogextraMMsToPad
- 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 classAlgorithmBase
-
runAlgorithm
public void runAlgorithm()
Run the de-facing algorithm.- Specified by:
runAlgorithm
in classAlgorithmBase
-
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 initiallyimageInfluence
- the image influence ratiostiffness
- 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 sizesrcImage.getSize()
where set values are the location of brain.
-
bufferBrain
private java.util.BitSet bufferBrain(java.util.BitSet brainMaskTemp, int mmToPad)
Appends the givenbrainMaskTemp
bymmToPad
in pixels in all directions. TODO: Use Algorithms -> Morphological -> Dilate- Parameters:
brainMaskTemp
- TheBitSet
returned bythis.extractBrain()
.mmToPad
- Length in millimeters that the brain'sBitSet
should be extended.- Returns:
- The original
BitSet
withmmToPad
in pixels appended to thisBitSet
-
defineInterestRegion
private java.util.BitSet defineInterestRegion()
Defines the bounding region for face de-identification.- Returns:
- A
BitSet
of sizesrcImage.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 sizesrcImage.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 theinitialRegion
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 bythis.bufferBrain(BitSet, int)
- Returns:
- A
BitSet
of sizesrcImage.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 inremoveRegion
. Near neighbors are those values which are set and are within five percent of the image resolution.- Parameters:
removeRegion
- The originalBitSet
for face de-identification.interestRegion
- The bounding region.brainMask
- The location of the brain in this image.- Returns:
- A
BitSet
of sizesrcImage.getSize()
where set values denote face de-identification may be performed.
-
-