Class ExportImageHistograms

Object
AnchorBean<Task<ProvidesStackInput, GroupedSharedState<Histogram, Histogram>>>
Task<ProvidesStackInput, GroupedSharedState<Histogram, Histogram>>
GroupedStackBase<Histogram, Histogram>
ExportImageHistograms

public class ExportImageHistograms extends GroupedStackBase<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 Details

    • ExportImageHistograms

      public ExportImageHistograms()
  • Method Details

    • defaultOutputs

      public OutputEnabledMutable defaultOutputs()
      Overrides:
      defaultOutputs in class Task<ProvidesStackInput, GroupedSharedState<Histogram, Histogram>>
    • createGroupMap

      protected GroupMapByName<Histogram, Histogram> createGroupMap(ConsistentChannelChecker channelChecker, Optional<Stream<String>> groupIdentifiers, Optional<InputOutputContext> outputContext, 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<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<Histogram, Histogram>
      Returns:
      an Optional containing the subdirectory name as a String, or Optional.empty() if no subdirectory is specified.
    • createChannelDeriver

      protected CheckedFunction<Channel, Histogram, CreateException> createChannelDeriver(ChannelSource source) throws 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<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:
      OperationFailedException - if the channel-deriver cannot be successfully created.
    • processIndividual

      protected void processIndividual(String name, Histogram individual, boolean partOfGroup, CheckedBiConsumer<String, Histogram, OperationFailedException> consumeIndividual, InputOutputContext context) throws 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<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:
      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<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.