fafbseg.flywire.upload_annotations#

fafbseg.flywire.upload_annotations(table_name, data, *, dataset=None)[source]#

Upload or update annotations to CAVE table.

Parameters:
  • table_name (str) – Name of the table.

  • data (pandas.DataFrame) – Data to be uploaded. Must match the table’s schema! If ‘id’ column exists, we assume that you want to update existing annotations (i.e. rows in the table) with the given IDs. See Examples for details.

  • dataset ("public" | "production" | "sandbox", optional) – Against which FlyWire dataset to query. If None will fall back to the default dataset (see set_default_dataset()).

Returns:

response – Server response.

Return type:

str

Examples

Let’s say we want to upload annotations to a table with the “bound_tag” schema. That schema requires a “pt” position and a “tag” (string) field. For all position fields, we need to provide them as a “{}_position” column (so “pt_position” in our example here) of x/y/z coordinates. Make sure they match the voxel resolution used for the table!

>>> from fafbseg import flywire
>>> import pandas as pd

Generate the (mock) data we want to upload:

>>> data = pd.DataFrame([])
>>> data['pt_position'] = [[0,0,0], [100, 100, 100]]
>>> data['tag'] = ['tag1', 'tag2']
>>> data
       pt_position   tag
0        [0, 0, 0]  tag1
1  [100, 100, 100]  tag2

Upload that data to a (fictional) table:

>>> flywire.upload_annotations('my_table', data)            

To update annotations we can do the same thing but provide IDs:

>>> # Look up IDs of annotations to update and add to DataFrame
>>> data['id'] = [0, 1]
>>> # Make some changes to the data
>>> data.loc[0, 'tag'] = 'new tag1'
>>> flywire.upload_annotations('my_table', data)