We have released physionet, a Python package and command-line tool for working with PhysioNet. Use it to search for datasets, preview and download them, load tables directly into Python, and check a dataset before submitting it. Install or upgrade it with:
pip install -U physionet
Find a dataset. Search published projects, then view the details of a specific version:
physionet search "sleep" --resource-type database
physionet show mimic-iv-demo --version 2.2
Preview tables before downloading. List a dataset's tables and their columns, find the tables that have a particular column, or show the first rows of a table. Only the start of each file is read, so this takes seconds even for very large tables:
physionet tables mimic-iv-demo --version 2.2
physionet tables mimic-iv-demo --version 2.2 --column stay_id
physionet head mimic-iv-demo hosp/patients --version 2.2
Download files. Download a whole project, or just the files you need. Downloads resume if interrupted, and every file is checked against the project's published checksums. Open datasets are downloaded from our AWS mirror when available. Use --jobs to download several files at once, which is much faster for datasets with many small files:
physionet download mimic-iv-demo --version 2.2
physionet download mimic-iv-demo --version 2.2 --include "hosp/*" --dry-run
physionet download mitdb --jobs 4
Sign in to access restricted data. Restricted and credentialed datasets need a PhysioNet account that meets the dataset's access requirements. Sign in once: the package shows a link and a short code, which you approve in your browser. This also works on remote servers and clusters, because you can open the link on any device. Later downloads, from the command line and from Python, then use your account. Your password is never stored.
physionet login
physionet download mimiciv --version 3.1
physionet whoami
physionet logout
In a notebook, call physionet.login() instead. You can see your signed-in devices, and sign them out, under Settings > Tokens. For scheduled jobs and continuous integration, create a personal access token there with the "Download data" scope and set it as the PHYSIONET_TOKEN environment variable. Signing in with your username and password still works.
Check your access. See whether your account can download a dataset, and which steps are still needed, such as credentialing, training, or signing the data use agreement:
physionet access mimiciv --version 3.1 --username YOUR_USERNAME
Load a table in Python. Files are downloaded once and cached, so later calls read them from disk. Restricted tables load the same way once you are signed in:
import physionet
patients = physionet.load("mimic-iv-demo", "hosp/patients", version="2.2")
PhysioNet files can also be opened directly with pandas, polars, DuckDB and other tools that read files through fsspec, using physionet:// paths. These use the same cache and checksum checks:
import pandas as pd
admissions = pd.read_csv("physionet://mimic-iv-demo/2.2/hosp/admissions.csv.gz")
Fix problems. If a download or sign-in is not working, physionet doctor checks your setup, including the connection to PhysioNet, your sign-in, and the download cache, and explains how to fix anything that is wrong. Add a dataset name to also check your access to it. The report never includes passwords or tokens, so you can include it when reporting an issue:
physionet doctor
physionet doctor mimiciv
Prepare a submission. Check a dataset for common problems, such as missing documentation, file naming issues, duplicate files, and possible identifiers, before you submit it to PhysioNet:
physionet validate /path/to/dataset
The package is open source and requires Python 3.10 or later. See the GitHub repository for full documentation, and to report issues or suggest features.