CORR-VARS – Streamlining Real-World Evidence Studies and Bedside Use 
Build and manage clinical study cohorts from ICU and hospital data sources. Add, filter and export variables whose definitions are served — and versioned — by the CORR Concepts API.
Installation
uv add corr-vars
or pip install corr-vars. The development version (latest main) is available via
uv add git+https://github.com/CUB-CORR/corr_vars.
Requires Python ≥ 3.10.
Quick Start
from corr_vars import Cohort
cohort = Cohort(
obs_level="icu_stay", # "patient" | "hospital_stay" | "icu_stay" | "procedure"
sources={"reprodicu": {"path": "/path/to/reprodICU_files"}},
project="my_project", # project on the Concepts API
# api_key="corr_..." # or set CORR_CONCEPTS_API_KEY
)
# Add a pre-defined variable
cohort.add_variable("blood_sodium")
# Apply inclusion criteria and visualise the flowchart
cohort.include_list([
{"variable": "age_on_admission", "operation": ">= 18", "label": "Adults"},
{"variable": "icu_length_of_stay", "operation": "> 2", "label": "ICU stay > 2 days"},
])
cohort.figureone
# Export
cohort.save("my_cohort.corr3")
cohort.to_csv("output/")
Try it with the demo dataset
The charite_demo source reads a public, fully synthetic ICU dataset (20'000 ICU
stays), and the public demo Concepts API serves its variable definitions, so you can
try corr_vars without data access or an account:
cohort = Cohort(
obs_level="icu_stay",
sources={"charite_demo": {}},
project="demo",
api_key="cak_demo_0d2b53ac", # public demo key
)
Install with the extra (uv add "corr-vars[charite-demo]")
and follow the demo tutorial.
For a hands-on notebook to run yourself, see examples/.
Observation Levels
obs_level |
Primary key | One row per … |
|---|---|---|
"patient" |
patient_id |
patient |
"hospital_stay" |
case_id |
hospitalisation |
"icu_stay" |
icu_stay_id |
ICU admission |
"procedure" |
procedure_id |
surgical procedure |
Data Sources
Sources are plugins: each is a package under src/corr_vars/sources/ that
supplies cohort data and, optionally, variable extraction. Multiple sources can
be combined in a single Cohort call.
Two sources ship with the package: reprodicu, a ready-to-use example, and
local_datasource, a skeleton you bind to your own store.
ReprodICU
The plug-and-play example source. Download the
reprodICU parquet files and pass their
folder as path — nothing else to configure.
sources = {
"reprodicu": {
"path": "/path/to/reprodICU_files",
"include_datasets": [],
"exclude_datasets": [],
}
}
Local data source (local_datasource)
A source skeleton, pinned local in routing.toml: it ships the variable
classes (NativeStatic, DerivedStatic, DerivedDynamic, NativeDynamic,
ComplexVariable) and the extraction pipeline, but no store. Bind it to your
own data in two places:
- Replace
cohort.load_data(obs_level, source_kwargs)so it returns the observation frame (primary key plus the level'st_min/t_maxanchors). - Subclass
NativeExtractor, implementextract(cohort, id_column), and setNativeDynamic.extractor_classto your subclass.
Then fill mapping/vars.json and mapping/variables.py with your variable
definitions, or route the source to a Concepts API endpoint instead. See the
local_datasource API reference.
Custom variables
The aggregation classes are source-agnostic — construct one directly and add it to any cohort, including a reprodICU one:
from corr_vars import Cohort
from corr_vars.sources.local_datasource import DerivedStatic, NativeStatic
cohort = Cohort(
obs_level="icu_stay",
sources={"reprodicu": {"path": "/path/to/reprodICU_files"}},
project="my_project",
)
cohort.add_variable(NativeStatic(
var_name="max_sodium_icu",
select="!max value",
base_var="blood_sodium",
tmin="icu_admission",
tmax="icu_discharge",
))
cohort.add_variable(DerivedStatic(
var_name="hypernatremia",
requires=["max_sodium_icu"],
expression="max_sodium_icu > 145",
))
base_var and requires resolve through the cohort's own sources. Pass
tmin/tmax inside the constructor, not to add_variable. Full reference:
aggregation variables.
Variable Definitions
Variable definitions are not bundled with this package. They are fetched per
concept and per source from the CORR Concepts API, which also records the exact
version that was served. Routing is declared in
src/corr_vars/concepts/routing.toml:
[local]
sources = ["local_datasource"]
[[endpoint]]
url = "https://concepts.example.edu/api"
sources = ["*"]
A cohort authenticates against that endpoint on construction, so a missing
project or a bad key fails before the (slow) data load:
cohort = Cohort(project="my_project", api_key="corr_...")
cohort = Cohort(project="my_project", date="2025-06-30") # freeze to a day
cohort.add_variable("blood_sodium::v3") # pin one variable
Point a cohort at a different endpoint with Cohort(concepts_api_url=...).
Sources listed under [local] in routing.toml are never fetched; their
definitions are read from the source's bundled mapping module and keep working
with no network and no API key. local_datasource is the one bundled source
listed there.
Development
Setup
git clone https://github.com/CUB-CORR/corr_vars.git
cd corr_vars
uv sync --group dev
uv run pre-commit install
Pre-commit hooks enforce uniform formatting and catch common errors. When a hook modifies a file, stage the change and commit again.
Running Tests
If you have developed new features, please add relevant tests to the tests/ folder.
uv run pytest
Integration tests (tests/integration) run automatically once a pull request to main is opened. Results are attached to the pull request and a test report will be generated. Do not merge until tests pass.
tests/sources is hand-run: it needs the source's own data files plus a Concepts API project and key, skips when they are missing, and runs only when named (uv run pytest tests/sources). A bare uv run pytest runs tests/integration only, like CI, which needs neither.
Building the Documentation
cd docs
make clean && make html
# or: rm -rf _build && uv run sphinx-build -M html . _build
The HTML output is written to docs/_build/html/. Documentation is automatically published to docs.corr-vars.de on merge to main.
Releasing
Releases are published to PyPI as corr_vars by .github/workflows/release.yml using Trusted Publishing (OIDC). No API token is stored anywhere.
One-time setup
- On PyPI, add a pending trusted publisher. Use PyPI project name
corr_vars, ownerCUB-CORR, repositorycorr_vars, workflowrelease.ymland environmentpypi. The first successful publish creates the project. - In the GitHub repository, under Settings → Environments, create the environment
pypi. You can optionally add required reviewers topypiand restrict it tov*tags.
Release procedure
- Bump
__version__insrc/corr_vars/__init__.pyandversion/date-releasedinCITATION.cff, then merge tomain. - Tag and push:
git tag v2.0.3 && git push origin v2.0.3.
The workflow first checks that the tag, __version__ and CITATION.cff agree. It then runs the tests, builds and checks the sdist and wheel, publishes to PyPI and creates the GitHub release with the built files attached.
Contributing
See the Contributing Variables guide for variable contributions in the documentation.
- Create an issue or feature request on GitHub.
- Branch off
mainusing the naming conventionIssueNumber-IssueTitle. - Commit your changes and push to your branch (i.e. variables or new features)
- Run unit tests as described above by opening a pull request or running them manually.
- If you have changed anything relevant to the documentation update the documentation as described above. This is not done automatically!
License
MIT — see LICENSE.md.
Metadata
Release files for corr-vars 2.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| corr_vars-2.1.1.tar.gz | 205.6 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| corr_vars-2.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 444.9 kB
Release files / corr_vars-2.1.1.tar.gz
| Download URL | corr_vars-2.1.1.tar.gz |
|---|---|
| Size | 205.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4390b0d1d53850e68151649e4e374925f33f8f09e25ed07d0543bf8ea724993d
|
|
BLAKE2b-256 checksum How to use checksums |
e3460a1b20ce75e076eeafe00cc7a11c52f84f081363820d7db1fd53fffbf521
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 22, 2026.
Transparency logRelease files / corr_vars-2.1.1-py3-none-any.whl
| Download URL | corr_vars-2.1.1-py3-none-any.whl |
|---|---|
| Size | 239.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4b5b207f5fb16da8abc0ad0cb4ea70460fd4b084af1667926833daffb73b177b
|
|
BLAKE2b-256 checksum How to use checksums |
66bbb818ffca215a83f056413d4063da3fa9c04a2355ead6ff01236b862decd9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 22, 2026.
Transparency logSecurity for corr-vars 2.1.1
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.
Attestation for corr_vars-2.1.1.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 22, 2026.
Transparency logA 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.