Separate synthetic radar breathing and heartbeat cues
Recover simulated breathing and heartbeat peaks while rejecting a gross-motion window and retaining the medical boundary.

Radio Remi
Radio Remi: predict first, inspect every intermediate value, and keep the claim inside the evidence.
Predict the reading, then compare it with the measurement.
Python 3 in your browser (JupyterLite)
Python · no installOpen the notebook in your browser and run each Python cell; no install or account is needed.
Three ways to run: use JupyterLite here with no install; run main.py locally from the downloadable lab folder; or open the same notebook in Google Colab.
Steps
Step 1
- Do
- In the JupyterLite notebook, run the Step 1 cell to predict the stronger peak before running the fixture.
- You will see
Run the cell. You should see:
- Predict: breathing peak stronger than heartbeat peak.
- seed=437; sampling=10 Hz; duration=40 s
- breathing=0.25 Hz; heartbeat=1.20 Hz
- Why it matters
- Expected: source=synthetic displacement, not radar or patient data from this deterministic notebook step. Interpretation: These bands are useful teaching ranges, not universal diagnostic limits. Action: Predict the stronger peak before running the fixture. Boundary: this local fixture is not a live device, network, or site measurement.
Code for step 1import platform import pyodide print(f"Runtime: Python {platform.python_version()} / Pyodide {pyodide.__version__}") """Deterministic synthetic radar phase exercise; no RF or person measurements.""" import argparse import cmath import math import random SEED = 437 FS = 10.0 SECONDS = 40 WAVELENGTH_MM = 5.0 BREATH_HZ = 0.25 HEART_HZ = 1.2 def trace(motion=False): rng = random.Random(SEED) times = [i / FS for i in range(int(FS * SECONDS))] breath = [3.0 * math.sin(2 * math.pi * BREATH_HZ * t) for t in times] heart = [0.2 * math.sin(2 * math.pi * HEART_HZ * t) for t in times] artefact = [8.0 * math.sin(math.pi * (t - 18) / 2) if motion and 18 <= t < 20 else 0.0 for t in times] displacement = [b + h + a + rng.gauss(0, 0.03) for b, h, a in zip(breath, heart, artefact)] # Monostatic round trip: phase changes by 4π displacement / wavelength. phase = [4 * math.pi * x / WAVELENGTH_MM for x in displacement] return times, breath, heart, artefact, displacement, phase def band_peak(samples, low, high): # A transparent DFT over the known finite fixture, with the DC term removed. n = len(samples) centre = sum(samples) / n bins = [(k * FS / n, abs(sum((x - centre) * cmath.exp(-2j * math.pi * k * i / n) for i, x in enumerate(samples)))) for k in range(1, n // 2)] return max((row for row in bins if low <= row[0] <= high), key=lambda row: row[1]) def step_1(): return ['STEP 1 | prediction and fixture', 'Predict: breathing peak stronger than heartbeat peak.', f'seed={SEED}; sampling={FS:.0f} Hz; duration={SECONDS} s', 'breathing=0.25 Hz; heartbeat=1.20 Hz', 'source=synthetic displacement, not radar or patient data'] lines = step_1() assert 4 <= len(lines) <= 15 print("\n".join(lines))
Step 1 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Step 2
- Do
- In the JupyterLite notebook, run the Step 2 cell to generate a chest displacement and monostatic phase trace.
- You will see
Run the cell. You should see:
- x(t)=3 sin(2π·0.25t)+0.2 sin(2π·1.2t)+noise mm
- Δφ(t)=4πx(t)/λ for a monostatic round trip
- λ=5.0 mm; samples=400
- Why it matters
- Expected: first displacement=-0.013 mm; phase=-0.034 rad from this deterministic notebook step. Interpretation: Shorter wavelengths create more phase change for the same motion, but wrapping, noise, multipath, and poor target selection still matter. Action: Generate a chest displacement and monostatic phase trace. Boundary: this local fixture is not a live device, network, or site measurement.
Code for step 2def step_2(): t, b, h, a, x, phase = trace() return ['STEP 2 | chest displacement to phase', 'x(t)=3 sin(2π·0.25t)+0.2 sin(2π·1.2t)+noise mm', 'Δφ(t)=4πx(t)/λ for a monostatic round trip', f'λ={WAVELENGTH_MM:.1f} mm; samples={len(t)}', f'first displacement={x[0]:+.3f} mm; phase={phase[0]:+.3f} rad'] lines = step_2() assert 4 <= len(lines) <= 15 print("\n".join(lines))
Step 2 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Step 3
- Do
- In the JupyterLite notebook, run the Step 3 cell to compare the breathing and heartbeat components.
- You will see
Run the cell. You should see:
- breathing amplitude=3.00 mm
- heartbeat amplitude=0.20 mm
- combined range=-3.23 to +3.18 mm
- Why it matters
- Expected: Small heartbeat motion sits on a larger breathing wave. from this deterministic notebook step. Interpretation: Large motion spreads energy across frequencies and can shift phase by many cycles. Action: Compare the breathing and heartbeat components. Boundary: this local fixture is not a live device, network, or site measurement.
Code for step 3def step_3(): _, b, h, _, x, _ = trace() return ['STEP 3 | compare components', f'breathing amplitude={max(b):.2f} mm', f'heartbeat amplitude={max(h):.2f} mm', f'combined range={min(x):+.2f} to {max(x):+.2f} mm', 'Small heartbeat motion sits on a larger breathing wave.'] lines = step_3() assert 4 <= len(lines) <= 15 print("\n".join(lines))
Step 3 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Step 4
- Do
- In the JupyterLite notebook, run the Step 4 cell to search only the stated breathing and heartbeat bands.
- You will see
Run the cell. You should see:
- breathing search=0.1–0.5 Hz; heart search=0.8–2.0 Hz
- breathing peak=0.250 Hz = 15.0 cycles/min
- heartbeat peak=1.200 Hz = 72.0 cycles/min
- Why it matters
- Expected: peak-strength ratio=14.9:1 from this deterministic notebook step. Interpretation: A band-pass filter can separate slow breathing energy from faster heartbeat energy in a clean simulated trace. Action: Search only the stated breathing and heartbeat bands. Boundary: this local fixture is not a live device, network, or site measurement.
Code for step 4def step_4(): _, _, _, _, x, _ = trace() breath = band_peak(x, 0.1, 0.5) heart = band_peak(x, 0.8, 2.0) return ['STEP 4 | separate named bands', 'breathing search=0.1–0.5 Hz; heart search=0.8–2.0 Hz', f'breathing peak={breath[0]:.3f} Hz = {60*breath[0]:.1f} cycles/min', f'heartbeat peak={heart[0]:.3f} Hz = {60*heart[0]:.1f} cycles/min', f'peak-strength ratio={breath[1]/heart[1]:.1f}:1'] lines = step_4() assert 4 <= len(lines) <= 15 print("\n".join(lines))
Step 4 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Step 5
- Do
- In the JupyterLite notebook, run the Step 5 cell to inject a large movement and reject its window.
- You will see
Run the cell. You should see:
- Injected artefact lasts two seconds around t=18 s.
- contaminated samples=19 of 400
- max absolute displacement=4.85 mm
- Why it matters
- Expected: Decision=abstain on the motion window, not force a rate. from this deterministic notebook step. Interpretation: A robust pipeline first detects motion or low signal quality, then abstains before calculating rates. Action: Inject a large movement and reject its window. Boundary: this local fixture is not a live device, network, or site measurement.
Code for step 5def step_5(): _, _, _, artefact, x, _ = trace(True) contaminated = sum(abs(v) > 0.1 for v in artefact) return ['STEP 5 | reject gross motion', 'Injected artefact lasts two seconds around t=18 s.', f'contaminated samples={contaminated} of {len(x)}', f'max absolute displacement={max(abs(v) for v in x):.2f} mm', 'Decision=abstain on the motion window, not force a rate.'] lines = step_5() assert 4 <= len(lines) <= 15 print("\n".join(lines))
Step 5 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Step 6
- Do
- In the JupyterLite notebook, run the Step 6 cell to score the clean fixture and report accepted-window coverage.
- You will see
Run the cell. You should see:
- clean breathing error=0.0 cycles/min
- clean heart error=0.0 cycles/min
- one of four 10-second windows contains gross motion
- Why it matters
- Expected: accepted-window coverage=3/4; rejected-window rate=1/4 from this deterministic notebook step. Interpretation: It should retain the rejected window and reason instead of deleting inconvenient evidence. Action: Score the clean fixture and report accepted-window coverage. Boundary: this local fixture is not a live device, network, or site measurement.
Code for step 6def step_6(): clean = trace(False)[4] moving = trace(True)[4] return ['STEP 6 | score fixture and coverage', f'clean breathing error={abs(band_peak(clean,0.1,0.5)[0]-BREATH_HZ)*60:.1f} cycles/min', f'clean heart error={abs(band_peak(clean,0.8,2.0)[0]-HEART_HZ)*60:.1f} cycles/min', 'one of four 10-second windows contains gross motion', 'accepted-window coverage=3/4; rejected-window rate=1/4'] lines = step_6() assert 4 <= len(lines) <= 15 print("\n".join(lines))
Step 6 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Step 7
- Do
- In the JupyterLite notebook, run the Step 7 cell to write a bounded result card.
- You will see
Run the cell. You should see:
- method=synthetic monostatic phase plus bounded DFT bands
- breathing=15.0/min; heartbeat=72.0/min in clean fixture
- motion=one window rejected; coverage=75%
- Why it matters
- Expected: decision=no medical or unattended safety claim from this exercise from this deterministic notebook step. Interpretation: The lab in this chapter teaches phase and filtering with synthetic signals only. Action: Write a bounded result card. Boundary: this local fixture is not a live device, network, or site measurement.
Code for step 7def step_7(): return ['STEP 7 | RESULT CARD', 'method=synthetic monostatic phase plus bounded DFT bands', 'breathing=15.0/min; heartbeat=72.0/min in clean fixture', 'motion=one window rejected; coverage=75%', 'missing=RF hardware, people, multi-person geometry, clinical reference', 'decision=no medical or unattended safety claim from this exercise'] lines = step_7() assert 4 <= len(lines) <= 15 print("\n".join(lines))
Step 7 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture.
Chapter checks
These questions refer to the chapter’s examples. Use the return links to review their answers.
Why should a large-motion window be rejected before estimating breathing or heart rate?
Return to the chapter’s knowledge checkWhat does a 0.25 Hz peak prove here?
Return to the chapter’s knowledge check
Caution
Before you start
Read this before you start.
These generated fixtures prove calculations only. Reopen the prepared notebook if screens change; measured hardware, consent, and site evidence are required for a deployment claim.
Technical details
- Version tested
- Version tested: Python 3.12.7 / Pyodide 0.27.6 in JupyterLite 0.6.4; captureSource playwright:jupyterlite. Date: 2026-09-22.
- Fixture and seed
- Each notebook step runs with the record’s unchanged fixture, seed, and parameters.
https://iotclass.org/labs/presence-vital-sign-sensing.htmlReturn to Presence and Vital-Sign Sensing with Radar and Wi-Fi · Browse Labs