Installation
You only do this once.
Before you start
You need Python 3.9, 3.10, 3.11 or 3.12. Python 3.13 is not yet supported.
To check what you have, open a terminal and type:
python --version
If that says “command not found”, or shows a version outside the range, install Miniforge and reopen your terminal.
Opening a terminal
On macOS press Cmd + Space, type “Terminal”, press Enter. On Windows
press Start, type “Miniforge Prompt”, press Enter. On Linux press
Ctrl + Alt + T.
Step 1 - Create a separate environment
An environment is a private space for this project’s software, so it cannot clash with anything else on your computer. Pick one option.
Option A - conda (recommended)
conda create -n cardiacprep python=3.11 -y
conda activate cardiacprep
Option B - venv (built into Python)
python -m venv .venv
Activate it. On macOS or Linux:
source .venv/bin/activate
On Windows:
.venv\Scripts\activate
How to tell it worked: your prompt now starts with (cardiacprep) or
(.venv).
Warning
Activate the environment every time you open a new terminal. If your prompt does not show the name in brackets, run the activate line again.
Step 2 - Install the pipeline
pip install cardiacprep
This takes several minutes. It is finished when your prompt reappears.
Step 3 - Set up a folder for your study
Go to wherever you want your results to live, then:
cardiac-prep init
That writes config.yaml and creates the input_data, output and models
folders beside it, then prints the settings worth checking before you start.
Tip
cardiac-prep init --output ./my-study sets everything up in a new folder
instead, which is handy when you have several studies on the go.
Step 4 - Get the heartbeat detector
The pipeline uses a machine learning model to find heartbeats. It is too large to keep in the repository, so it is downloaded separately.
You do not normally need to do anything here. The first time you run the
pipeline it fetches the weights into your models folder automatically, checks
them against a known checksum, and carries on.
To fetch them ahead of time, worth doing before working somewhere without a reliable connection:
cardiac-prep download
No internet on the machine that processes your data?
Run cardiac-prep download --model-dir /somewhere on a machine that does have
a connection, copy the .keras file across, and set auto_download_model: false
in your config.yaml.
The pipeline finds the file by extension, so the exact name does not matter -
but there must be exactly one .keras file in that folder, otherwise it will
refuse to guess. Every output row records the file name and its SHA-256, so you
can always tell which detector produced a given result.
Step 5 - Check it works
cardiac-prep --help
If you see a list of options, setup is complete.
Working from a clone
Contributors, and anyone who wants to modify the pipeline, should work from a checkout instead:
git clone https://github.com/OxWearables/cardiac-prep.git
cd cardiac-prep && pip install -e ".[dev]"
A clone already contains config.yaml and the working folders, so init is
not needed. It also has process.py, summarise_dataset.py and
plot_subject.py at the root, which run the same subcommands without
installing anything. See Development.