Class ExportImageHistograms

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<org.anchoranalysis.math.histogram.Histogram,​org.anchoranalysis.math.histogram.Histogram>
org.anchoranalysis.plugin.image.task.bean.grouped.histogram.ExportImageHistograms

public class ExportImageHistograms
extends GroupedStackBase<org.anchoranalysis.math.histogram.Histogram,​org.anchoranalysis.math.histogram.Histogram>
Exports a histogram of voxel intensities as a CSV file for each channel of an image.

Additionally, a histogram with the summation of voxel intensities for all channels in each image is produced.

Optionally, one channel can be used as a mask, to restrict which voxels are included in the histogram.

These steps occur:

  1. All files are aggregated into groups.
  2. For each image file, a histogram is calculated.
  3. The histogram is added to the group histogram.
  4. The histograms are written to the filesystem.

The following outputs are produced:

Output NameDefault?Description
"channels"yesA separate CSV histogram for each channel's voxels intensity.
"sum"yesA histogram for the sum of each voxel's intensity across all channels.
inherited from Task
  • Constructor Summary

    Constructors 
    Constructor Description
    ExportImageHistograms()  
  • Method Summary

    Modifier and Type Method Description
    protected org.anchoranalysis.core.functional.checked.CheckedFunction<org.anchoranalysis.image.core.channel.Channel,​org.anchoranalysis.math.histogram.Histogram,​org.anchoranalysis.core.exception.CreateException> createChannelDeriver​(ChannelSource source)
    A function to derive the individual type used for aggregation from a Channel.
    protected GroupMapByName<org.anchoranalysis.math.histogram.Histogram,​org.anchoranalysis.math.histogram.Histogram> 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.
    org.anchoranalysis.io.output.enabled.OutputEnabledMutable defaultOutputs()  
    String getChannelMask()
    If defined, this is the name of channel used as a mask over the values which are fed into the histogram
    int getMaskValue()
    What voxel value to read as "On" in the mask above.
    boolean isCsvIgnoreZeros()
    Iff true, bins with zero-counts are not written as a row in the CSV file.
    protected String outputNameForGroups()
    The first-level output-name used for determining if groups are written.
    protected void processIndividual​(String name, org.anchoranalysis.math.histogram.Histogram individual, boolean partOfGroup, org.anchoranalysis.core.functional.checked.CheckedBiConsumer<String,​org.anchoranalysis.math.histogram.Histogram,​org.anchoranalysis.core.exception.OperationFailedException> consumeIndividual, org.anchoranalysis.io.output.outputter.InputOutputContext context)
    Processes each derived individual element from a Channel, calling consumeIndividual one or more times.
    void setChannelMask​(String channelMask)
    If defined, this is the name of channel used as a mask over the values which are fed into the histogram
    void setCsvIgnoreZeros​(boolean csvIgnoreZeros)
    Iff true, bins with zero-counts are not written as a row in the CSV file.
    void setMaskValue​(int maskValue)
    What voxel value to read as "On" in the mask above.
    protected Optional<String> subdirectoryForGroupOutputs()
    An optional subdirectory where the group outputs are placed.

    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

    Methods inherited from class java.lang.Object

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

  • Method Details

    • defaultOutputs

      public org.anchoranalysis.io.output.enabled.OutputEnabledMutable defaultOutputs()
      Overrides:
      defaultOutputs in class org.anchoranalysis.experiment.bean.task.Task<org.anchoranalysis.image.io.stack.input.ProvidesStackInput,​GroupedSharedState<org.anchoranalysis.math.histogram.Histogram,​org.anchoranalysis.math.histogram.Histogram>>
    • createGroupMap

      protected GroupMapByName<org.anchoranalysis.math.histogram.Histogram,​org.anchoranalysis.math.histogram.Histogram> 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)
      Description copied from class: GroupedStackBase
      Creates a map for the storing an aggregate-data-object for each group.
      Specified by:
      createGroupMap in class GroupedStackBase<org.anchoranalysis.math.histogram.Histogram,​org.anchoranalysis.math.histogram.Histogram>
      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.
    • subdirectoryForGroupOutputs

      protected Optional<String> subdirectoryForGroupOutputs()
      Description copied from class: GroupedStackBase
      An optional subdirectory where the group outputs are placed.
      Specified by:
      subdirectoryForGroupOutputs in class GroupedStackBase<org.anchoranalysis.math.histogram.Histogram,​org.anchoranalysis.math.histogram.Histogram>
      Returns:
      an Optional containing the subdirectory name as a String, or Optional.empty() if no subdirectory is specified.
    • createChannelDeriver

      protected org.anchoranalysis.core.functional.checked.CheckedFunction<org.anchoranalysis.image.core.channel.Channel,​org.anchoranalysis.math.histogram.Histogram,​org.anchoranalysis.core.exception.CreateException> createChannelDeriver​(ChannelSource source) throws org.anchoranalysis.core.exception.OperationFailedException
      Description copied from class: GroupedStackBase
      A function to derive the individual type used for aggregation from a Channel.
      Specified by:
      createChannelDeriver in class GroupedStackBase<org.anchoranalysis.math.histogram.Histogram,​org.anchoranalysis.math.histogram.Histogram>
      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:
      org.anchoranalysis.core.exception.OperationFailedException - if the channel-deriver cannot be successfully created.
    • processIndividual

      protected void processIndividual​(String name, org.anchoranalysis.math.histogram.Histogram individual, boolean partOfGroup, org.anchoranalysis.core.functional.checked.CheckedBiConsumer<String,​org.anchoranalysis.math.histogram.Histogram,​org.anchoranalysis.core.exception.OperationFailedException> consumeIndividual, org.anchoranalysis.io.output.outputter.InputOutputContext context) throws org.anchoranalysis.core.exception.OperationFailedException
      Description copied from class: GroupedStackBase
      Processes each derived individual element from a Channel, calling consumeIndividual one or more times.
      Specified by:
      processIndividual in class GroupedStackBase<org.anchoranalysis.math.histogram.Histogram,​org.anchoranalysis.math.histogram.Histogram>
      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.
    • outputNameForGroups

      protected String outputNameForGroups()
      Description copied from class: GroupedStackBase
      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.

      Specified by:
      outputNameForGroups in class GroupedStackBase<org.anchoranalysis.math.histogram.Histogram,​org.anchoranalysis.math.histogram.Histogram>
      Returns:
      the output-name.
    • getChannelMask

      public String getChannelMask()
      If defined, this is the name of channel used as a mask over the values which are fed into the histogram
    • setChannelMask

      public void setChannelMask​(String channelMask)
      If defined, this is the name of channel used as a mask over the values which are fed into the histogram
    • getMaskValue

      public int getMaskValue()
      What voxel value to read as "On" in the mask above.
    • setMaskValue

      public void setMaskValue​(int maskValue)
      What voxel value to read as "On" in the mask above.
    • isCsvIgnoreZeros

      public boolean isCsvIgnoreZeros()
      Iff true, bins with zero-counts are not written as a row in the CSV file.
    • setCsvIgnoreZeros

      public void setCsvIgnoreZeros​(boolean csvIgnoreZeros)
      Iff true, bins with zero-counts are not written as a row in the CSV file.