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.
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 --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 > 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
- How soma works: pipeline components and experiment design.
- Modeling paths: tile, slide, patient, and dense prediction workflows.
- Use cases: the preset and end-to-end scenario of each path.
- Benchmarking: fixed protocols and encoder comparisons, including task-free CRoMa evaluation.
- Caching and run outputs: feature reuse and experiment provenance.
License
Metadata
Release files for soma-pathology 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| soma_pathology-2.0.0.tar.gz | 573.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| soma_pathology-2.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.3 MB
Release files / soma_pathology-2.0.0.tar.gz
| Download URL | soma_pathology-2.0.0.tar.gz |
|---|---|
| Size | 573.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1409c4a7f143b82110c8948ed26a434a280fa63c4488dcc124d9fcb09f950c57
|
|
BLAKE2b-256 checksum How to use checksums |
c7a7a621fa3e171cfb9fc2abab6b0eb964192f85f143bbebd530492ac6d2332b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.17
|
Release files / soma_pathology-2.0.0-py3-none-any.whl
| Download URL | soma_pathology-2.0.0-py3-none-any.whl |
|---|---|
| Size | 697.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4bd19fb9f4b1edadd206287db4b279ab015b7b2b3c8f9f90389dfb1c1454c2a4
|
|
BLAKE2b-256 checksum How to use checksums |
9637410cd8cb4edd6abf3b41e2319c99da66e65703b98dd8b8df71d711c20946
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.17
|