Signal guides
Choose a signal to see focused examples and saved plots. Start with the quickstart if you want a complete synthetic ECG workflow before exploring individual functions.
Choose a signal
Section titled “Choose a signal”Clean waveforms, find R-peaks, derive RR intervals, and generate synthetic ECG.
Find pulse peaks and explore heart rate, respiratory rate, and SpO₂ examples.
Find respiratory peaks and calculate rate from sampled breathing signals.
Calculate ENMO, tilt angles, and activity counts from accelerometer data.
Calculate time- and frequency-domain measures from beat intervals.
Find shared filtering, resampling, smoothing, and transform examples.
Short examples
Section titled “Short examples”Compute heart rate from ECG peaks
Section titled “Compute heart rate from ECG peaks”import physiokit as pk
fs = 250ecg, segments, fiducials = pk.ecg.synthesize( signal_length=10 * fs, sample_rate=fs, heart_rate=72, leads=1,)ecg = pk.ecg.clean(ecg.squeeze(), sample_rate=fs)
bpm, qos = pk.ecg.compute_heart_rate(ecg, sample_rate=fs, method="peak")print(bpm, qos)Find PPG peaks
Section titled “Find PPG peaks”import numpy as npimport physiokit as pk
fs = 100t = np.arange(0, 8, 1 / fs)ppg = np.sin(2 * np.pi * 1.1 * t)
peaks = pk.ppg.find_peaks(ppg, sample_rate=fs)print(len(peaks))Respiratory rate from RSP using FFT
Section titled “Respiratory rate from RSP using FFT”import numpy as npimport physiokit as pk
fs = 25t = np.arange(0, 40, 1 / fs)rsp = np.sin(2 * np.pi * 0.2 * t)
bpm, qos = pk.rsp.compute_respiratory_rate(rsp, sample_rate=fs, method="fft")print(bpm, qos)IMU ENMO and tilt
Section titled “IMU ENMO and tilt”import numpy as npimport physiokit as pk
x = np.array([0, 0.1, 0.2])y = np.array([0, 0.1, 0.2])z = np.array([1, 1.0, 1.1])
enmo = pk.imu.compute_enmo(x, y, z)angles = pk.imu.compute_tilt_angles(x, y, z, in_radians=False)print(enmo, angles)Signal helpers: filter and FFT
Section titled “Signal helpers: filter and FFT”import numpy as npimport physiokit as pk
fs = 100t = np.arange(0, 5, 1 / fs)sig = np.sin(2 * np.pi * 2 * t) + 0.2 * np.random.randn(t.size)
clean = pk.signal.filter_signal(sig, lowcut=0.5, highcut=20, sample_rate=fs)freqs, sp = pk.signal.compute_fft(clean, sample_rate=fs)print(freqs[np.argmax(np.abs(sp))])