Class FeatureExporter<S>
Object
org.anchoranalysis.plugin.image.task.feature.FeatureExporter<S>
- Type Parameters:
S- a source-of-rows that is duplicated for each new thread (to prevent any concurrency issues)
public class FeatureExporter<S> extends Object
Shared-state for an
ExportFeatures task.- Author:
- Owen Feehan
-
Field Summary
Fields Modifier and Type Field Description static StringOUTPUT_THUMBNAILSThe output-name for writing thumbnails. -
Constructor Summary
Constructors Constructor Description FeatureExporter(org.anchoranalysis.feature.io.results.FeatureOutputMetadata outputMetadata, Supplier<S> featureSource, Optional<org.anchoranalysis.io.input.grouper.InputGrouper> grouper, FeatureExporterContext context)Creates the shared state. -
Method Summary
Modifier and Type Method Description voidcloseAndWriteOutputs(Optional<org.anchoranalysis.feature.store.NamedFeatureStore<org.anchoranalysis.feature.input.FeatureInputResults>> featuresAggregate, boolean includeGroups, Function<org.anchoranalysis.io.output.outputter.InputOutputContext,org.anchoranalysis.feature.io.csv.results.FeatureCSVWriterFactory> csvWriterCreator, org.anchoranalysis.io.output.outputter.InputOutputContext context)Writes all the results that have been collected as a CSV file, and closes open I/O handles and memory structures.static <T extends org.anchoranalysis.feature.input.FeatureInput>
FeatureExporter<org.anchoranalysis.feature.bean.list.FeatureList<T>>create(List<org.anchoranalysis.bean.NamedBean<org.anchoranalysis.feature.bean.list.FeatureListProvider<T>>> features, org.anchoranalysis.feature.io.csv.metadata.LabelHeaders metadataHeaders, org.anchoranalysis.feature.io.results.FeatureOutputNames outputNames, Optional<org.anchoranalysis.io.input.grouper.InputGrouper> grouper, FeatureExporterContext context)Alternative static constructor that creates a shared-state from a list of namedFeatureListProviders.static <T extends org.anchoranalysis.feature.input.FeatureInput>
FeatureExporter<org.anchoranalysis.image.feature.calculator.FeatureTableCalculator<T>>create(org.anchoranalysis.feature.io.results.FeatureOutputNames outputNames, org.anchoranalysis.image.feature.calculator.FeatureTableCalculator<T> features, org.anchoranalysis.feature.io.csv.metadata.LabelHeaders identifierHeaders, Optional<org.anchoranalysis.io.input.grouper.InputGrouper> grouper, FeatureExporterContext context)Alternative static constructor that creates a shared-state from aNamedFeatureStore.static <T extends org.anchoranalysis.feature.input.FeatureInput>
FeatureExporter<org.anchoranalysis.feature.bean.list.FeatureList<T>>create(org.anchoranalysis.feature.store.NamedFeatureStore<T> featureStore, org.anchoranalysis.feature.io.csv.metadata.LabelHeaders metadataHeaders, org.anchoranalysis.feature.io.results.FeatureOutputNames outputNames, Optional<org.anchoranalysis.io.input.grouper.InputGrouper> grouper, FeatureExporterContext context)Alternative static constructor that creates a shared-state from aNamedFeatureStore.FeatureCalculationContext<S>createCalculationContext(Optional<String> groupName, org.anchoranalysis.core.time.ExecutionTimeRecorder executionTimeRecorder, org.anchoranalysis.io.output.outputter.InputOutputContext ioContext)Creates aFeatureCalculationContextfor calculating features to later use this exporter.org.anchoranalysis.feature.name.FeatureNameListgetFeatureNames()The names of the features to be exported.Optional<org.anchoranalysis.io.input.grouper.InputGrouper>getGrouper()When defined, assigns each input to a group.FeatureResultsAndThumbnailsgetResults()Saved store feature calculation results, and writes associated thumbnails.
-
Field Details
-
OUTPUT_THUMBNAILS
The output-name for writing thumbnails.- See Also:
- Constant Field Values
-
-
Constructor Details
-
FeatureExporter
public FeatureExporter(org.anchoranalysis.feature.io.results.FeatureOutputMetadata outputMetadata, Supplier<S> featureSource, Optional<org.anchoranalysis.io.input.grouper.InputGrouper> grouper, FeatureExporterContext context) throws org.anchoranalysis.io.output.error.OutputWriteFailedExceptionCreates the shared state.- Parameters:
outputMetadata- headers and output-name for the feature CSV file that is written.featureSource- source of rows in the feature-table (called independently for each thread).grouper- when defined, assigns each input to a group.context- context for exporting features.- Throws:
org.anchoranalysis.io.output.error.OutputWriteFailedException- if there's an error during output writing
-
-
Method Details
-
create
public static <T extends org.anchoranalysis.feature.input.FeatureInput> FeatureExporter<org.anchoranalysis.feature.bean.list.FeatureList<T>> create(List<org.anchoranalysis.bean.NamedBean<org.anchoranalysis.feature.bean.list.FeatureListProvider<T>>> features, org.anchoranalysis.feature.io.csv.metadata.LabelHeaders metadataHeaders, org.anchoranalysis.feature.io.results.FeatureOutputNames outputNames, Optional<org.anchoranalysis.io.input.grouper.InputGrouper> grouper, FeatureExporterContext context) throws org.anchoranalysis.core.exception.CreateExceptionAlternative static constructor that creates a shared-state from a list of namedFeatureListProviders.- Type Parameters:
T- feature input-type in store- Parameters:
features- a list of beans to create the features.metadataHeaders- headers to describe any metadata.outputNames- customizable output names used byLabelledResultsCollector.grouper- when defined, assigns each input to a group.context- context.- Returns:
- a newly created
FeatureExporter. - Throws:
org.anchoranalysis.core.exception.CreateException- if it cannot be successfully created.
-
create
public static <T extends org.anchoranalysis.feature.input.FeatureInput> FeatureExporter<org.anchoranalysis.feature.bean.list.FeatureList<T>> create(org.anchoranalysis.feature.store.NamedFeatureStore<T> featureStore, org.anchoranalysis.feature.io.csv.metadata.LabelHeaders metadataHeaders, org.anchoranalysis.feature.io.results.FeatureOutputNames outputNames, Optional<org.anchoranalysis.io.input.grouper.InputGrouper> grouper, FeatureExporterContext context) throws org.anchoranalysis.core.exception.CreateExceptionAlternative static constructor that creates a shared-state from aNamedFeatureStore.- Type Parameters:
T- feature input-type in store- Parameters:
featureStore- a list of beans to create the features.metadataHeaders- headers to describe any metadata.outputNames- customizable output names used byLabelledResultsCollector.grouper- when defined, assigns each input to a group.context- context.- Returns:
- a newly created
FeatureExporter. - Throws:
org.anchoranalysis.core.exception.CreateException- if it cannot be successfully created.
-
create
public static <T extends org.anchoranalysis.feature.input.FeatureInput> FeatureExporter<org.anchoranalysis.image.feature.calculator.FeatureTableCalculator<T>> create(org.anchoranalysis.feature.io.results.FeatureOutputNames outputNames, org.anchoranalysis.image.feature.calculator.FeatureTableCalculator<T> features, org.anchoranalysis.feature.io.csv.metadata.LabelHeaders identifierHeaders, Optional<org.anchoranalysis.io.input.grouper.InputGrouper> grouper, FeatureExporterContext context) throws org.anchoranalysis.core.exception.CreateExceptionAlternative static constructor that creates a shared-state from aNamedFeatureStore.- Type Parameters:
T- feature input-type in store- Parameters:
outputNames- the names of the feature outputs.features- a table calculator for features.identifierHeaders- headers to describe the identifier metadata before the feature values.grouper- when defined, assigns each input to a group.context- context.- Returns:
- a newly created
FeatureExporter. - Throws:
org.anchoranalysis.core.exception.CreateException- if it cannot be successfully created.
-
createCalculationContext
public FeatureCalculationContext<S> createCalculationContext(Optional<String> groupName, org.anchoranalysis.core.time.ExecutionTimeRecorder executionTimeRecorder, org.anchoranalysis.io.output.outputter.InputOutputContext ioContext)Creates aFeatureCalculationContextfor calculating features to later use this exporter.- Parameters:
groupName- the group to associate with the feature-results when outputted.executionTimeRecorder- records execution-times.ioContext- IO-context.- Returns:
- a newly created context.
-
closeAndWriteOutputs
public void closeAndWriteOutputs(Optional<org.anchoranalysis.feature.store.NamedFeatureStore<org.anchoranalysis.feature.input.FeatureInputResults>> featuresAggregate, boolean includeGroups, Function<org.anchoranalysis.io.output.outputter.InputOutputContext,org.anchoranalysis.feature.io.csv.results.FeatureCSVWriterFactory> csvWriterCreator, org.anchoranalysis.io.output.outputter.InputOutputContext context) throws org.anchoranalysis.io.output.error.OutputWriteFailedExceptionWrites all the results that have been collected as a CSV file, and closes open I/O handles and memory structures.- Parameters:
featuresAggregate- features that can be used for generating additional "aggregated" exports.includeGroups- iff true a group-column is included in the CSV file and the group exports occur, otherwise not.csvWriterCreator- creates a CSV writer for a particular IO-context.context- IO-context.- Throws:
org.anchoranalysis.io.output.error.OutputWriteFailedException- if any output cannot be written, or there is an error closing open I/O.
-
getFeatureNames
public org.anchoranalysis.feature.name.FeatureNameList getFeatureNames()The names of the features to be exported. -
getResults
Saved store feature calculation results, and writes associated thumbnails. -
getGrouper
When defined, assigns each input to a group.
-