Class GroupedStackBase<S,T>
Object
AnchorBean<Task<ProvidesStackInput, GroupedSharedState<S,T>>>
Task<ProvidesStackInput, GroupedSharedState<S,T>>
GroupedStackBase<S,T>
- Type Parameters:
S- individual-typeT- aggregate-type
- Direct Known Subclasses:
AggregateChannelTask,ExportImageHistograms
public abstract class GroupedStackBase<S,T>
extends Task<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 -
Method Summary
Modifier and TypeMethodDescriptionvoidafterAllJobsAreExecuted(GroupedSharedState<S, T> sharedState, InputOutputContext context) beforeAnyJobIsExecuted(Outputter outputter, ConcurrencyPlan concurrencyPlan, List<ProvidesStackInput> inputs, ParametersExperiment parameters) protected abstract CheckedFunction<Channel, S, CreateException> createChannelDeriver(ChannelSource source) A function to derive the individual type used for aggregation from aChannel.protected abstract GroupMapByName<S, T> createGroupMap(ConsistentChannelChecker channelChecker, Optional<Stream<String>> groupIdentifiers, Optional<InputOutputContext> outputContext, OperationContext operationContext) Creates a map for the storing an aggregate-data-object for each group.voiddoJobOnInput(InputBound<ProvidesStackInput, GroupedSharedState<S, T>> input) GroupergetGroup()How to partition the inputs into groups.InterpolatorThe interpolator to use for scaling images.SizeXYIf set, each channel is scaled to a specific size before aggregation (useful for combining different sized images).Selects which channels are included, optionally renaming.booleanInputTypesExpectedprotected abstract StringThe first-level output-name used for determining if groups are written.protected abstract voidprocessIndividual(String name, S individual, boolean partOfGroup, CheckedBiConsumer<String, S, OperationFailedException> consumeIndividual, InputOutputContext context) Processes each derived individual element from aChannel, callingconsumeIndividualone or more times.voidsetGroup(Grouper group) How to partition the inputs into groups.voidsetInterpolator(Interpolator interpolator) The interpolator to use for scaling images.voidsetResizeTo(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.An optional subdirectory where the group outputs are placed.Methods inherited from class org.anchoranalysis.experiment.bean.task.Task
defaultOutputs, executeJob, isInputCompatibleWithMethods inherited from class org.anchoranalysis.bean.AnchorBean
checkMisconfigured, describeBean, describeChildren, duplicateBean, fields, findFieldsOfClass, getBeanName, getLocalPath, localise, toString
-
Constructor Details
-
GroupedStackBase
public GroupedStackBase()
-
-
Method Details
-
inputTypesExpected
public InputTypesExpected inputTypesExpected()- Specified by:
inputTypesExpectedin classTask<ProvidesStackInput, GroupedSharedState<S,T>>
-
hasVeryQuickPerInputExecution
public boolean hasVeryQuickPerInputExecution()- Specified by:
hasVeryQuickPerInputExecutionin classTask<ProvidesStackInput, GroupedSharedState<S,T>>
-
beforeAnyJobIsExecuted
public GroupedSharedState<S,T> beforeAnyJobIsExecuted(Outputter outputter, ConcurrencyPlan concurrencyPlan, List<ProvidesStackInput> inputs, ParametersExperiment parameters) throws ExperimentExecutionException - Specified by:
beforeAnyJobIsExecutedin classTask<ProvidesStackInput, GroupedSharedState<S,T>> - Throws:
ExperimentExecutionException
-
doJobOnInput
public void doJobOnInput(InputBound<ProvidesStackInput, GroupedSharedState<S, T>> input) throws JobExecutionException- Specified by:
doJobOnInputin classTask<ProvidesStackInput, GroupedSharedState<S,T>> - Throws:
JobExecutionException
-
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(ConsistentChannelChecker channelChecker, Optional<Stream<String>> groupIdentifiers, Optional<InputOutputContext> outputContext, 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 CheckedFunction<Channel, S, CreateException> createChannelDeriver(ChannelSource source) throws OperationFailedException A 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:
OperationFailedException- if the channel-deriver cannot be successfully created.
-
processIndividual
protected abstract void processIndividual(String name, S individual, boolean partOfGroup, CheckedBiConsumer<String, S, OperationFailedException> consumeIndividual, InputOutputContext context) throws OperationFailedException Processes 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:
OperationFailedException- if anything goes wrong during processing.
-
getInterpolator
public Interpolator getInterpolator()The interpolator to use for scaling images. -
setInterpolator
public void setInterpolator(Interpolator interpolator) The interpolator to use for scaling images. -
getGroup
public Grouper getGroup()How to partition the inputs into groups. -
setGroup
public void setGroup(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 SizeXY getResizeTo()If set, each channel is scaled to a specific size before aggregation (useful for combining different sized images). -
setResizeTo
public void setResizeTo(SizeXY resizeTo) If set, each channel is scaled to a specific size before aggregation (useful for combining different sized images).
-