Class ExportImageHistograms
Object
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 -
Method Summary
Modifier and TypeMethodDescriptionprotected CheckedFunction<Channel, Histogram, CreateException> createChannelDeriver(ChannelSource source) A function to derive the individual type used for aggregation from aChannel.protected GroupMapByName<Histogram, Histogram> 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.If specified, default rules for determine which outputs are enabled or not.If defined, this is the name of channel used as a mask over the values which are fed into the histogramintWhat voxel value to read as "On" in the mask above.booleanIff true, bins with zero-counts are not written as a row in the CSV file.protected StringThe first-level output-name used for determining if groups are written.protected voidprocessIndividual(String name, Histogram individual, boolean partOfGroup, CheckedBiConsumer<String, Histogram, OperationFailedException> consumeIndividual, 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.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, isInputCompatibleWithMethods inherited from class org.anchoranalysis.bean.AnchorBean
checkMisconfigured, describeBean, describeChildren, duplicateBean, fields, findFieldsOfClass, getBeanName, getLocalPath, localise, toString
-
Constructor Details
-
ExportImageHistograms
public ExportImageHistograms()
-
-
Method Details
-
defaultOutputs
Description copied from class:TaskIf specified, default rules for determine which outputs are enabled or not.- Overrides:
defaultOutputsin classTask<ProvidesStackInput,GroupedSharedState<Histogram, Histogram>> - Returns:
- the default rules if they exist.
-
createGroupMap
protected GroupMapByName<Histogram,Histogram> createGroupMap(ConsistentChannelChecker channelChecker, Optional<Stream<String>> groupIdentifiers, Optional<InputOutputContext> outputContext, OperationContext operationContext) Description copied from class:GroupedStackBaseCreates a map for the storing an aggregate-data-object for each group.- Specified by:
createGroupMapin classGroupedStackBase<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<Histogram,Histogram> - Returns:
- an
Optionalcontaining the subdirectory name as aString, orOptional.empty()if no subdirectory is specified.
-
createChannelDeriver
protected CheckedFunction<Channel,Histogram, createChannelDeriverCreateException> (ChannelSource source) throws OperationFailedException Description copied from class:GroupedStackBaseA function to derive the individual type used for aggregation from aChannel.- Specified by:
createChannelDeriverin classGroupedStackBase<Histogram,Histogram> - Parameters:
source- how to retrieve aChannel, appropriately-sized.- Returns:
- a function, that given a
Channelwill return an individual element of typeT. - Throws:
OperationFailedException- if the channel-deriver cannot be successfully created.
-
processIndividual
protected void processIndividual(String name, Histogram individual, boolean partOfGroup, CheckedBiConsumer<String, Histogram, throws OperationFailedExceptionOperationFailedException> consumeIndividual, InputOutputContext context) Description copied from class:GroupedStackBaseProcesses each derived individual element from aChannel, callingconsumeIndividualone or more times.- Specified by:
processIndividualin classGroupedStackBase<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
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<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.
-