diff --git a/src/napari_cryoet_data_portal/_reader.py b/src/napari_cryoet_data_portal/_reader.py index 70ca7d5..8851ee1 100644 --- a/src/napari_cryoet_data_portal/_reader.py +++ b/src/napari_cryoet_data_portal/_reader.py @@ -22,12 +22,8 @@ def _annotation_color(annotation: Annotation) -> np.ndarray: """Maps an annotation to a color based on its object_id.""" - try: - object_id = int(annotation.object_id.split(":")[-1]) - except RuntimeError as e: - logger.error("Failed to parse integer from object_id: %s\%s", annotation.object_id, e) - return DEFAULT_OBJECT_COLOR - color = OBJECT_COLORMAP(object_id % len(OBJECT_COLORMAP.color_stops)) + object_id = annotation.object_id.split(":")[-1] + color = OBJECT_COLORMAP(hash(object_id) % len(OBJECT_COLORMAP.color_stops)) return np.array(color.rgba)