SectraClient
The primary interface for communicating with a Sectra PACS instance. Supports use as a context manager (recommended) or manually via close().
Constructor
| Parameter | Description |
|---|---|
url |
Base URL of the Sectra Image Analysis API (from callbackInfo.url) |
token |
Auth token (from callbackInfo.token) |
_allow_http |
Whether to allow plain HTTP during communication with Sectra (useful for MockSectraServer) |
Properties
| Property | Type | Description |
|---|---|---|
version_info |
ApplicationInfo |
API and software version reported by the server |
response_headers |
dict |
Headers to forward in your webhook response (required by Sectra) |
Image metadata
get_image_metadata
client.get_image_metadata(slide_id: str, extended: bool = False, phi: bool = False) -> ImageMetadata
Retrieves slide metadata including dimensions, focal planes, optical paths, and staining info. Set extended=True for additional fields and phi=True to include protected health information.
get_image_infos_in_case
client.get_image_infos_in_case(
accession_number: str,
phi: bool = False,
accession_number_issuer_id: str | None = None,
) -> list[CaseImageInfo]
Returns all slides belonging to a case, looked up by accession number. Requires IA-API 1.9+.
get_image_infos_in_case_by_slide_id
client.get_image_infos_in_case_by_slide_id(
slide_id: str,
phi: bool = False,
accession_number_issuer_id: str | None = None,
) -> list[CaseImageInfo]
Same as above but resolves the case from a known slide_id. Requires IA-API 1.9+.
File operations
get_label_image
Retrieves the slide's label/thumbnail image. Call .convert_to_pil() on the result to get a Pillow Image.
download_slide_files
Downloads all WSI files for a slide into output_dir (created if absent). Returns the paths of the saved files. Handles multipart responses transparently.
Results
create_results
Submits analysis results to Sectra. Returns the stored result including its assigned id.
get_result_by_result_id
Fetches a single stored result by ID.
get_all_results
Returns all results stored for a slide/application pair.
update_results
Updates an existing result. AdaptedResult requires the current versionId (optimistic concurrency).
Quality control
set_quality_control
Sets the QC status for a slide. Requires IA-API 1.10+.
Errors
SectraRequestError is raised when Sectra returns a non-2xx response.
from sectra_client.utils.errors import SectraRequestError
try:
client.get_image_metadata(slide_id)
except SectraRequestError as e:
print(e.status_code, e.path, e.text)
Failed requests are retried up to 5 times with exponential backoff on connection errors.