Package gov.nih.mipav.model.algorithms
Class AlgorithmBrainSurfaceExtractor
java.lang.Object
java.lang.Thread
gov.nih.mipav.model.algorithms.AlgorithmBase
gov.nih.mipav.model.algorithms.AlgorithmBrainSurfaceExtractor
- All Implemented Interfaces:
AlgorithmInterface,ActionListener,WindowListener,Runnable,EventListener
This class provides an implementation of a second method for segmentation of the brain from a 3D MRI, as opposed to
the BET algorithm implemented in AlgorithmBrainExtractor. The algorithm is partially based on the paper describing
the Brain Surface Extraction (BSE) algorithm:
Magnetic Resonance Image Tissue Classification Using a Partial Volume Model
David W. Shattuck et al.
NeuroImage 13, 856-876 (2001)
available at http://www.idealibrary.com
- Version:
- 1.0 June 3, 2004
- Author:
- Evan McCreedy
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate floatThe size of the region we have identified as the brain.private static final floatThe proportion of the total number of pixels in the volume that a region should be before we decide that it's probably the brain.private intThe number of closings to perform.private final intUse the sized circle kernel for the closing.private floatThe size of the kernel to use in closings.private booleanWhether to use the edge detection algorithm with a separable convolver.private floatThe size of the edge detection kernel.private booleanWhether to erode / dilate image slices independently.private intThe number of erosions/dilations to perform.private booleanThis flag is set when the algorithm is being used only to extract paint from the brain.private booleanWhether to make an effort to fill in any interior holes in the final brain mask.private intThe number of filter passes to make.private floatThe size of the filter kernel to use.private ModelImageThe source image.private intThe size, in voxels, of the volume.private BitSetThe actual paint bitmap.private IntVectorThe stack of voxels in the image that we should try to grow to.private static final floatUsed to initialize the stack size when finding the largest segmented region (i.e. the brain).private ModelImageThe result image.private booleanWhether to show the intermediate images generated during the BSE algorithm.private intThe size, in voxels, of a slice of the volume.private intThe image size in the x dimension.private floatThe image resolution in the x dimension.private intThe image size in the y dimension.private floatThe image resolution in the y dimension.private intThe image size in the z dimension.private floatThe image resolution in the z dimension.Fields inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
destFlag, destImage, image25D, mask, maxProgressValue, minProgressValue, multiThreadingEnabled, nthreads, progress, progressModulus, progressStep, runningInSeparateThread, separable, srcImage, threadStoppedFields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionAlgorithmBrainSurfaceExtractor(ModelImage srcImg, int fIter, float fKernel, float eKernel, boolean ero25D, int eroIter, float cKernel, int cIter, boolean showIntermediate, boolean noHoles, boolean doSep, boolean extractPaint) Create an extractor for segmenting the brain from a 3D magnetic resonance image. -
Method Summary
Modifier and TypeMethodDescriptionprivate static ModelImageaddPadding(ModelImage img) Pad an image by copying the first and last slices 2 more times so that the laplacian algorithm behaves well in edge conditions.voidalgorithmPerformed(AlgorithmBase algorithm) This method is required if the AlgorithmPerformed interface is implemented.private float[]calculateProgressRatios(int filterIterations, boolean doSeparable, boolean fillHolesFlag) Calculates the progress ratios for different algorithms.private int[]calculateProgressValueBoundary(int index, float[] ratios, int min, int max) Calculates the boundary of progress value which is assigned to theindexth algorithm.voidIsolate the brain from the rest of the MR image.voidfinalize()Prepares this class for destruction.findLargestRegion(ModelImage maskImage) Find the largest region within a mask image.final floatReturns the volume of the brain in units (typically millimeters).Method is used when the "extract paint" option is set.Get the final result image.intmarkRegion(int[] imgData, int initIndex, int regionId) Start at a point in an image and grow to all connected points, marking them and counting as we go.private static ModelImageremovePadding(ModelImage paddedImg) Remove the padding slices from the beginning and end of an image.voidStarts the algorithm.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, windowOpenedMethods 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, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
-
Field Details
-
brainRegionThresholdRatio
private static final float brainRegionThresholdRatioThe proportion of the total number of pixels in the volume that a region should be before we decide that it's probably the brain.- See Also:
-
regionPointStackRatio
private static final float regionPointStackRatioUsed to initialize the stack size when finding the largest segmented region (i.e. the brain).- See Also:
-
brainRegionSize
private float brainRegionSizeThe size of the region we have identified as the brain. -
closeIterations
private int closeIterationsThe number of closings to perform. -
closeKernel
private final int closeKernelUse the sized circle kernel for the closing.- See Also:
-
closeKernelSize
private float closeKernelSizeThe size of the kernel to use in closings. -
doSeparable
private boolean doSeparableWhether to use the edge detection algorithm with a separable convolver. -
edgeKernel
private float edgeKernelThe size of the edge detection kernel. -
erosion25D
private boolean erosion25DWhether to erode / dilate image slices independently. -
erosionIterations
private int erosionIterationsThe number of erosions/dilations to perform. -
extractPaint
private boolean extractPaintThis flag is set when the algorithm is being used only to extract paint from the brain. -
fillHolesFlag
private boolean fillHolesFlagWhether to make an effort to fill in any interior holes in the final brain mask. -
filterIterations
private int filterIterationsThe number of filter passes to make. -
filterKernel
private float filterKernelThe size of the filter kernel to use. -
image
The source image. -
imgSize
private int imgSizeThe size, in voxels, of the volume. -
paintMask
The actual paint bitmap. -
regionPointStack
The stack of voxels in the image that we should try to grow to. Made a class member to increase speed. -
resultImage
The result image. -
showIntermediateImages
private boolean showIntermediateImagesWhether to show the intermediate images generated during the BSE algorithm. -
sliceSize
private int sliceSizeThe size, in voxels, of a slice of the volume. -
xDim
private int xDimThe image size in the x dimension. -
xRes
private float xResThe image resolution in the x dimension. -
yDim
private int yDimThe image size in the y dimension. -
yRes
private float yResThe image resolution in the y dimension. -
zDim
private int zDimThe image size in the z dimension. -
zRes
private float zResThe image resolution in the z dimension.
-
-
Constructor Details
-
AlgorithmBrainSurfaceExtractor
public AlgorithmBrainSurfaceExtractor(ModelImage srcImg, int fIter, float fKernel, float eKernel, boolean ero25D, int eroIter, float cKernel, int cIter, boolean showIntermediate, boolean noHoles, boolean doSep, boolean extractPaint) Create an extractor for segmenting the brain from a 3D magnetic resonance image.- Parameters:
srcImg- the source image. Should be MR image of the brainfIter- number of passes to make with the filterfKernel- gaussian kernel size to use when running the filtereKernel- kernel size to use with edge detection algoero25D- whether to use 2.5D processing in erosion / dilationeroIter- number of erosions / dialations to performcKernel- kernel size in mm to be used in closingcIter- number of closings to performshowIntermediate- whether to save intermediate images for displaynoHoles- whether to fill in all interior holes of the extracted braindoSep- whether to use separable convolver for edge detectionextractPaint- whether to extract paint from the brain
-
-
Method Details
-
algorithmPerformed
This method is required if the AlgorithmPerformed interface is implemented. It is called by the algorithms when it has completed or failed to to complete, so that the dialog can be display the result image and/or clean up.- Specified by:
algorithmPerformedin interfaceAlgorithmInterface- Parameters:
algorithm- Algorithm that caused the event.
-
extractBrain
public void extractBrain()Isolate the brain from the rest of the MR image. -
finalize
public void finalize()Prepares this class for destruction.- Overrides:
finalizein classAlgorithmBase
-
findLargestRegion
Find the largest region within a mask image.- Parameters:
maskImage- the original mask image, with values of 0 or 1- Returns:
- ModelImage the image containing only the largest connected component from
maskImage
-
getBrainVolume
public final float getBrainVolume()Returns the volume of the brain in units (typically millimeters).- Returns:
- The volume of the brain in voxel units (typically millimeters).
-
getComputedPaintMask
Method is used when the "extract paint" option is set.- Returns:
- the paint mask bitset representing the area not removed from the image during the brain extraction
-
getResultImage
Get the final result image.- Returns:
- the final extracted brain image
-
markRegion
public int markRegion(int[] imgData, int initIndex, int regionId) Start at a point in an image and grow to all connected points, marking them and counting as we go.- Parameters:
imgData- the exported 3d image maskinitIndex- the point to start growing the region fromregionId- what to mark where the region is located- Returns:
- the number of voxels in the grown region
-
runAlgorithm
public void runAlgorithm()Starts the algorithm.- Specified by:
runAlgorithmin classAlgorithmBase
-
addPadding
Pad an image by copying the first and last slices 2 more times so that the laplacian algorithm behaves well in edge conditions.- Parameters:
img- the image to pad- Returns:
- the padded image
-
removePadding
Remove the padding slices from the beginning and end of an image.- Parameters:
paddedImg- the padded image- Returns:
- the image without padding
-
calculateProgressRatios
private float[] calculateProgressRatios(int filterIterations, boolean doSeparable, boolean fillHolesFlag) Calculates the progress ratios for different algorithms.- Parameters:
filterIterations- the iteration number for filter.doSeparable- flag to indicate whether use separable algorithm or not.fillHolesFlag- DOCUMENT ME!- Returns:
- the progress ratios for different algorithms
-
calculateProgressValueBoundary
private int[] calculateProgressValueBoundary(int index, float[] ratios, int min, int max) Calculates the boundary of progress value which is assigned to theindexth algorithm.- Parameters:
index- the algorithm indexratios- the ratio array assigned to the algorithms.min- the minimum progress value available to be distributedmax- the maximum progress value available to be distributed- Returns:
- the minimum and maximum progress value assigned to the
indexth algorithm.
-