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:
- All files are aggregated into groups.
- For each image file, a histogram is calculated.
- The histogram is added to the group histogram.
- The histograms are written to the filesystem.
The following outputs are produced:
| Output Name | Default? | Description |
|---|---|---|
| "channels" | yes | A separate CSV histogram for each channel's voxels intensity. |
| "sum" | yes | A 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 aChannel.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.OutputEnabledMutabledefaultOutputs()StringgetChannelMask()If defined, this is the name of channel used as a mask over the values which are fed into the histogramintgetMaskValue()What voxel value to read as "On" in the mask above.booleanisCsvIgnoreZeros()Iff true, bins with zero-counts are not written as a row in the CSV file.protected StringoutputNameForGroups()The first-level output-name used for determining if groups are written.protected voidprocessIndividual(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 aChannel, callingconsumeIndividualone or more times.voidsetChannelMask(String channelMask)If defined, this is the name of channel used as a mask over the values which are fed into the histogramvoidsetCsvIgnoreZeros(boolean csvIgnoreZeros)Iff true, bins with zero-counts are not written as a row in the CSV file.voidsetMaskValue(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.plugin.image.task.bean.grouped.GroupedStackBase
afterAllJobsAreExecuted, beforeAnyJobIsExecuted, doJobOnInput, getGroup, getInterpolator, getResizeTo, getSelectChannels, hasVeryQuickPerInputExecution, inputTypesExpected, setGroup, setInterpolator, setResizeTo, setSelectChannelsMethods inherited from class org.anchoranalysis.experiment.bean.task.Task
executeJob, isInputCompatibleWith
-
Constructor Details
-
ExportImageHistograms
public ExportImageHistograms()
-
-
Method Details
-
defaultOutputs
public org.anchoranalysis.io.output.enabled.OutputEnabledMutable defaultOutputs()- Overrides:
defaultOutputsin classorg.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:GroupedStackBaseCreates a map for the storing an aggregate-data-object for each group.- Specified by:
createGroupMapin classGroupedStackBase<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
Description copied from class:GroupedStackBaseAn optional subdirectory where the group outputs are placed.- Specified by:
subdirectoryForGroupOutputsin classGroupedStackBase<org.anchoranalysis.math.histogram.Histogram,org.anchoranalysis.math.histogram.Histogram>- Returns:
- an
Optionalcontaining the subdirectory name as aString, orOptional.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.OperationFailedExceptionDescription copied from class:GroupedStackBaseA function to derive the individual type used for aggregation from aChannel.- Specified by:
createChannelDeriverin classGroupedStackBase<org.anchoranalysis.math.histogram.Histogram,org.anchoranalysis.math.histogram.Histogram>- Parameters:
source- how to retrieve aChannel, appropriately-sized.- Returns:
- a function, that given a
Channelwill return an individual element of typeT. - 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.OperationFailedExceptionDescription copied from class:GroupedStackBaseProcesses each derived individual element from aChannel, callingconsumeIndividualone or more times.- Specified by:
processIndividualin classGroupedStackBase<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
Description copied from class:GroupedStackBaseThe 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:
outputNameForGroupsin classGroupedStackBase<org.anchoranalysis.math.histogram.Histogram,org.anchoranalysis.math.histogram.Histogram>- Returns:
- the output-name.
-
getChannelMask
If defined, this is the name of channel used as a mask over the values which are fed into the histogram -
setChannelMask
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.
-