Class GroupedStackBase<S,T>

Object
AnchorBean<Task<ProvidesStackInput, GroupedSharedState<S,T>>>
Task<ProvidesStackInput, GroupedSharedState<S,T>>
GroupedStackBase<S,T>
Type Parameters:
S - individual-type
T - 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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    afterAllJobsAreExecuted(GroupedSharedState<S,T> sharedState, InputOutputContext context)
     
    beforeAnyJobIsExecuted(Outputter outputter, ConcurrencyPlan concurrencyPlan, List<ProvidesStackInput> inputs, ParametersExperiment parameters)
     
    protected abstract CheckedFunction<Channel, S, CreateException>
    A function to derive the individual type used for aggregation from a Channel.
    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
    doJobOnInput(InputBound<ProvidesStackInput, GroupedSharedState<S,T>> input)
     
    Grouper
    How to partition the inputs into groups.
    Interpolator
    The interpolator to use for scaling images.
    SizeXY
    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
     
    InputTypesExpected
     
    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 a Channel, calling consumeIndividual one or more times.
    void
    setGroup(Grouper group)
    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.
    protected abstract Optional<String>
    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • GroupedStackBase

      public GroupedStackBase()
  • Method Details

    • inputTypesExpected

      public InputTypesExpected inputTypesExpected()
      Specified by:
      inputTypesExpected in class Task<ProvidesStackInput, GroupedSharedState<S,T>>
    • hasVeryQuickPerInputExecution

      public boolean hasVeryQuickPerInputExecution()
      Specified by:
      hasVeryQuickPerInputExecution in class Task<ProvidesStackInput, GroupedSharedState<S,T>>
    • beforeAnyJobIsExecuted

      public GroupedSharedState<S,T> beforeAnyJobIsExecuted(Outputter outputter, ConcurrencyPlan concurrencyPlan, List<ProvidesStackInput> inputs, ParametersExperiment parameters) throws ExperimentExecutionException
      Specified by:
      beforeAnyJobIsExecuted in class Task<ProvidesStackInput, GroupedSharedState<S,T>>
      Throws:
      ExperimentExecutionException
    • doJobOnInput

      public void doJobOnInput(InputBound<ProvidesStackInput, GroupedSharedState<S,T>> input) throws JobExecutionException
      Specified by:
      doJobOnInput in class Task<ProvidesStackInput, GroupedSharedState<S,T>>
      Throws:
      JobExecutionException
    • afterAllJobsAreExecuted

      public void afterAllJobsAreExecuted(GroupedSharedState<S,T> sharedState, InputOutputContext context) throws ExperimentExecutionException
      Specified by:
      afterAllJobsAreExecuted in class Task<ProvidesStackInput, GroupedSharedState<S,T>>
      Throws:
      ExperimentExecutionException
    • outputNameForGroups

      protected abstract String 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

      protected abstract Optional<String> subdirectoryForGroupOutputs()
      An optional subdirectory where the group outputs are placed.
      Returns:
      an Optional containing the subdirectory name as a String, or Optional.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 a Channel.
      Parameters:
      source - how to retrieve a Channel, appropriately-sized.
      Returns:
      a function, that given a Channel will return an individual element of type T.
      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 a Channel, calling consumeIndividual 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

      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

      public FromStacks getSelectChannels()
      Selects which channels are included, optionally renaming.
    • setSelectChannels

      public void setSelectChannels(FromStacks selectChannels)
      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).