I'm trying to annotate some points in a meshwork (specifically, places where edits have occurred) using add_annotation. I am getting an error that is taking me a bit to work though - at the end of the day I suspect that there is some schema for what the annotation data frames should look like that I'm not aware of? Is there any documentation on this that I'm missing?
For instance, can the points be arbitrary, or do they need to map onto a particular node in the mesh/skeleton? Do x,y,z positions need to follow a particular format?
Minimal working example
(requires pcg_skel)
import caveclient as cc
import pandas as pd
import pcg_skel
client = cc.CAVEclient("minnie65_phase3_v1")
root_id = 864691135510015497
change_log = client.chunkedgraph.get_change_log(root_id)
details = client.chunkedgraph.get_operation_details(change_log["operations_ids"])
merges = {}
splits = {}
for operation, detail in details.items():
operation = int(operation)
source_coords = detail["source_coords"][0]
sink_coords = detail["sink_coords"][0]
x = (source_coords[0] + sink_coords[0]) / 2
y = (source_coords[1] + sink_coords[1]) / 2
z = (source_coords[2] + sink_coords[2]) / 2
pt = [x, y, z]
row = {"x": x, "y": y, "z": z, "pt": pt}
if "added_edges" in detail:
merges[operation] = row
elif "removed_edges" in detail:
splits[operation] = row
merges = pd.DataFrame.from_dict(merges, orient="index")
merges.index.name = "operation"
splits = pd.DataFrame.from_dict(splits, orient="index")
splits.index.name = "operation"
meshwork = pcg_skel.coord_space_meshwork(root_id, client=client)
meshwork.add_annotations("splits", splits)
meshwork.add_annotations("merges", merges)
Traceback (most recent call last):
File "/Users/bpedigo/aibs-code/cave-explorer/cave-explorer/experiments/anno_mwe.py", line 39, in <module>
meshwork.add_annotations("splits", splits)
File "/Users/bpedigo/aibs-code/cave-explorer/cave-explorer/.venv/lib/python3.11/site-packages/meshparty/meshwork/meshwork.py", line 754, in add_annotations
self._anno.add_annotations(
File "/Users/bpedigo/aibs-code/cave-explorer/cave-explorer/.venv/lib/python3.11/site-packages/meshparty/meshwork/meshwork.py", line 168, in add_annotations
self._data_tables[name] = AnchoredAnnotation(
^^^^^^^^^^^^^^^^^^^
File "/Users/bpedigo/aibs-code/cave-explorer/cave-explorer/.venv/lib/python3.11/site-packages/meshparty/meshwork/meshwork.py", line 295, in __init__
self._anchor_points(mesh)
File "/Users/bpedigo/aibs-code/cave-explorer/cave-explorer/.venv/lib/python3.11/site-packages/meshparty/meshwork/meshwork.py", line 404, in _anchor_points
self._data[self._index_column_filt] = minds_filt
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bpedigo/aibs-code/cave-explorer/cave-explorer/.venv/lib/python3.11/site-packages/pandas/core/frame.py", line 4094, in __setitem__
self._set_item(key, value)
File "/Users/bpedigo/aibs-code/cave-explorer/cave-explorer/.venv/lib/python3.11/site-packages/pandas/core/frame.py", line 4303, in _set_item
value, refs = self._sanitize_column(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bpedigo/aibs-code/cave-explorer/cave-explorer/.venv/lib/python3.11/site-packages/pandas/core/frame.py", line 5042, in _sanitize_column
com.require_length_match(value, self.index)
File "/Users/bpedigo/aibs-code/cave-explorer/cave-explorer/.venv/lib/python3.11/site-packages/pandas/core/common.py", line 561, in require_length_match
raise ValueError(
ValueError: Length of values (0) does not match length of index (19)
Problem
I'm trying to annotate some points in a meshwork (specifically, places where edits have occurred) using
add_annotation
. I am getting an error that is taking me a bit to work though - at the end of the day I suspect that there is some schema for what the annotation data frames should look like that I'm not aware of? Is there any documentation on this that I'm missing?For instance, can the points be arbitrary, or do they need to map onto a particular node in the mesh/skeleton? Do x,y,z positions need to follow a particular format?
Minimal working example
(requires pcg_skel)