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 dataset.csv (sample ID, image path, label) and splits.csv (sample ID, split, fold). The getting started guide shows both files and a complete walkthrough.

from soma import ExperimentConfig, Pipeline
from soma.config import (
    CohortConfig,
    EvaluationConfig,
    FeaturesConfig,
    LearnerConfig,
    RunConfig,
    TrainerConfig,
)

config = ExperimentConfig(
    run=RunConfig(output_dir="output", seed=0),
    cohort=CohortConfig(records="dataset.csv", splits="splits.csv"),
    features=FeaturesConfig(encoder="phikon"),
    learner=LearnerConfig("mil", {"aggregator": "abmil", "head": "binary_classification"}),
    trainer=TrainerConfig(max_epochs=5),
    evaluation=EvaluationConfig(metrics=["auroc", "balanced_accuracy"]),
)
result = Pipeline(config).run()
print(result.summary)
print(result.run_dir)

phikon weights are public and download on first use. To extract features once and reuse them across experiments, see the API guide.

Use the CLI

Run the same pipeline from a YAML config:

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

Or start from a preset, a complete experiment for a common task (soma list presets):

soma run --preset mil_classification --encoder phikon --aggregator abmil --cohort dataset.csv --splits splits.csv --out output
# or print it as an editable YAML with every default filled in, edit it, then run it:
soma init mil_classification --encoder phikon --aggregator abmil > experiment.yaml
soma run experiment.yaml

The YAML has the same seven sections as ExperimentConfig (run, cohort, features, loaders, learner, trainer, evaluation), spelled as the Python call spells them; a field left out keeps its default. soma resolves the config against the cohort and writes the result to the run's plan.yaml. Start with the task examples or the CLI reference. soma list prints the component kinds and soma list aggregators (or encoders, heads, decoders, benchmarks, ...) prints one kind's registered components with their params.

Explore

License

Apache-2.0.

Metadata

Release files for soma-pathology 2.3.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 2.3.0
File Size Uploaded Provenance Actions
soma_pathology-2.3.0.tar.gz 644.2 kB Without provenance Details for soma_pathology-2.3.0.tar.gz

Built distribution (wheel)

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

Total release size: 1.4 MB

Release files / soma_pathology-2.3.0.tar.gz

Download URL soma_pathology-2.3.0.tar.gz
Size 644.2 kB
Tags Source
SHA-256 checksum
How to use checksums
bf57501d2a63e3e017ad06cec26236ebe5daa2c2f298c0788a847286c7f3a861
BLAKE2b-256 checksum
How to use checksums
c4cb742f1a54c7f7894bd0c14a842af4b44d730d2aa82f1caaeac3e85e384b5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.18

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

Download URL soma_pathology-2.3.0-py3-none-any.whl
Size 770.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2773c45e8679133f773bd8dcdc1d9d8dfa06552f2c50558c33767f2252c5a6fa
BLAKE2b-256 checksum
How to use checksums
6b51f1f75e977967c9d1d90ca0f2974691f63e3a2b9c65071546ed71c1ef6783
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.18

Security for soma-pathology 2.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.3.0 This release

2 release files No provenance

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