Skip to main content

suMEDS

PyPI - Version codecov tests code-quality Python Version license PRs contributors DOI MEDS v0.4

suMEDS (pronounced "summed-s", past tense of "sum" + s) creates a compact code catalog for performing tasks Medical Event Data Standard (MEDS) datasets. MEDS data should be "summed" in this way in a storage-efficient format, without the need to access the full dataset.

It can be seen as a form of "extended metadata," as we sometimes need more information than vanilla MEDS metadata provides, but don't want to expose our complete dataset (either because of privacy concerns, storage capacity, or token use efficiency for LLMs). It joins canonical descriptions and configurable parent, child, and sibling codes to event and unique-subject counts, then masks or removes rare codes before writing Parquet, CSV, or JSON.

Polars scans, aggregations, joins, and writes stay lazy. This should mean that it could run with little resources on large MEDS datasets.

Install and run

Normal install:

pip install sumeds

Datasets with more than 2³² rows require Polars' 64-bit runtime:

pip install "sumeds[rt64]"

Development

uv sync
uv run suMEDS tests/resources/MIMICIV_DEMO/MEDS_cohort \
  --output code-summary.parquet \
  --min-subjects 20 \
  --split-columns

Or use YAML:

summary:
  per_split: false
  split_columns: true
  partitions: 256
privacy:
  min_subjects: 20
  min_split_subjects: 1
  rare_code_action: bucket
  rare_code_label: __RARE__
  round_counts_to: 5
uv run suMEDS /path/to/MEDS -o summary.parquet -c examples/summary.yaml
# The suffix selects CSV or JSON instead:
uv run suMEDS /path/to/MEDS -o summary.json -c examples/summary.yaml

CLI flags override YAML. The defaults bucket codes seen in fewer than 20 unique subjects and retain exact counts.

Optionally fill missing descriptions, all ancestors, OMOP concept IDs, domains, and standard-concept markers from OHDSI Athena. Child and sibling expansion are opt-in:

uv run suMEDS /path/to/MEDS -o summary.parquet \
  --athena-csv /path/to/athena --child-codes --child-depth 3 --sibling-codes
# Or use PostgreSQL through the installed psql client:
uv run suMEDS /path/to/MEDS -o summary.parquet \
  --athena-postgres postgresql://postgres@localhost/omop

Standalone enrichment avoids rescanning event data:

uv run suMEDS-enrich metadata/codes.parquet -o codes-enriched.parquet \
  --athena-csv /path/to/athena

The standalone command shows phase progress and reports Athena matches and before/after metadata coverage.

Both VOCABULARY//CODE//... and VOCABULARY//VOCABULARY_VERSION//CODE layouts are resolved. See the Athena enrichment guide.

Python API

from sumeds import EnrichmentConfig, SummaryConfig, summarize

path = summarize(
    "/path/to/MEDS",
    "code-summary.parquet",
    SummaryConfig(
        min_subjects=20,
        rare_code_action="bucket",
        enrichment=EnrichmentConfig(csv_dir="/path/to/athena"),
    ),
)

The output format is inferred from .parquet, .csv, or .json (with .jsonl/.ndjson also supported). It preserves all code-metadata extension columns and adds event_count, subject_count, and is_masked. per_split=True emits one row per split. split_columns=True keeps the total row and adds columns such as event_count_train and subject_count_train from subject_splits.parquet. Set min_split_subjects above 1 to suppress rare split-level cells. numeric_stats=True (CLI --numeric-stats) adds per-code numeric_value statistics: count, min, max, mean, median, std, and a confidence interval, or any subset such as numeric_stats=["mean", "std"].

Documentation

uv run mkdocs serve
uv run mkdocs build --strict

See the documentation site for the data flow, complete CLI and YAML reference, output schema, Python API, and privacy limitations.

Development

uv run pre-commit run --all-files
uv run pytest
uv run mkdocs build --strict

The included integration test uses tests/resources/MIMICIV_DEMO/MEDS_cohort when present.

Metadata

Release files for sumeds 0.3.2

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

Source distribution (sdist)

Source distribution for sumeds 0.3.2
File Size Uploaded Provenance
sumeds-0.3.2.tar.gz 20.9 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for sumeds 0.3.2
File Interpreter ABI Platform
sumeds-0.3.2-py3-none-any.whl Python 3 none any Details

Total release size: 45.8 kB

Release files / sumeds-0.3.2.tar.gz

Download URL sumeds-0.3.2.tar.gz
Size 20.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2ebcced4c8713c73baea2b33da8bb8ef1f7f7d022b1b1c1d3167e4ad4f1b9944
BLAKE2b-256 checksum
How to use checksums
329b2fb3441c24149468b477e857fb2567b7eb98d9d3f92b941bd9bf85e51115
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Release files / sumeds-0.3.2-py3-none-any.whl

Download URL sumeds-0.3.2-py3-none-any.whl
Size 24.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8eef47b3d5569791b0d30997afda9185627bd68631dac5f8d67da869a208dd26
BLAKE2b-256 checksum
How to use checksums
0d601ea1086fe9d35af7e870ea80b390942655b1584dc666332c7c9e3389c6c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Security for sumeds 0.3.2

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for sumeds-0.3.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

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.

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