Package qupath.ext.braian
Class AbstractDetections
java.lang.Object
qupath.ext.braian.AbstractDetections
- Direct Known Subclasses:
ChannelDetections
,OverlappingDetections
This abstract class defines the interface to handle groups of different cell detections groups.
It works by using on "container" annotations, inside which all the cells are grouped.
By default,
AbstractDetections
allows to classify its detections by applying PartialClassifier
s.-
Constructor Summary
ConstructorDescriptionAbstractDetections
(String id, Collection<qupath.lib.objects.classes.PathClass> detectionClasses, qupath.lib.objects.hierarchy.PathObjectHierarchy hierarchy) Constructs an object that groups together detections of the same kind. -
Method Summary
Modifier and TypeMethodDescriptionvoid
applyClassifiers
(List<PartialClassifier> classifiers, qupath.lib.images.ImageData<?> imageData) applies a list of classifiers in sequence to the detections of the instance kind.protected qupath.lib.objects.PathAnnotationObject
createContainer
(qupath.lib.objects.PathAnnotationObject containerParent, boolean overwrite) Creates a duplicate child annotation to be used as containerboolean
Two detection objects are functionally the same if they are compatible with each other and they have the same containersvoid
Updates the internal representation to the current state.protected static Stream<qupath.lib.objects.PathDetectionObject>
getChildrenDetections
(qupath.lib.objects.PathAnnotationObject annotation) List<qupath.lib.objects.PathAnnotationObject>
abstract String
qupath.lib.objects.classes.PathClass
protected static Stream<qupath.lib.objects.PathDetectionObject>
getDetectionsInside
(qupath.lib.objects.PathAnnotationObject annotation, qupath.lib.objects.hierarchy.PathObjectHierarchy hierarchy) returns the detections inside the given annotationprotected static Stream<qupath.lib.objects.PathDetectionObject>
getDetectionsInside
(qupath.lib.roi.interfaces.ROI roi, qupath.lib.objects.hierarchy.PathObjectHierarchy hierarchy) returns the detections inside the givenROI
List<qupath.lib.objects.classes.PathClass>
qupath.lib.objects.classes.PathClass
protected qupath.lib.objects.hierarchy.PathObjectHierarchy
getId()
Optional<qupath.lib.objects.PathObject>
getOverlappingObjectIfPresent
(qupath.lib.objects.PathObject o) boolean
isChannelDetection
(qupath.lib.objects.PathObject o, boolean all) checks whether the given object is a detection belonging to the instance kindprotected <T> boolean
isCompatibleClassifier
(qupath.lib.classifiers.object.ObjectClassifier<T> classifier) boolean
Check whether twoAbstractDetections
are compatible.boolean
isContainer
(qupath.lib.objects.PathObject o) boolean
isEmpty()
If there are no detections within the current instance.Stream<qupath.lib.objects.PathDetectionObject>
toStream()
-
Constructor Details
-
AbstractDetections
public AbstractDetections(String id, Collection<qupath.lib.objects.classes.PathClass> detectionClasses, qupath.lib.objects.hierarchy.PathObjectHierarchy hierarchy) throws NoCellContainersFoundException Constructs an object that groups together detections of the same kind. To do so, it searches for container annotations of detections having a name compatible withgetContainersName()
- Parameters:
id
- identification of this group of detectionsdetectionClasses
- classifications used to identify the detectionshierarchy
- where to find the detections- Throws:
NoCellContainersFoundException
- if there is no compatible container in the hierarchy- See Also:
-
-
Method Details
-
getDetectionsInside
protected static Stream<qupath.lib.objects.PathDetectionObject> getDetectionsInside(qupath.lib.objects.PathAnnotationObject annotation, qupath.lib.objects.hierarchy.PathObjectHierarchy hierarchy) returns the detections inside the given annotation- Parameters:
annotation
- where to search the detectionshierarchy
- where to find the detections- Returns:
- a stream of detections found inside annotations
-
getDetectionsInside
protected static Stream<qupath.lib.objects.PathDetectionObject> getDetectionsInside(qupath.lib.roi.interfaces.ROI roi, qupath.lib.objects.hierarchy.PathObjectHierarchy hierarchy) returns the detections inside the givenROI
- Parameters:
roi
- where to search the detectionshierarchy
- where to find the detections- Returns:
- a stream of detections found inside annotations
-
getChildrenDetections
protected static Stream<qupath.lib.objects.PathDetectionObject> getChildrenDetections(qupath.lib.objects.PathAnnotationObject annotation) -
fireUpdate
Updates the internal representation to the current state. If a new container of detections is added and overlaps the old containers, it updates the old detections with the new ones. Additionally, it makes sure that the newer containers don't overlap with the old ones.
If container annotations or detections are touched outside of BraiAn, it's better to call this method.- Throws:
NoCellContainersFoundException
- if there is no compatible container in the hierarchy
-
isEmpty
public boolean isEmpty()If there are no detections within the current instance.
If the state was changed outside of this extension, you might need to callfireUpdate()
first.- Returns:
- True, if no detections are found within the current state. False otherwise.
- See Also:
-
getContainers
- Returns:
- the container annotations
-
getHierarchy
protected qupath.lib.objects.hierarchy.PathObjectHierarchy getHierarchy() -
getId
- Returns:
- a string often used to identify detections and their container annotations
-
toStream
- Returns:
- a stream of the given detections, in no particular order
-
getOverlappingObjectIfPresent
public Optional<qupath.lib.objects.PathObject> getOverlappingObjectIfPresent(qupath.lib.objects.PathObject o) - Parameters:
o
- the object to search an overlapping detection for- Returns:
- the detection that overlaps the given object
- See Also:
-
getContainersName
- Returns:
- the name used by the containers of detections of the instance kind
-
isContainer
public boolean isContainer(qupath.lib.objects.PathObject o) - Parameters:
o
- the object to test- Returns:
- true if the given object is a container of these detections. False otherwise
-
getContainersPathClass
public qupath.lib.objects.classes.PathClass getContainersPathClass()- Returns:
- the classification used to indentify containers of detections of the instance kind
-
getDiscardedDetectionsPathClass
public qupath.lib.objects.classes.PathClass getDiscardedDetectionsPathClass()- Returns:
- the classification used to identify detections of the instance kind that were discarded
-
getDetectionsPathClasses
- Returns:
- the classifications used to identify the detections of the instance kind
-
isChannelDetection
public boolean isChannelDetection(qupath.lib.objects.PathObject o, boolean all) checks whether the given object is a detection belonging to the instance kind- Parameters:
o
- the object to testall
- if true, considers discarded detections also as belonging to the instance kind- Returns:
- true if the given object belongs to the instance kind
-
createContainer
protected qupath.lib.objects.PathAnnotationObject createContainer(qupath.lib.objects.PathAnnotationObject containerParent, boolean overwrite) Creates a duplicate child annotation to be used as container- Parameters:
containerParent
- the annotation to use as a model for the containeroverwrite
- if true, deletes all previously created containers, if any- Returns:
- the new container, as child of
containerParent
-
applyClassifiers
public void applyClassifiers(List<PartialClassifier> classifiers, qupath.lib.images.ImageData<?> imageData) applies a list of classifiers in sequence to the detections of the instance kind. The order of the classifiers is important. If they work on overlapping annotations, the intersection is classified using the latter classifier.
If a classifier's output is not compatible with the instance, the correspondingPartialClassifier
will be skipped.- Parameters:
classifiers
- the sequence of partial classifiers to applyimageData
- the imageData used by the classifiers- See Also:
-
isCompatibleClassifier
protected <T> boolean isCompatibleClassifier(qupath.lib.classifiers.object.ObjectClassifier<T> classifier) -
isCompatibleWith
Check whether twoAbstractDetections
are compatible. They are compatible if they work on the same hierarchy, they have the samegetId()
, they work on the same type of containers and on the samegetDetectionsPathClasses()
- Parameters:
other
- an instance of the detections to check against the current one- Returns:
- true, if compatible. False otherwise.
- See Also:
-
equals
Two detection objects are functionally the same if they are compatible with each other and they have the same containers
-