Skip to main content

gtagora-workbook-py

Agora workbook utilities for Python

Pure, dependency-free (no numpy, no HTTP client) helpers for working with the JSON shape of an Agora Workbook - mask RLE encoding, default CMR contour/landmark button templates, and merging new masks/contour groups into an existing workbook session. No network code lives here; it's meant to be shared by anything that needs to build or read Workbook data, whether that's a REST client (see gtagora-connector-py, which depends on this package) or code with direct database access.

Installation

pip install gtagora-workbook-py

Usage

Mask encoding/decoding (workbook.mask)

Encode a (size_x * size_y) label array into the base64 RLE format used by a Workbook mask's mSliceMask[i].mBase64Values, and decode it back:

from workbook.mask import encode_mask, decode_mask

encoded = encode_mask(labels)  # labels: flat list of ints, one per pixel
decoded = decode_mask(encoded, len(labels))
assert decoded == labels

Decode a full Workbook mask dict (mSizeX/Y/Z/T plus one mSliceMask entry per (z, t)) into a flat list and its (X, Y, Z, T) shape:

from workbook.mask import decode_full_mask

decoded = decode_full_mask(mask)  # mask: one entry of workbook['mask']['mMasks']
print(decoded.shape)  # (size_x, size_y, size_z, size_t)

Convert to a numpy array with a single call:

import numpy as np

array = np.array(decoded.data, dtype=np.uint8).reshape(decoded.shape)

Default CMR templates (workbook.templates)

from workbook.templates import default_cmr_contour_buttons, default_cmr_landmark_buttons, new_cmr_workbook_body

object_buttons = default_cmr_contour_buttons() + default_cmr_landmark_buttons()
body = new_cmr_workbook_body(dataset_id=158, name='CMR Workbook')  # ready to POST to a Workbook endpoint

Merging into an existing workbook session (workbook.session)

from workbook.session import merge_contour_session, merge_mask_session, resolve_contour_buttons

# insert/replace `mask` (by its 'name') into an existing mask session
mask_session = merge_mask_session(workbook['mask'], workbook_id=workbook['id'], mask=mask)

# insert/replace contour groups (by 'name') and set the object buttons
contour_session = merge_contour_session(
    workbook['contour'], workbook_id=workbook['id'],
    contour_groups=contour_groups, object_buttons=object_buttons)

# a workbook's own contour buttons, or the default CMR set if it has none yet
object_buttons = resolve_contour_buttons(workbook.get('contour'))

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gtagora_workbook_py-0.2.0.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gtagora_workbook_py-0.2.0-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file gtagora_workbook_py-0.2.0.tar.gz.

File metadata

  • Download URL: gtagora_workbook_py-0.2.0.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for gtagora_workbook_py-0.2.0.tar.gz
Algorithm Hash digest
SHA256 12e283a752df8d116d05ef8fcfc06d8a22f1333830d984b2c78fcc5d08cb0076
MD5 faaaeaf7ab2dab4b21ffb13941b56b21
BLAKE2b-256 b2ae67cc656346825473111bf3585fd9411d1a1798f9cf5b6e97380f866a6678

See more details on using hashes here.

Provenance

The following attestation bundles were made for gtagora_workbook_py-0.2.0.tar.gz:

Publisher: python-publish.yml on GyroTools/gtagora-workbook-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gtagora_workbook_py-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for gtagora_workbook_py-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 26c9312e32194c5101c0376ec70a609b1beba87fc22d7eecb7beeff147ecd15b
MD5 07a1863b06afcd74da77945a3963a312
BLAKE2b-256 3a7e345dd9291956e73a724d45dd8453366e52dc904ac113f02fef6991030840

See more details on using hashes here.

Provenance

The following attestation bundles were made for gtagora_workbook_py-0.2.0-py3-none-any.whl:

Publisher: python-publish.yml on GyroTools/gtagora-workbook-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 files

0.1.0

2 files

0.0.2

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page