Class GroupedStackBase<S,T>
Object
org.anchoranalysis.bean.AnchorBean<org.anchoranalysis.experiment.bean.task.Task<T,S>>
org.anchoranalysis.experiment.bean.task.Task<org.anchoranalysis.image.io.stack.input.ProvidesStackInput,GroupedSharedState<S,T>>
org.anchoranalysis.plugin.image.task.bean.grouped.GroupedStackBase<S,T>
- Type Parameters:
S- individual-typeT- aggregate-type
- Direct Known Subclasses:
AggregateChannelTask,ExportImageHistograms
public abstract class GroupedStackBase<S,T> extends org.anchoranalysis.experiment.bean.task.Task<org.anchoranalysis.image.io.stack.input.ProvidesStackInput,GroupedSharedState<S,T>>
Base class for stacks (usually each channel from an image) that are somehow grouped-together.
Two types of entities are considered:
- The individual type, to which a
Channelis converted in the image. - The aggregated type, when multiple individual types are combined.
- Author:
- Owen Feehan
-
Constructor Summary
Constructors Constructor Description GroupedStackBase() -
Method Summary
Modifier and Type Method Description voidafterAllJobsAreExecuted(GroupedSharedState<S,T> sharedState, org.anchoranalysis.io.output.outputter.InputOutputContext context)GroupedSharedState<S,T>beforeAnyJobIsExecuted(org.anchoranalysis.io.output.outputter.Outputter outputter, org.anchoranalysis.inference.concurrency.ConcurrencyPlan concurrencyPlan, List<org.anchoranalysis.image.io.stack.input.ProvidesStackInput> inputs, org.anchoranalysis.experiment.task.ParametersExperiment parameters)protected abstract org.anchoranalysis.core.functional.checked.CheckedFunction<org.anchoranalysis.image.core.channel.Channel,S,org.anchoranalysis.core.exception.CreateException>createChannelDeriver(ChannelSource source)A function to derive the individual type used for aggregation from aChannel.protected abstract GroupMapByName<S,T>createGroupMap(org.anchoranalysis.image.bean.nonbean.ConsistentChannelChecker channelChecker, Optional<Stream<String>> groupIdentifiers, Optional<org.anchoranalysis.io.output.outputter.InputOutputContext> outputContext, org.anchoranalysis.core.time.OperationContext operationContext)Creates a map for the storing an aggregate-data-object for each group.voiddoJobOnInput(org.anchoranalysis.experiment.task.InputBound<org.anchoranalysis.image.io.stack.input.ProvidesStackInput,GroupedSharedState<S,T>> input)org.anchoranalysis.io.input.bean.grouper.GroupergetGroup()How to partition the inputs into groups.org.anchoranalysis.image.bean.interpolator.InterpolatorgetInterpolator()The interpolator to use for scaling images.org.anchoranalysis.image.bean.spatial.SizeXYgetResizeTo()If set, each channel is scaled to a specific size before aggregation (useful for combining different sized images).FromStacksgetSelectChannels()Selects which channels are included, optionally renaming.booleanhasVeryQuickPerInputExecution()org.anchoranalysis.experiment.task.InputTypesExpectedinputTypesExpected()protected abstract StringoutputNameForGroups()The first-level output-name used for determining if groups are written.protected abstract voidprocessIndividual(String name, S individual, boolean partOfGroup, org.anchoranalysis.core.functional.checked.CheckedBiConsumer<String,S,org.anchoranalysis.core.exception.OperationFailedException> consumeIndividual, org.anchoranalysis.io.output.outputter.InputOutputContext context)Processes each derived individual element from aChannel, callingconsumeIndividualone or more times.voidsetGroup(org.anchoranalysis.io.input.bean.grouper.Grouper group)How to partition the inputs into groups.voidsetInterpolator(org.anchoranalysis.image.bean.interpolator.Interpolator interpolator)The interpolator to use for scaling images.voidsetResizeTo(org.anchoranalysis.image.bean.spatial.SizeXY resizeTo)If set, each channel is scaled to a specific size before aggregation (useful for combining different sized images).voidsetSelectChannels(FromStacks selectChannels)Selects which channels are included, optionally renaming.protected abstract Optional<String>subdirectoryForGroupOutputs()An optional subdirectory where the group outputs are placed.Methods inherited from class org.anchoranalysis.experiment.bean.task.Task
defaultOutputs, executeJob, isInputCompatibleWith
-
Constructor Details
-
GroupedStackBase
public GroupedStackBase()
-
-
Method Details
-
inputTypesExpected
public org.anchoranalysis.experiment.task.InputTypesExpected inputTypesExpected()- Specified by:
inputTypesExpectedin classorg.anchoranalysis.experiment.bean.task.Task<org.anchoranalysis.image.io.stack.input.ProvidesStackInput,GroupedSharedState<S,T>>
-
hasVeryQuickPerInputExecution
public boolean hasVeryQuickPerInputExecution()- Specified by:
hasVeryQuickPerInputExecutionin classorg.anchoranalysis.experiment.bean.task.Task<org.anchoranalysis.image.io.stack.input.ProvidesStackInput,GroupedSharedState<S,T>>
-
beforeAnyJobIsExecuted
public GroupedSharedState<S,T> beforeAnyJobIsExecuted(org.anchoranalysis.io.output.outputter.Outputter outputter, org.anchoranalysis.inference.concurrency.ConcurrencyPlan concurrencyPlan, List<org.anchoranalysis.image.io.stack.input.ProvidesStackInput> inputs, org.anchoranalysis.experiment.task.ParametersExperiment parameters) throws org.anchoranalysis.experiment.ExperimentExecutionException- Specified by:
beforeAnyJobIsExecutedin classorg.anchoranalysis.experiment.bean.task.Task<org.anchoranalysis.image.io.stack.input.ProvidesStackInput,GroupedSharedState<S,T>>- Throws:
org.anchoranalysis.experiment.ExperimentExecutionException
-
doJobOnInput
public void doJobOnInput(org.anchoranalysis.experiment.task.InputBound<org.anchoranalysis.image.io.stack.input.ProvidesStackInput,GroupedSharedState<S,T>> input) throws org.anchoranalysis.experiment.JobExecutionException- Specified by:
doJobOnInputin classorg.anchoranalysis.experiment.bean.task.Task<org.anchoranalysis.image.io.stack.input.ProvidesStackInput,GroupedSharedState<S,T>>- Throws:
org.anchoranalysis.experiment.JobExecutionException
-
afterAllJobsAreExecuted
public void afterAllJobsAreExecuted(GroupedSharedState<S,T> sharedState, org.anchoranalysis.io.output.outputter.InputOutputContext context) throws org.anchoranalysis.experiment.ExperimentExecutionException- Specified by:
afterAllJobsAreExecutedin classorg.anchoranalysis.experiment.bean.task.Task<org.anchoranalysis.image.io.stack.input.ProvidesStackInput,GroupedSharedState<S,T>>- Throws:
org.anchoranalysis.experiment.ExperimentExecutionException
-
outputNameForGroups
The first-level output-name used for determining if groups are written.Second-level matches against this, and will determine which specific groups may or may not be written.
- Returns:
- the output-name.
-
subdirectoryForGroupOutputs
An optional subdirectory where the group outputs are placed.- Returns:
- an
Optionalcontaining the subdirectory name as aString, orOptional.empty()if no subdirectory is specified.
-
createGroupMap
protected abstract GroupMapByName<S,T> createGroupMap(org.anchoranalysis.image.bean.nonbean.ConsistentChannelChecker channelChecker, Optional<Stream<String>> groupIdentifiers, Optional<org.anchoranalysis.io.output.outputter.InputOutputContext> outputContext, org.anchoranalysis.core.time.OperationContext operationContext)Creates a map for the storing an aggregate-data-object for each group.- Parameters:
channelChecker- checks that the channels of all relevant stacks have the same size and data-type.groupIdentifiers- a stream with each group-identifier that should be added to the map.outputContext- where to write results to when a group is processed.operationContext- supporting entities for the operation.- Returns:
- a newly created map.
-
createChannelDeriver
protected abstract org.anchoranalysis.core.functional.checked.CheckedFunction<org.anchoranalysis.image.core.channel.Channel,S,org.anchoranalysis.core.exception.CreateException> createChannelDeriver(ChannelSource source) throws org.anchoranalysis.core.exception.OperationFailedExceptionA function to derive the individual type used for aggregation from aChannel.- Parameters:
source- how to retrieve aChannel, appropriately-sized.- Returns:
- a function, that given a
Channelwill return an individual element of typeT. - Throws:
org.anchoranalysis.core.exception.OperationFailedException- if the channel-deriver cannot be successfully created.
-
processIndividual
protected abstract void processIndividual(String name, S individual, boolean partOfGroup, org.anchoranalysis.core.functional.checked.CheckedBiConsumer<String,S,org.anchoranalysis.core.exception.OperationFailedException> consumeIndividual, org.anchoranalysis.io.output.outputter.InputOutputContext context) throws org.anchoranalysis.core.exception.OperationFailedExceptionProcesses each derived individual element from aChannel, callingconsumeIndividualone or more times.- Parameters:
name- the name of the channel.individual- the derived-individual element.partOfGroup- true when the item is part of a group, false otherwise.consumeIndividual- a function that should be called one or more times for the individual element, or sub-elements of it.context- supporting entities for the operation.- Throws:
org.anchoranalysis.core.exception.OperationFailedException- if anything goes wrong during processing.
-
getInterpolator
public org.anchoranalysis.image.bean.interpolator.Interpolator getInterpolator()The interpolator to use for scaling images. -
setInterpolator
public void setInterpolator(org.anchoranalysis.image.bean.interpolator.Interpolator interpolator)The interpolator to use for scaling images. -
getGroup
public org.anchoranalysis.io.input.bean.grouper.Grouper getGroup()How to partition the inputs into groups. -
setGroup
public void setGroup(org.anchoranalysis.io.input.bean.grouper.Grouper group)How to partition the inputs into groups. -
getSelectChannels
Selects which channels are included, optionally renaming. -
setSelectChannels
Selects which channels are included, optionally renaming. -
getResizeTo
public org.anchoranalysis.image.bean.spatial.SizeXY getResizeTo()If set, each channel is scaled to a specific size before aggregation (useful for combining different sized images). -
setResizeTo
public void setResizeTo(org.anchoranalysis.image.bean.spatial.SizeXY resizeTo)If set, each channel is scaled to a specific size before aggregation (useful for combining different sized images).
-