Class 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
Channel
is converted in the image. - The aggregated type, when multiple individual types are combined.
- Author:
- Owen Feehan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
afterAllJobsAreExecuted
(GroupedSharedState<S, T> sharedState, InputOutputContext context) Called once after all calls toTask.executeJob(org.anchoranalysis.experiment.task.ParametersUnbound<T, S>)
.beforeAnyJobIsExecuted
(Outputter outputter, ConcurrencyPlan concurrencyPlan, List<ProvidesStackInput> inputs, ParametersExperiment parameters) Called once before all calls toTask.executeJob(org.anchoranalysis.experiment.task.ParametersUnbound<T, S>)
.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.void
Performs the task on a particular input.getGroup()
How to partition the inputs into groups.The interpolator to use for scaling images.If set, each channel is scaled to a specific size before aggregation (useful for combining different sized images).Selects which channels are included, optionally renaming.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.protected abstract String
The first-level output-name used for determining if groups are written.protected abstract void
processIndividual
(String name, S individual, boolean partOfGroup, CheckedBiConsumer<String, S, OperationFailedException> consumeIndividual, InputOutputContext context) Processes each derived individual element from aChannel
, callingconsumeIndividual
one or more times.void
How to partition the inputs into groups.void
setInterpolator
(Interpolator interpolator) The interpolator to use for scaling images.void
setResizeTo
(SizeXY resizeTo) If set, each channel is scaled to a specific size before aggregation (useful for combining different sized images).void
setSelectChannels
(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, isInputCompatibleWith
Methods 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
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<ProvidesStackInput,
GroupedSharedState<S, T>> - Returns:
- the input-types that a task expects.
-
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<ProvidesStackInput,
GroupedSharedState<S, T>> - Returns:
- true iff the execution is expected to be very quick, false otherwise.
-
beforeAnyJobIsExecuted
public GroupedSharedState<S,T> beforeAnyJobIsExecuted(Outputter outputter, ConcurrencyPlan concurrencyPlan, List<ProvidesStackInput> 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<ProvidesStackInput,
GroupedSharedState<S, T>> - Parameters:
outputter
- the output-manager for the experiment (not for an individual job)concurrencyPlan
- 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<ProvidesStackInput, GroupedSharedState<S, throws JobExecutionExceptionT>> input) Description copied from class:Task
Performs the task on a particular input.- Specified by:
doJobOnInput
in classTask<ProvidesStackInput,
GroupedSharedState<S, T>> - Parameters:
input
- the input for the job.- Throws:
JobExecutionException
- if an error occurs executing a particular job, that is not otherwise suppressed.
-
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
Optional
containing 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, createChannelDeriverCreateException> (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
Channel
will 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, throws OperationFailedExceptionOperationFailedException> consumeIndividual, InputOutputContext context) Processes each derived individual element from aChannel
, callingconsumeIndividual
one 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
The interpolator to use for scaling images. -
setInterpolator
The interpolator to use for scaling images. -
getGroup
How to partition the inputs into groups. -
setGroup
How to partition the inputs into groups. -
getSelectChannels
Selects which channels are included, optionally renaming. -
setSelectChannels
Selects which channels are included, optionally renaming. -
getResizeTo
If set, each channel is scaled to a specific size before aggregation (useful for combining different sized images). -
setResizeTo
If set, each channel is scaled to a specific size before aggregation (useful for combining different sized images).
-