Installation

torchcor runs on Python 3.10+ and is built on PyTorch, so it uses your GPU when one is available and falls back to CPU otherwise.

Install

pip install torchcor

Installs the latest release from PyPI together with its runtime dependencies (PyTorch, NumPy, SciPy, PyVista, …).

Clone the repository and install in editable mode so your changes take effect immediately:

git clone https://github.com/sagebei/torchcor.git
cd torchcor
pip install -e .

Tip

For GPU runs, install the PyTorch build that matches your CUDA toolkit first (see pytorch.org/get-started), then pip install torchcor. On CPU-only machines the default wheel is fine.

Requirements

Component

Requirement

Python

≥ 3.10

Core

PyTorch ≥ 2.0, NumPy, SciPy

Meshing / visualisation

PyVista, pygmsh

ECG / signal analysis

pandas, wfdb, scikit-learn, seaborn, matplotlib

GPU (optional)

a CUDA-capable device + a matching PyTorch build

Verify the installation

import torchcor as tc
print(tc.get_device())          # cuda:0  (or cpu)

from torchcor.simulator import Monodomain, ReactionEikonal
from torchcor.ionic import TenTusscherPanfilov
print("torchcor is ready")

Select the device once at the top of a script:

import torchcor as tc
tc.set_device("cuda:0")         # or "cpu"

Next steps

⚡ Quickstart

Run your first monodomain simulation in a dozen lines.

Quickstart
📚 Tutorials

Monodomain, reaction-eikonal, and body-surface ECGs.

Tutorials