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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12e283a752df8d116d05ef8fcfc06d8a22f1333830d984b2c78fcc5d08cb0076
|
|
| MD5 |
faaaeaf7ab2dab4b21ffb13941b56b21
|
|
| BLAKE2b-256 |
b2ae67cc656346825473111bf3585fd9411d1a1798f9cf5b6e97380f866a6678
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gtagora_workbook_py-0.2.0.tar.gz -
Subject digest:
12e283a752df8d116d05ef8fcfc06d8a22f1333830d984b2c78fcc5d08cb0076 - Sigstore transparency entry: 2580307884
- Sigstore integration time:
-
Permalink:
GyroTools/gtagora-workbook-py@d56ab896a5fe3605b67f80e73d4190e816a4a118 -
Branch / Tag:
refs/tags/0.2.0 - Owner: https://github.com/GyroTools
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@d56ab896a5fe3605b67f80e73d4190e816a4a118 -
Trigger Event:
release
-
Statement type:
File details
Details for the file gtagora_workbook_py-0.2.0-py3-none-any.whl.
File metadata
- Download URL: gtagora_workbook_py-0.2.0-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26c9312e32194c5101c0376ec70a609b1beba87fc22d7eecb7beeff147ecd15b
|
|
| MD5 |
07a1863b06afcd74da77945a3963a312
|
|
| BLAKE2b-256 |
3a7e345dd9291956e73a724d45dd8453366e52dc904ac113f02fef6991030840
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gtagora_workbook_py-0.2.0-py3-none-any.whl -
Subject digest:
26c9312e32194c5101c0376ec70a609b1beba87fc22d7eecb7beeff147ecd15b - Sigstore transparency entry: 2580307892
- Sigstore integration time:
-
Permalink:
GyroTools/gtagora-workbook-py@d56ab896a5fe3605b67f80e73d4190e816a4a118 -
Branch / Tag:
refs/tags/0.2.0 - Owner: https://github.com/GyroTools
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@d56ab896a5fe3605b67f80e73d4190e816a4a118 -
Trigger Event:
release
-
Statement type: