Chris Collins

Tools · medical

Biosignal analysis

Load an ECG, PPG or EMG recording (CSV, PhysioNet WFDB, EDF) or a synthetic sample, filter out wander and mains, detect ECG beats with Pan–Tompkins and correct them, compute RR intervals and HRV, see why a PPG ratio-of-ratios is not an SpO₂ reading, and find EMG onsets — analysis of recordings for learning, not a medical device.

Added

How to use it
Educational — not a medical device. Not for diagnosis, treatment, monitoring or dosing. Everything here analyses a stored recording so you can learn how biosignal processing works. The tool never names rhythms or says whether a value is normal. Never connect anything you built to a person. Equipment connected to a patient is governed by IEC 60601-1, and bench electronics are not isolated to its limits. Use recorded or synthetic data.

Companion to chapter 7 (nerves and the biosignals bridge), chapter 9 (the ECG and how a pulse oximeter works and fails) and chapter 16 (WFDB and PhysioNet projects) of Human Biology for the Medical Maker. The signal amplitudes and bandwidths it quotes are from the biosignals table in Appendix C, which gives them for orientation only.

How to use it

Recording. Start with a built-in sample. Each one is generated in the browser and labelled synthetic: a 5-minute ECG (clean, or with baseline wander, 50 Hz mains, noise and two motion artefacts), red and infra-red PPG generated with R = 0.6, and surface EMG with three contractions. You can also open your own file. Files are read only in the page, never uploaded and never saved.

  • CSV/TSV/text: comma, tab, semicolon or space separated, with an optional header row and units row (PhysioNet’s CSV export works). Choose a time column, in seconds, milliseconds or h:mm:ss.sss, or give the sample rate. If the time stamps are uneven, the signal is resampled linearly and the tool says so.

  • WFDB (PhysioNet): select the .hea header together with its .dat file(s). Formats 16, 61, 80 and 212 are read. Samples are converted to physical units as (ADC − baseline) ÷ gain, and invalid-sample codes are filled by interpolation, with a note.

  • EDF/EDF+: every signal is read at its own sample rate, and annotation channels are skipped. The patient and recording identification fields are never read out or shown.

For real recordings, use open, de-identified data: PhysioNet has many ECG, PPG and EMG databases.

Filters. There are two settings, one used by the ECG tab and one by the EMG tab: a high-pass for baseline wander, a low-pass, and a 50 or 60 Hz notch with an adjustable Q. Each is a second-order Butterworth or notch section (RBJ biquad) run forward and then backward over the whole recording. That gives zero phase, so peaks don’t shift, and each section’s attenuation counts twice, so a cutoff is −6 dB rather than −3 dB. A real-time monitor cannot do this. The page plots the frequency response and the signal before and after. Presets give the book’s ECG diagnostic band (~0.05–150 Hz), a 0.5–40 Hz viewing band, and the book’s surface-EMG band (~10–500 Hz). If a cutoff is impossible at the recording’s sample rate, the tool says so and does not move the cutoff for you.

ECG beats and HRV. R peaks are detected with the Pan–Tompkins algorithm (Pan and Tompkins, IEEE Trans. Biomed. Eng. 32:230, 1985). The steps are:

  1. a 5–15 Hz band-pass (zero-phase Butterworth here, not the paper’s integer filters for 200 Hz);

  2. a five-point derivative;

  3. squaring;

  4. a 150 ms moving-window integrator;

  5. adaptive signal and noise thresholds, with a 200 ms refractory period, T-wave rejection between 200 and 360 ms, and a search-back with the lower threshold when no beat appears within 166 % of the average RR.

Click a marker to remove a false detection, or click a missed peak to add a beat, which snaps to the highest point within 60 ms. The beat list shows the beats in the current window. From the edited list the tool computes RR intervals, beat-to-beat heart rate, SDNN, RMSSD, pNN50 and a Poincaré plot with SD1 and SD2. These are the time-domain measures of the Task Force of the ESC and NASPE (Circulation 93:1043, 1996); SD1 and SD2 follow Brennan et al. (IEEE Trans. Biomed. Eng. 48:1342, 2001).

PPG ratio. Pick the red and infra-red channels. For each pulse, AC is the peak-to-trough height of the 0.5–8 Hz band-passed channel and DC is the channel’s mean, which gives R = (ACred/DCred) ÷ (ACIR/DCIR). The tool reports the median and interquartile range of R. It then draws the straight line often used in teaching, SpO₂ ≈ 110 − 25·R (for example Texas Instruments application note SLAA655 and NXP AN4327, which both stress that real devices use their own empirical calibration; the book does not give this line). The line is shown with a deliberately wide ±6 percentage-point band, about twice the 3 % Arms accuracy in the FDA’s 2013 premarket guidance for pulse oximeters. The tool only ever shows a range, never one SpO₂ number. As chapter 9 explains, the real mapping is an empirical calibration curve from desaturation studies. It overestimates saturation more often in people with darker skin, and it fails with low perfusion, motion, ambient light and dyshaemoglobins.

EMG onsets. The filtered EMG is rectified and smoothed with a centred moving-RMS window. A burst starts when the envelope stays above your threshold for at least the minimum duration, and ends when it stays below for as long. You set the threshold either as a fixed level or as the mean plus k standard deviations of a quiet stretch you choose (an approach compared by Hodges and Bui, Electroencephalogr. Clin. Neurophysiol. 101:511, 1996). The default k = 3 is only a starting point. Choose the window, k and the minimum duration for your own recording.

Export. Each tab exports CSV: raw and filtered series, the beat list (time, RR, heart rate, and whether you added the beat), per-pulse PPG AC/DC/R, and the EMG envelope and onsets.

To generate synthetic ECG, EMG, EEG or PPG and see signal averaging, use the spectrum analyser. That tool generates signals; this one analyses recordings.

⛶ Full screen (or F) gives the active tab’s main plot the whole screen — the browser’s full screen where it is allowed, otherwise a full-window layer (iPhone). The tab’s settings and other panels start hidden; ◫ Panels brings them back. Escape leaves.

Limits

  • Not validated against any standard database. Pan–Tompkins misses beats and finds false ones, especially with noise, motion, paced or wide complexes, or large T waves, so check the beat list before reading any figure. The tool does not classify beats or rhythms.

  • HRV figures include every interval, so one wrong beat changes SDNN and RMSSD noticeably. The Task Force’s short-term figures assume 5-minute recordings, and values from recordings of different lengths are not comparable. None of the figures is a reference range, and none says anything about a person.

  • The PPG ratio assumes the two channels were recorded simultaneously by the same detector with stable LEDs. Without a calibration made for your sensor, R cannot be turned into a saturation. The line and band are an illustration only.

  • EMG onset times depend on your filters, window, threshold and minimum duration. Report all four with any onset time.

  • WFDB multi-segment and multi-frequency records, formats other than 16/61/80/212, BDF and discontinuous EDF+ timing are not supported. Very long recordings (hours at high sample rates) may be slow.

  • Filters run over the whole stored recording, both forwards and backwards, which a live device cannot do. The result is non-causal: a narrow mains notch rings before a sudden burst as well as after it. On the synthetic EMG sample, a Q 30 notch moves the first onset about 0.2 s earlier, so compare onsets with the notch off or at a lower Q.

Related: spectrum analyser (spectra, synthetic biosignals and signal averaging), active filter designer (analogue front-end filters), ADC calculator (resolution and sampling for an acquisition chain).

Sharing

Share link (under the title) copies a URL that restores your settings: filters, thresholds and the chosen synthetic sample. Recordings you open are never put in a link. Tabs can be linked directly, for example /tools/biosignals/#ecg.

Runs entirely in your browser; nothing you type leaves this page.