A wrapper for the Sectra Image Analysis API.
Project description
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.
Project details
Release history Release notifications | RSS feed
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 sectra_image_analysis_api-1.5.1.tar.gz.
File metadata
- Download URL: sectra_image_analysis_api-1.5.1.tar.gz
- Upload date:
- Size: 111.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1cde633acfac197cf52ae6dc6143c0be29c1fdc406466d03b8f74c7f931b842
|
|
| MD5 |
72d6b50a3b6d0abec8499ade9f7692aa
|
|
| BLAKE2b-256 |
7c01a986a176bd656104990f0ba4b7a4e80a8c4ea031feaca0b1cb05df3c72e1
|
File details
Details for the file sectra_image_analysis_api-1.5.1-py3-none-any.whl.
File metadata
- Download URL: sectra_image_analysis_api-1.5.1-py3-none-any.whl
- Upload date:
- Size: 19.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b571c9d4e2b5263bd3e93fcecb415f85df9b8d7f16357c3c02ec80afa107684f
|
|
| MD5 |
eea9320450c638b69ee6b3ae4e007717
|
|
| BLAKE2b-256 |
b87927565571c8f7e0286aaffa1bc4d01b555b4eb41260f26ff3281504dc3f9d
|