Python Client for Sectra
This python package aims to facilite the development of AI applications for Sectra PACS.
Version
The library currently supports functionality up to do version 3.4 (Dec 2023). However, we will update to 5.0 in Juli, after which this library will be adjusted to the newest version as well.
Installation
To install sectra_client:
pip install sectra-image-analysis-api
Usage
Before using the client, make sure you have access to a valid authentication token, and url, sent in the analysis requests.
Example 1: Retrieve image information
from sectra_client import SectraClient
# Info, sent by Sectra in the request
callback_url = "http://sectraweb.*.*.*/SectraPathologyServer/external/imageanalysis/v1"
callback_token = "abcde"
slide_id = "fghij"
# Use the context manager
with SectraClient(
url=callback_url,
token=callback_token
) as client:
# Returns the image info with extended and personal health information data
image_info = client.get_image_metadata(slide_id, extended=True, phi=True)
Example 2: Download WSI
from sectra_client import SectraClient
# Info, sent by Sectra in the request
...
# Use the context manager
with SectraClient(
url=callback_url,
token=callback_token
) as client:
# Download the file(s) to an output directory, and returns the file paths of the file(s).
file_paths = client.download_slide_files(slide_id, output_dir="./path/to/output/dir/")
Example 3: Without context manager
It is also possible to use the SectraClient without the context manager
from sectra_client import SectraClient
# Info, sent by Setra in the request
...
# Open context manager
client = SectraClient(url=callback_url, token=callback_token)
# Perform API interactions
image_info = client.get_image_metadata(slide_id, extended=True, phi=False)
# Make sure to close the connection
client.close()
Local development with the mock server
MockSectraServer simulates a Sectra PACS instance in memory so you can develop and test without a real server.
from sectra_client.mock_server import MockSectraServer
server = MockSectraServer(token="dev-token")
with server.run(port=8001):
server.trigger(
webhook_url="http://localhost:8000/sectra/hook",
application_id="my-app",
slide_id="slide-001",
)
results = server.get_results(app_id="my-app", slide_id="slide-001")
See examples/local_dev.py for a complete round-trip: both servers started from a single script, a fake invocation fired, and results read back.
Metadata
Release files for sectra-image-analysis-api 1.6.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sectra_image_analysis_api-1.6.3.tar.gz | 114.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sectra_image_analysis_api-1.6.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 135.1 kB
Release files / sectra_image_analysis_api-1.6.3.tar.gz
| Download URL | sectra_image_analysis_api-1.6.3.tar.gz |
|---|---|
| Size | 114.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
15a33bdcb11aeda6bcc20ad0dfa21407ded7cfa5d2f9816ba2c9ed4751a67324
|
|
BLAKE2b-256 checksum How to use checksums |
f6e3d92e3a14f727814b2ebfadb64c32994e87f428a0fc85e992b037982dc278
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / sectra_image_analysis_api-1.6.3-py3-none-any.whl
| Download URL | sectra_image_analysis_api-1.6.3-py3-none-any.whl |
|---|---|
| Size | 20.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a67158909e3b699438725c4daf409eaa614242f01cd54f535f98006b73a69af8
|
|
BLAKE2b-256 checksum How to use checksums |
44505f0f94d6fd7fac46032526401e69e818df5e88aa550747ac205ad9f46421
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|