Skip to main content
The Bioptimus Python SDK runs whole-slide inference against either an on-premise server or a SageMaker endpoint. It handles WSI reading, tiling, tissue masking, bulk-RNA alignment, and concurrent dispatch. The Bioptimus SDK talks to whichever model is deployed at the endpoint you connect to. Backbone.available_backbones() lists the models the Bioptimus SDK knows how to build (h1, m-optimus, tissue-seg) — to see what a server actually has loaded, check its /ping response.

Installation

Two ways to use it

Inference pipeline (recommended)

One object configures the whole pipeline. Caches tissue masks, organizes outputs into a workspace, and is reproducible. Best for most users and for cohorts.

Core API (advanced)

Backbone + SlideInference give explicit, per-slide control over the model client, mask provider, and writer.

Connecting to a model

The Backbone factory is the low-level client used by both layers.
For M-Optimus, gene sets are fetched from the server automatically (model.input_gene_names, model.output_gene_names).
Before constructing a Backbone (or an Inference pipeline), confirm the on-premise server is reachable:
If this raises ConnectionError / connection refused or times out, nothing is serving at that URL:
  • Not started — launch the container, mapping port 8080, then wait for models to load. See On-premise deployment:
  • 503 {"status": "loading"} — models are still initialising; wait and retry.
  • Wrong URL/portbase_url (and the pipeline’s api_url) must be the server’s host and port, with no trailing /ping.
For SageMaker there is no /ping: confirm the endpoint is InService and that endpoint_name / region_name are correct.

Guides

Inference pipeline

One-object pipeline, workspaces, reproducible config.

Cohorts

Multi-slide cohorts and late-binding bulk RNA.

Spatial transcriptomics

M-Optimus gene-expression prediction end to end.

Tile embeddings & PCA

Extract embeddings and visualize morphology.

WSI processing

Read slides: levels, MPP, regions, thumbnails.

Visualizing results

Load Zarr/HDF5/NPZ and overlay genes and masks.

Output formats

Every output file contains the same contents:
  • Datasets: outputs, coords, tissue_ratios, thumbnail, tissue_mask — plus input_gene_names and output_gene_names for M-Optimus.
  • Metadata attributes: slide_name, tile_size, stride, mpp, slide_dimensions, slide_dimensions_at_mpp, num_tiles.
See Visualizing results to load and plot them.