Local backup and SQL querying of annotation data

Created on Thu Dec 12 13:19:18 2019

@author: tageldim

histomicstk.annotations_and_masks.annotation_database_parser.dump_annotations_locally(gc, folderid, local, save_json=True, save_sqlite=False, dbcon=None, callback=None, callback_kwargs=None)[source]

Dump annotations of folder and subfolders locally recursively.

This reproduces this tiered structure locally and (possibly) dumps annotations there. Adapted from Lee A.D. Cooper

Parameters
  • gc (girder_client.GirderClient) – authenticated girder client instance

  • folderid (str) – girder id of source (base) folder

  • local (str) – local path to dump annotations

  • save_json (bool) – whether to dump annotations as json file

  • save_sqlite (bool) – whether to save the backup into an sqlite database

  • dbcon (sqlalchemy.create_engine.connect() object) – IGNORE THIS PARAMETER!! This is used internally.

  • callback (function) – function to call that CAN accept AT LEAST the following params - item: girder response with item information - annotations: loaded annotations - local: local directory - monitorPrefix: string - dbcon: sqlalchemy.create_engine.connect() object You can just add kwargs at the end of your callback definition for simplicity.

  • callback_kwargs (dict) – kwargs to pass along to callback. DO NOT pass any of the parameters item, annotations, local, monitorPrefix, or dbcon as these will be internally passed. Just include any specific paremeters for the callback. See parse_annotations_to_local_tables() above for an example of a callback and the unir test of this function.

histomicstk.annotations_and_masks.annotation_database_parser.dump_annotations_workflow(gc, slide_id, local, monitorPrefix='', save_json=True, save_sqlite=False, dbcon=None, callback=None, callback_kwargs=None)[source]

Dump annotations for single slide into the local folder.

Parameters
  • gc (girder_client.GirderClient) – authenticated girder client instance

  • slide_id (str) – girder id of item (slide)

  • monitorPrefix (str) – prefix to monitor string

  • local (str) – local path to dump annotations

  • save_json (bool) – whether to dump annotations as json file

  • save_sqlite (bool) – whether to save the backup into an sqlite database

  • dbcon (sqlalchemy.create_engine.connect() object) – IGNORE THIS PARAMETER!! This is used internally.

  • callback (function) – function to call that takes in AT LEAST the following params - item: girder response with item information - annotations: loaded annotations - local: local directory - monitorPrefix: string

  • callback_kwargs (dict) – kwargs to pass along to callback

histomicstk.annotations_and_masks.annotation_database_parser.parse_annotations_to_local_tables(item, annotations, local, monitorPrefix='', save_csv=True, save_sqlite=False, dbcon=None)[source]

Parse loaded annotations for slide into tables.

Parameters
  • item (dict) – girder response with item information

  • annotations (dict) – loaded annotations

  • local (str) – local directory

  • save_csv (bool) – whether to use histomicstk.annotations_and_masks.annotation_and_mask. parse_slide_annotations_into_tables() to get a tabular representation (including some simple calculations like bounding box) and save the output as two csv files, one representing the annotation documents and the other representing the actual annotation elements (polygons).

  • save_sqlite (bool) – whether to save the backup into an sqlite database

  • dbcon (sqlalchemy.create_engine.connect() object) – IGNORE THIS PARAMETER!! This is used internally.

  • monitorPrefix (str) – text to prepend to printed statements