Skip to content

Filters

Client-side filtering helpers for annotation lists.

nimbusimage.filters

Client-side filtering helpers for annotation lists.

filter_by_tags(annotations, tags, exclusive=False)

Filter annotations by tags.

Parameters:

Name Type Description Default
annotations list[Annotation]

List of Annotation objects.

required
tags list[str]

Tags to filter by.

required
exclusive bool

If False (default), annotation must have at least one matching tag. If True, annotation tags must exactly match (order independent).

False

Returns:

Type Description
list[Annotation]

Filtered list.

filter_by_location(annotations, xy=None, z=None, time=None)

Filter annotations by location. None means any value.

Parameters:

Name Type Description Default
annotations list[Annotation]

List of Annotation objects.

required
xy int | None

XY position to match, or None for any.

None
z int | None

Z position to match, or None for any.

None
time int | None

Time position to match, or None for any.

None

Returns:

Type Description
list[Annotation]

Filtered list.

group_by_location(annotations)

Group annotations by location.

Returns:

Type Description
dict[tuple[int, int, int], list[Annotation]]

Dict mapping (time, z, xy) tuples to lists of annotations.

dict[tuple[int, int, int], list[Annotation]]

Key order is time (outermost), z, xy (innermost).