Configuration reference

Every setting lives in config.yaml at the root of the project. All of them are optional: delete a line and the pipeline falls back to the default shown here. You should never need to edit a .py file.

Command-line flags override the file, which overrides these defaults:

dataclass defaults  ->  config.yaml  ->  command-line flags

A mistake in the file stops the run immediately, before any recording is processed, with a message naming the setting at fault.

Everyday settings

Where your files are

input_dir

Default: input_dir: ./input_data

Folder containing the .edf / .EDF files you want to process.

output_dir

Default: output_dir: ./output

Folder where results are written. Created automatically if missing.

model_dir

Default: model_dir: ./models

Folder containing the QRS detector weights (a .keras file). The weights are downloaded separately - see models/README.md.

model_path

Default: model_path: ~

Normally leave this unset: the pipeline finds the single .keras file in model_dir on its own. Set an explicit path only if you keep several models side by side and need to choose one.

auto_download_model

Default: auto_download_model: true

Fetch the detector weights automatically the first time you run, if model_dir does not already contain them. Set to false on a machine with no internet access, and download them separately instead - or fetch them ahead of time with: cardiac-prep download

How much of your computer to use

n_processes

Default: n_processes: ~

Number of files to process at the same time. Leave unset to use all CPU cores except one, which keeps your machine usable while the pipeline runs. Set to 1 if you want to see errors clearly.

chunk_hours

Default: chunk_hours: 24

Hours of recording loaded into memory at a time. Lower this if you run out of memory on very long recordings.

ECG quality control

These decide which 10-second segments of ECG are trustworthy enough to use. The defaults are reasonable; change them only with a specific reason.

rr_cover_min

Default: rr_cover_min: 0.75

Minimum fraction of a segment that must be covered by valid heartbeats.

n_beats_min

Default: n_beats_min: 5

Minimum number of detected beats before a segment is scored at all.

rr_min_ms, rr_max_ms

Default: rr_min_ms: 250, rr_max_ms: 2500

Shortest and longest believable gap between heartbeats, in milliseconds. 250 ms is 240 bpm; 2500 ms is 24 bpm. Anything outside this is an artefact.

max_rr_outliers

Default: max_rr_outliers: 1

How many implausibly long gaps (a missed beat) a segment may contain.

qc_warn_below

Default: qc_warn_below: 0.75

If less than this fraction of worn-time ECG passes quality control, the pipeline prints a warning and saves example failing traces so you can look at what went wrong.

Physical activity intensity

Cut-points in milli-g (mg) for Mean Amplitude Deviation, from Etzkorn et al. (2024): Zio XT chest-worn cut-points derived in 381 older adults in the ARIC study, mapped from waist-worn ActiGraph GT3X.

IMPORTANT: these were validated in older adults (median age 78). If your participants are younger, these boundaries may not describe them well. Must be listed smallest to largest.

activity_very_light_mg, activity_light_mg, activity_moderate_mg

Default: activity_very_light_mg: 9.04, activity_light_mg: 28.19, activity_moderate_mg: 58.08

Resting heart rate and HRV

sleep_threshold_mg

Default: sleep_threshold_mg: 9.04

Movement below this (in mg) counts as being at rest.

night_start_hour, night_end_hour

Default: night_start_hour: 21, night_end_hour: 9

Clock window used to find overnight rest, as whole hours (0-23). The default 21:00-09:00 assumes a conventional sleep schedule.

WARNING: this misclassifies anyone who sleeps outside these hours - shift workers, or someone who regularly sleeps 02:00-11:00. If that describes your participants, adjust the window here. Automatic per-participant detection of the main sleep period is planned.

Signal format

The bundled QRS detector was trained on 10-second segments of 250 Hz ECG. Changing these requires a model retrained to match, so leave them alone unless you know exactly what you are doing.

segment_seconds, fs_expected

Default: segment_seconds: 10, fs_expected: 250

Advanced settings

These control the signal processing itself. The defaults match the conditions the bundled QRS detector was trained under, so changing them changes what the model sees. Check the effect on detection before trusting the results.

The exception is mains_hz, which you should set correctly for your country regardless.

ECG filtering

mains_hz

Default: mains_hz: 50.0

Mains frequency removed by a notch filter, in Hz. 50 across most of the world; set 60 in North America and parts of Asia, otherwise mains hum is left in the signal.

mains_notch_q

Default: mains_notch_q: 30.0

Notch width. Higher is narrower, removing less of the surrounding signal.

ecg_bandpass_low_hz, ecg_bandpass_high_hz

Default: ecg_bandpass_low_hz: 2.0, ecg_bandpass_high_hz: 40.0

Bandpass corners in Hz, applied after the notch. Both must sit below half the sampling rate.

ECG amplitude clipping

Both values are in millivolts. Lower them to clip more aggressively.

ecg_clip_mv

Default: ecg_clip_mv: 4.0

Hard limit applied before filtering. A segment with more than 5% of its samples beyond this is treated as saturated and fails quality control.

ecg_clip_margin_mv

Default: ecg_clip_margin_mv: 1.0

Just before beat detection the signal is clipped again to a band that adapts to the recording: the median per-segment peak, plus this margin. Most QRS complexes fall within about 1 mV, so tightening this suppresses artefact - but movement during exercise genuinely exceeds it, and clipping too hard there removes real signal along with the noise.

ECG noise gate

A segment whose variance falls outside this range, or whose peak-to-peak is below the minimum, is judged too noisy or too flat to score at all.

ecg_var_min, ecg_var_max, ecg_min_ptp_mv

Default: ecg_var_min: 0.0001, ecg_var_max: 2.0, ecg_min_ptp_mv: 0.025

Beat detection

qrs_threshold

Default: qrs_threshold: 0.5

Probability above which the detector calls a sample part of a QRS complex. Lowering this finds more beats and more false positives; raising it does the reverse. 0.5 is the usual starting point.

rr_outlier_factor

Default: rr_outlier_factor: 1.8

An R-R interval longer than this multiple of the segment median counts as an outlier, usually a missed beat. Works together with max_rr_outliers above.

Accelerometer

acc_clip_mg

Default: acc_clip_mg: 4000.0

Saturation limit in milli-g. 4000 suits a +/-4 g device; raise it to 8000 for a +/-8 g one, or clipping will be over-reported.

acc_calibrate

Default: acc_calibrate: true

Auto-calibrate the accelerometer against gravity before use. Turn off only if your data is already calibrated.

acc_epoch_seconds

Default: acc_epoch_seconds: 60

Movement is measured as Mean Amplitude Deviation: the average distance of the acceleration magnitude from its own average over an epoch. This is the quantity the activity cut-points above were derived from.

Etzkorn et al. published those cut-points at minute level, so 60 seconds is the value they were validated at. A shorter epoch spreads MAD over a wider range and shifts time between the intensity bands, so changing this means the cut-points no longer describe what they were meant to.

Must divide evenly into segment_seconds.

Gap filling

impute_gap_max_s

Default: impute_gap_max_s: 600

Longest gap in seconds filled by linear interpolation. Gaps longer than this are filled from the average for that time of day instead. Set to 0 to interpolate nothing.