I was wondering if there is existing code within whole-slide-data to do something similar to what I write below:
wsa = WholeSlideAnnotation('foo.xml')
# Iterate over classes in WSA like with a dict.items()
for label, annos in wsa.annotations_per_label():
# Do stuff here
I am aware of the existence of sampling annotations, but these don't really fit this use case. I would have to instantiate a separate wsa object with its own sampling_annotation for every class (and I would first have to read these classes if didn't know them a priori).
If something like that doesn't exist, what do you think of making it a property/method in WholeSlideAnnotations? It wouldn't be very hard:
@property
def annotations_per_label(self) -> Dict
annos_per_label = dict(zip(self.labels.names, [[] for _ in self.labels.names]))
for anno in self.annotations:
annos_per_label[anno.label.name].append(anno)
return annos_per_label
Hi @martvanrijthoven,
I was wondering if there is existing code within whole-slide-data to do something similar to what I write below:
I am aware of the existence of sampling annotations, but these don't really fit this use case. I would have to instantiate a separate
wsa
object with its own sampling_annotation for every class (and I would first have to read these classes if didn't know them a priori).If something like that doesn't exist, what do you think of making it a property/method in WholeSlideAnnotations? It wouldn't be very hard: