Skip to main content

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.

Download files

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

Source Distribution

sectra_image_analysis_api-1.6.1.tar.gz (114.2 kB view details)

Uploaded Source

Built Distribution

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

sectra_image_analysis_api-1.6.1-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

Details for the file sectra_image_analysis_api-1.6.1.tar.gz.

File metadata

  • Download URL: sectra_image_analysis_api-1.6.1.tar.gz
  • Upload date:
  • Size: 114.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.30 {"installer":{"name":"uv","version":"0.11.30","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

Hashes for sectra_image_analysis_api-1.6.1.tar.gz
Algorithm Hash digest
SHA256 21aa9ac6ad7f37f7440de62692a504826af32660f1428edf0ac84728081cba36
MD5 874f2861c81974f33d486df9f6abe534
BLAKE2b-256 9828106c635b0b465db121892edd02822bfacdad9c96efe874754a707cc43826

See more details on using hashes here.

File details

Details for the file sectra_image_analysis_api-1.6.1-py3-none-any.whl.

File metadata

  • Download URL: sectra_image_analysis_api-1.6.1-py3-none-any.whl
  • Upload date:
  • Size: 20.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.30 {"installer":{"name":"uv","version":"0.11.30","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

Hashes for sectra_image_analysis_api-1.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5de120fbc6a696858c96d2841c2fb4789dbce9c7f8d176f2cd93a406b81f844b
MD5 4a1b9978bde885c7221963b3c7e4934e
BLAKE2b-256 13e5fae1471c49fe9936d425ed653591e8cac12f237da5a316c6f188e5c285b1

See more details on using hashes here.

Release history Release notifications | RSS feed

1.6.2

2 files

This release

1.6.1 This release

2 files

1.6.0

2 files

1.5.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