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.1.0.tar.gz (10.4 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.1.0-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gtagora_workbook_py-0.1.0.tar.gz
  • Upload date:
  • Size: 10.4 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.1.0.tar.gz
Algorithm Hash digest
SHA256 1ab7cdc047bd22960534662404df4feda3bb3de885c1bd6635edd10335a32526
MD5 e20a01194041b150a9520bbe0fe87ef9
BLAKE2b-256 04d53dcabeb3408165bb452f920451535bb4e421ba52ae7d452a9ff7b1a76e9a

See more details on using hashes here.

Provenance

The following attestation bundles were made for gtagora_workbook_py-0.1.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.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for gtagora_workbook_py-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e7fc1e023049a1855cb34c365f64ee49e306d553f826a11f9b28731db54506b9
MD5 33a853fc754add9d2fd5f7e8794a72f4
BLAKE2b-256 bebb134cca61402eafc964a63c81205180d6896a566d933d667af650b8261767

See more details on using hashes here.

Provenance

The following attestation bundles were made for gtagora_workbook_py-0.1.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

0.2.0

2 files

This release

0.1.0 This release

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