用原生 HTML、CSS 和 JavaScript 建構互動式生物醫學工程實驗室
I built interactive biomedical engineering labs with plain HTML, CSS, and JavaScript
Inside MedTech 以原生 HTML、CSS 和 JavaScript 建構互動式生物醫學工程實驗室,首個模組透過 5 個實驗和 3 篇參考文章講解脈搏血氧儀。網站免費、無需註冊,內容在瀏覽器中運行;示範採用合成數據和簡化模型,僅供教育用途,未經臨牀驗證,也不是醫療器材。
I've been building a free site called Inside MedTech that teaches biomedical engineering through interactive labs on real medical devices. The first module is the pulse oximeter, the clip they put on your fingertip. It has five labs and three reference articles, and everything runs in the browser with no sign-up.
The site: https://johnjones8.github.io/Inside-MedTech/
It's an early beta. I'd love feedback on the science, the clarity, and the code. Feedback form: https://forms.gle/gzAK84ry24nNGTiN8
What it teaches
A pulse oximeter shines red and infrared light through your finger. Oxygen-rich and oxygen-poor blood absorb those two colors differently, and each heartbeat makes a tiny wiggle in the light that reaches the sensor. The five labs follow that measurement step by step:
- Light and tissue: how hemoglobin absorbs red and infrared light
- A PPG signal explorer: heart rate, pulse size, and baseline
- Noise and signal quality: add movement, drift, and light flicker, and watch the signal-to-noise ratio fall
- Filtering and peak detection: smooth the signal, find the beats, and see what filtering costs
- Calibration: how a ratio of the two signals becomes an oxygen estimate (educational only, not clinically validated)
Everything uses synthetic data and simplified models. It is not a medical device.
Why no framework
I wanted it to be free to host and easy to keep alive, so it is plain HTML, CSS, and JavaScript files on GitHub Pages. There is no build step and no dependencies. Opening a file in a browser is the whole development setup. A handful of shared files do the work:
-
signal.jsgenerates the pulse signal -
noise.jsadds noise to it -
site.jsdraws the header and footer on every page -
labs.jsis a single list of the labs that the library page, the module page, and the counts all read from
A pulse signal from two bumps
The synthetic pulse is a sum of two Gaussian curves per heartbeat: a sharp systolic peak and a smaller bump after it. It is a classic way to get a believable shape without recorded data:
const g = (t, c, w) => Math.exp(-(((t - c) / w) ** 2));
// one beat: phase p runs from 0 to 1
const ppg = t => {
const p = t % 1;
return g(p, 0.22, 0.08) + 0.4 * g(p, 0.55, 0.1);
};
The lab then scales it by pulse size and adds a steady baseline, which are the AC and DC parts of the signal.
Noise you can repeat
The noise lab uses a seeded random number generator, so the same slider settings always give the same noise. That makes the examples reproducible and the numbers on the page checkable. One of the noise sources is 120 Hz light flicker. Sampled at 100 Hz, it shows up as a 20 Hz ripple, which is a nice, concrete demonstration of aliasing.
Charts drawn with plain SVG
The charts are SVG strings built in JavaScript and redrawn with a ResizeObserver, so they fit any screen width. Labels were the hard part. I wrote a small Playwright script that measures the bounding box of every SVG text element and fails if two overlap or one is clipped, and I run it on every page at desktop and phone width.
How I built it
I'm still learning to program, but I'm eager to start some projects. I built this with an AI assistant (Claude) writing the code while I directed the design, the content, and what to fix. I'm saying that openly because I think it matters for a project where accuracy counts.
What I'd like help with
- Is anything scientifically wrong or misleading? The content has not yet been reviewed by an expert.
- What was confusing, or did not work on your device?
- Which device should the next module cover: ECG, prosthetics, biosensors, or imaging?
Thanks for reading, and for any feedback. Honest criticism is the most useful thing you can give me.
來源:DEV Community · dev.to