CardioSim
Gymnasium environments for reinforcement learning in cardiac electrophysiology
CardioSim provides three Gymnasium-compatible reinforcement learning environments for cardiac electrophysiology: pacemaker control, antiarrhythmic drug dosing, and defibrillation timing. It includes the FitzHugh-Nagumo and Aliev-Panfilov cardiac action potential models, a single-compartment pharmacokinetic model, a cardiac conduction system model, configurable difficulty tiers, and baseline agents (random, heuristic, PPO). The package is designed for benchmarking RL algorithms on sequential decision-making problems in cardiology where real-world experimentation is impractical.
Installation
pip install cardiosim # Core (numpy, scipy, gymnasium)
pip install cardiosim[train] # + SB3, PyTorch for RL training
pip install cardiosim[all] # Everything
Development install:
git clone https://github.com/HassDhia/cardiosim.git
cd cardiosim
pip install -e ".[all]"
Quick Start
import gymnasium as gym
import cardiosim
env = gym.make("cardiosim/PacingControl-v0")
obs, info = env.reset(seed=42)
for _ in range(100):
action = env.action_space.sample()
obs, reward, terminated, truncated, info = env.step(action)
if terminated or truncated:
obs, info = env.reset()
env.close()
Environments
| Environment | Paradigm | Observation | Action | Key Challenge |
|---|---|---|---|---|
PacingControl-v0 |
Pacemaker optimization | Voltage, recovery, HR, HR error, HRV | Pacing rate, amplitude | Restore normal sinus rhythm in bradycardia |
AntiarrhythmicDosing-v0 |
Drug dosing | Voltage, recovery, concentration, arrhythmia, efficacy | Drug dose (mg) | Maintain therapeutic window, suppress arrhythmia |
DefibrillationTiming-v0 |
Defibrillation | Membrane potential, recovery, fibrillation index | Shock decision, energy (J) | Terminate fibrillation with minimal shocks |
Architecture
CardioSim combines established cardiac electrophysiology models with Gymnasium's RL interface:
- FitzHugh-Nagumo model - Two-variable excitable membrane model (FitzHugh, 1961)
- Aliev-Panfilov model - Cardiac-specific action potential dynamics (Aliev & Panfilov, 1996)
- PK/PD model - Single-compartment pharmacokinetics with sigmoid Emax pharmacodynamics
- Conduction system - SA/AV node timing with configurable conduction block
- Difficulty tiers - Easy, medium, hard configurations per environment
- Baseline agents - Random, heuristic (clinical rules), and PPO (Stable-Baselines3)
Paper
The accompanying paper is available at:
Citation
If you use CardioSim in your research, please cite:
@software{dhia2026cardiosim,
author = {Dhia, Hass},
title = {CardioSim: Gymnasium Environments for Reinforcement Learning in Cardiac Electrophysiology},
year = {2026},
publisher = {Smart Technology Investments Research Institute},
url = {https://github.com/HassDhia/cardiosim}
}
License
MIT License. See LICENSE for details.
Contact
Hass Dhia - Smart Technology Investments Research Institute
Metadata
Release files for cardiosim 0.1.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 | Provenance | |
|---|---|---|---|---|
| cardiosim-0.1.0.tar.gz | 27.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cardiosim-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 54.8 kB
Release files / cardiosim-0.1.0.tar.gz
| Download URL | cardiosim-0.1.0.tar.gz |
|---|---|
| Size | 27.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
abd45a4c1122ac9dd6e65528d282e753a67f836b1bbd03aad2441725802a90d6
|
|
BLAKE2b-256 checksum How to use checksums |
cb5f8314ccb6689a79e8a7f0d650361c2780b94b8d8e674c52e92159d307af47
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.8
|
Release files / cardiosim-0.1.0-py3-none-any.whl
| Download URL | cardiosim-0.1.0-py3-none-any.whl |
|---|---|
| Size | 27.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
45e04103a28576975a639034a69ed0d6ea3c12ba7747b0447f234d30296795ab
|
|
BLAKE2b-256 checksum How to use checksums |
9a8f9719c94f0d75a3b9306846f2792e6b4a9227a6406edecd28d5730265f8d2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.8
|
Security for cardiosim 0.1.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.