Skip to main content

soma

soma runs computational pathology experiments from images and labels to predictions, metrics, and reports. It combines preprocessing, frozen foundation-model features, and downstream training through a modular Python API or a YAML pipeline.

The soma pipeline — data, a frozen encoder, a trained decoder, and evaluation.

Documentation · PyPI

Install

Requires Python 3.11 or later:

pip install soma-pathology

The distribution is soma-pathology; the Python package and CLI are soma.

Run an experiment

For slide classification, prepare two CSV files:

  • dataset.csv: one row per slide with a unique sample_id, an image_path, and a label.
  • splits.csv: columns sample_id, split, and fold, assigning every sample to train, tune, or a test* split in each fold.

Use independent subjects across splits and include both classes in each split for binary AUROC. The getting started guide shows the manifests and a complete walkthrough.

from soma import (
    AggregatorConfig,
    EncoderConfig,
    EvalConfig,
    Pipeline,
    PipelineConfig,
    TaskConfig,
    TrainingConfig,
)

config = PipelineConfig(
    dataset_csv="dataset.csv",
    splits_csv="splits.csv",
    output_root="output",
    dataset_type="slide",
    encoder=EncoderConfig(name="phikon"),
    aggregator=AggregatorConfig(name="abmil"),
    task=TaskConfig(name="binary_classification"),
    training=TrainingConfig(epochs=5, learning_rate=1e-4, seed=0),
    evaluation=EvalConfig(metrics=["auroc", "balanced_accuracy"]),
)
result = Pipeline(config).run()
print(result.summary)
print(result.run_dir)

phikon weights are public and download on first use. Omitted tile size and spacing resolve from the encoder's native configuration. The pipeline preprocesses slides, extracts features, trains across folds, and evaluates predictions. result.fold_results contains per-fold results; result.run_dir locates the saved artifacts.

To reuse features across experiments, use Dataset and Splits to load data, FeatureExtractor.extract() to build a feature source, and train() or train_one_fold() for downstream training. The API guide shows this workflow and reporting examples.

Use the CLI

Run the same pipeline from a YAML config:

soma config.yaml
# Equivalent:
python -m soma config.yaml

soma merges the file with its bundled defaults. Start with the task examples or consult the CLI and configuration reference. Discover components with:

soma list encoders --level tile
soma list aggregators
soma list decoders
soma list pixel-classifiers
soma list tasks
soma list benchmarks

Explore

License

Apache-2.0.

Metadata

Release files for soma-pathology 1.15.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for soma-pathology 1.15.0
File Size Uploaded
soma_pathology-1.15.0.tar.gz 482.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for soma-pathology 1.15.0
File Interpreter ABI Platform
soma_pathology-1.15.0-py3-none-any.whl Python 3 none any Details

Total release size: 1.1 MB

Release files / soma_pathology-1.15.0.tar.gz

Download URL soma_pathology-1.15.0.tar.gz
Size 482.6 kB
Tags Source
SHA-256 checksum
How to use checksums
72724420fc02c1b4475bee5553812442f5bc6906055a7ca4d2244bd3245bec87
BLAKE2b-256 checksum
How to use checksums
e0c10515fcb77735f77738c4161f2d3055515f6ebc26760577b7c660c6f5efca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Release files / soma_pathology-1.15.0-py3-none-any.whl

Download URL soma_pathology-1.15.0-py3-none-any.whl
Size 585.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
201189b5ec9efbaa889ee05bfb7816aef57f74582f89bf33b083a3efd60a7aba
BLAKE2b-256 checksum
How to use checksums
7a2eb3ac0ebda7cfd1644db2968d265c9875ae965ca55abede4a3a0eb2cf509d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Release history Release notifications | RSS feed

2.0.0

2 release files

1.19.0

2 release files

1.16.0

2 release files

1.15.1

2 release files

This release

1.15.0 This release

2 release files

1.12.0

2 release files

1.11.3

2 release files

1.11.2

2 release files

1.11.1

2 release files

1.11.0

2 release files

1.10.1

2 release files

1.10.0

2 release files

1.9.0

2 release files

1.8.0

2 release files

1.7.0

2 release files

1.6.0

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.1

2 release 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