Class SegmentInstanceWithModel<T extends InferenceModel>
- Type Parameters:
T
- model-type in pool
public class SegmentInstanceWithModel<T extends InferenceModel>
extends Task<StackSequenceInput,SharedStateSegmentInstance<T>>
Using a model-pool, performs instance segmentation on an image producing zero, one or more
objects per image.
Various visualizations and export types are supported.
- Segmentation results in vairous forms (HDF5) for input into other scripts. (in HDF5 form and as a mask).
- Visualizations of the instances found (outlines, thumbnails etc.)
- A table of basic features (CSV) for each instance.
Specifically, the following outputs are produced:
Output Name | Default? | Description |
---|---|---|
"input" | no | The input image for segmentation. |
"objects" | yes | Segmented object-masks encoded into HDF5. |
"mask" | yes | A binary-mask image that binary ors each voxel across the segmented object-masks (scaled to match the input image for model inference). |
"outline" | yes | A RGB image showing the outline of segmented-objects on top of the input image (scaled to match the input image for model inference). |
"mask""InputScale" | no | Like mask but on the full-scale input image. |
"outline""InputScale" | no | Like outline but on on the full-scale input image. |
"summary" | yes | A CSV file showing basic feature of all segmented-objects across all input images. |
"thumbnails"<S> | yes | A directory of thumbnails showing the outline of all segmented objects on top of an extracted portion of the respective input-image. |
outputs inherited from Task |
- Author:
- Owen Feehan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
afterAllJobsAreExecuted
(SharedStateSegmentInstance<T> sharedState, InputOutputContext context) Called once after all calls toTask.executeJob(org.anchoranalysis.experiment.task.ParametersUnbound<T, S>)
.beforeAnyJobIsExecuted
(Outputter outputter, ConcurrencyPlan plan, List<StackSequenceInput> inputs, ParametersExperiment parameters) Called once before all calls toTask.executeJob(org.anchoranalysis.experiment.task.ParametersUnbound<T, S>)
.If specified, default rules for determine which outputs are enabled or not.void
Performs the task on a particular input.Features to calculate for objects in the features output.The interpolator to use for scaling images.The color of the outline.int
The width of the outline.The segmentation algorithm.getStyle()
Visual style for how feature export occurs.boolean
Is the execution-time of the task per-input expected to be very quick to execute?Highest class(es) that will function as a valid input.boolean
When true, then the outputs (outline, mask, image etc.) are not written for images that produce no objects.boolean
When true, the colors change for different objects in the image (using a default color set).void
setFeatures
(List<NamedBean<FeatureListProvider<FeatureInputSingleObject>>> features) Features to calculate for objects in the features output.void
setIgnoreNoObjects
(boolean ignoreNoObjects) When true, then the outputs (outline, mask, image etc.) are not written for images that produce no objects.void
setInterpolator
(Interpolator interpolator) The interpolator to use for scaling images.void
setOutlineColor
(RGBColorBean outlineColor) The color of the outline.void
setOutlineWidth
(int outlineWidth) The width of the outline.void
setSegment
(SegmentStackIntoObjectsPooled<T> segment) The segmentation algorithm.void
setStyle
(ExportFeaturesStyle style) Visual style for how feature export occurs.void
setVaryColors
(boolean varyColors) When true, the colors change for different objects in the image (using a default color set).Methods inherited from class org.anchoranalysis.experiment.bean.task.Task
executeJob, isInputCompatibleWith
Methods inherited from class org.anchoranalysis.bean.AnchorBean
checkMisconfigured, describeBean, describeChildren, duplicateBean, fields, findFieldsOfClass, getBeanName, getLocalPath, localise, toString
-
Constructor Details
-
SegmentInstanceWithModel
public SegmentInstanceWithModel()
-
-
Method Details
-
inputTypesExpected
Description copied from class:Task
Highest class(es) that will function as a valid input.This is usually the class of T (or sometimes the absolute base class InputFromManager).
- Specified by:
inputTypesExpected
in classTask<StackSequenceInput,
SharedStateSegmentInstance<T extends InferenceModel>> - Returns:
- the input-types that a task expects.
-
beforeAnyJobIsExecuted
public SharedStateSegmentInstance<T> beforeAnyJobIsExecuted(Outputter outputter, ConcurrencyPlan plan, List<StackSequenceInput> inputs, ParametersExperiment parameters) throws ExperimentExecutionException Description copied from class:Task
Called once before all calls toTask.executeJob(org.anchoranalysis.experiment.task.ParametersUnbound<T, S>)
.- Specified by:
beforeAnyJobIsExecuted
in classTask<StackSequenceInput,
SharedStateSegmentInstance<T extends InferenceModel>> - Parameters:
outputter
- the output-manager for the experiment (not for an individual job)plan
- available numbers of processors that can callTask.executeJob(org.anchoranalysis.experiment.task.ParametersUnbound<T, S>)
inputs
- a list of inputs, each will result in at least one call toTask.executeJob(ParametersUnbound)
.parameters
- the experiment-parameters.- Returns:
- the shared-state that is passed to each call to
Task.executeJob(org.anchoranalysis.experiment.task.ParametersUnbound<T, S>)
and toTask.afterAllJobsAreExecuted(S, org.anchoranalysis.io.output.outputter.InputOutputContext)
. - Throws:
ExperimentExecutionException
- if a fatal error occurs executing this step of the experiment.
-
doJobOnInput
public void doJobOnInput(InputBound<StackSequenceInput, SharedStateSegmentInstance<T>> input) throws JobExecutionExceptionDescription copied from class:Task
Performs the task on a particular input.- Specified by:
doJobOnInput
in classTask<StackSequenceInput,
SharedStateSegmentInstance<T extends InferenceModel>> - Parameters:
input
- the input for the job.- Throws:
JobExecutionException
- if an error occurs executing a particular job, that is not otherwise suppressed.
-
hasVeryQuickPerInputExecution
public boolean hasVeryQuickPerInputExecution()Description copied from class:Task
Is the execution-time of the task per-input expected to be very quick to execute?- Specified by:
hasVeryQuickPerInputExecution
in classTask<StackSequenceInput,
SharedStateSegmentInstance<T extends InferenceModel>> - Returns:
- true iff the execution is expected to be very quick, false otherwise.
-
defaultOutputs
Description copied from class:Task
If specified, default rules for determine which outputs are enabled or not.- Overrides:
defaultOutputs
in classTask<StackSequenceInput,
SharedStateSegmentInstance<T extends InferenceModel>> - Returns:
- the default rules if they exist.
-
getSegment
The segmentation algorithm. -
setSegment
The segmentation algorithm. -
getOutlineColor
The color of the outline. -
isVaryColors
public boolean isVaryColors()When true, the colors change for different objects in the image (using a default color set).This takes precedence over
outlineColor
. -
setVaryColors
public void setVaryColors(boolean varyColors) When true, the colors change for different objects in the image (using a default color set).This takes precedence over
outlineColor
. -
getOutlineWidth
public int getOutlineWidth()The width of the outline. -
setOutlineWidth
public void setOutlineWidth(int outlineWidth) The width of the outline. -
getFeatures
Features to calculate for objects in the features output.If unspecified, default features of bounding-box coordinates and number of voxels are selected.
-
setFeatures
Features to calculate for objects in the features output.If unspecified, default features of bounding-box coordinates and number of voxels are selected.
-
isIgnoreNoObjects
public boolean isIgnoreNoObjects()When true, then the outputs (outline, mask, image etc.) are not written for images that produce no objects. -
setIgnoreNoObjects
public void setIgnoreNoObjects(boolean ignoreNoObjects) When true, then the outputs (outline, mask, image etc.) are not written for images that produce no objects. -
getStyle
Visual style for how feature export occurs. -
setStyle
Visual style for how feature export occurs. -
getInterpolator
The interpolator to use for scaling images. -
setInterpolator
The interpolator to use for scaling images.
-