Package qupath.lib.classifiers.object
Class ObjectClassifiers
java.lang.Object
qupath.lib.classifiers.object.ObjectClassifiers
Helper class for creating ObjectClassifiers.
- Author:
- Pete Bankhead
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Builder to create a simpleObjectClassifier
that assigns a classification based upon whether the measurement of an object is above, equal to or below a specified threshold.static class
TypeAdapterFactory
to help with serializing ObjectClassifiers to and from JSON. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> ObjectClassifier
<T> createChannelClassifier
(PathObjectFilter filter, ImageChannel channel, String measurement, double threshold) Create a classifier that thresholds a single measurement, assigning a class based on anImageChannel
if the value is ≥ threshold.static <T> ObjectClassifier
<T> createCompositeClassifier
(Collection<ObjectClassifier<T>> classifiers) Create a compositeObjectClassifier
, which sequentially applies multiple (usually single-class) classifiers.static <T> ObjectClassifier
<T> createCompositeClassifier
(ObjectClassifier<T>... classifiers) Create a compositeObjectClassifier
, which sequentially applies multiple (usually single-class) classifiers.static TypeAdapterFactory
Get aTypeAdapterFactory
to handleObjectClassifier
instances.static <T> ObjectClassifier
<T> readClassifier
(Path path) Read the classifier from a file.static <T> void
writeClassifier
(ObjectClassifier<T> classifier, Path path) Write the classifier to a file.
-
Constructor Details
-
ObjectClassifiers
public ObjectClassifiers()
-
-
Method Details
-
getTypeAdapterFactory
Get aTypeAdapterFactory
to handleObjectClassifier
instances.- Returns:
-
createCompositeClassifier
Create a compositeObjectClassifier
, which sequentially applies multiple (usually single-class) classifiers. This can be used for multiplexed images, where a single classifier may be trained for each marker.- Type Parameters:
T
-- Parameters:
classifiers
- an array of classifiers to combine- Returns:
- the composite object classifier
-
createCompositeClassifier
public static <T> ObjectClassifier<T> createCompositeClassifier(Collection<ObjectClassifier<T>> classifiers) Create a compositeObjectClassifier
, which sequentially applies multiple (usually single-class) classifiers. This can be used for multiplexed images, where a single classifier may be trained for each marker.- Type Parameters:
T
-- Parameters:
classifiers
- a collection of classifiers to combine- Returns:
- the composite object classifier
-
createChannelClassifier
public static <T> ObjectClassifier<T> createChannelClassifier(PathObjectFilter filter, ImageChannel channel, String measurement, double threshold) Create a classifier that thresholds a single measurement, assigning a class based on anImageChannel
if the value is ≥ threshold.- Parameters:
filter
- filter to apply, typicallyPathObjectFilter.CELLS
channel
-ImageChannel
from which thePathClass
should be derived.measurement
- name of the measurement (within the object'sMeasurementList
)threshold
- threshold to apply to the measurement- Returns:
- the object classifier
- See Also:
-
readClassifier
Read the classifier from a file.- Type Parameters:
T
-- Parameters:
path
-- Returns:
- Throws:
IOException
-
writeClassifier
public static <T> void writeClassifier(ObjectClassifier<T> classifier, Path path) throws IOException Write the classifier to a file.- Type Parameters:
T
-- Parameters:
classifier
-path
-- Throws:
IOException
-