Digital Phonocardiogram

Human–machine interface · final build

Static snapshot. Numbers and examples were computed on 2026-10-05 UTC from the committed model and results. The live monitor runs on the Raspberry Pi.

How it works

What happens between a heart sound and the answer shown on the Monitor page, and the experiment this project was built for.

What this is

A phonocardiogram (PCG) is a recording of the sounds a heart makes. This instrument draws that sound as a waveform and asks a small machine-learning model whether a murmur (an extra whooshing sound between the main heart sounds) is present. It is an EECS 3641 course project and a research instrument for bench testing: not a medical device, no diagnostic claims, and no patient testing.

The question

How much murmur-detection accuracy is lost when the sound arrives through a real acquisition chain instead of straight from a dataset file, and where in the chain does the loss come from? The project does not try to beat published accuracy.

The system, end to end

Follow the arrows from left to right, lane by lane. Two routes lead to the same classifier. In the injected (control) route the dataset file goes straight into the software. In the re-acquired route the same file is played as sound, picked up again by a sensor, passed through the analog electronics and digitised. Hover, focus or tap any block to read what it does.

Test fixture Dataset file CirCor .wav Loudspeaker 3D-printedcoupler Siliconeskin layer Front end Microphone the sensor Signalconditioning ADC analog to digital Raspberry Pi Acquisition &5 s windows Band-limit &normalise MFCCfeatures Logisticregression Web HMI Monitor page

Scroll sideways to see the whole diagram.

Figure 1. The system as designed. Test fixture (purple), front end (blue) and Raspberry Pi (teal). The re-acquired route needs the hardware, which is still being built; the injected route runs today. Hardware not connected

The experiment

The same recordings, the same model, the same features and the same decision threshold are scored in each condition. Only the way the sound reaches the classifier changes, so a difference in the results is caused by what the sound passed through. The threshold is fixed from the training data and is never adjusted for a condition.

Every condition is scored on the bench set: one recording each from a balanced subset of the held-out children (children the model never trained on), with equal numbers of children with and without a murmur. Not every held-out child is in it; the counts are shown below.

Injected (control)

Checking results

The dataset file is read straight from disk into the feature code. Nothing can change it on the way, so this is the baseline. Any difference from it is caused by what the sound passed through.

Re-acquired

NOT MEASURED

The same file played through the loudspeaker, coupler and silicone, picked up by the microphone and digitised. This is the project's headline result: how much of the baseline accuracy survives the real chain. It needs the hardware.

Simulated bandpass

Checking results

A software model of the 20–600 Hz bandpass filter applied to the same files. It shows how much of any loss the filter's response alone could explain. It is a model, not a measurement, and never a re-acquired result.

What is measured

Accuracy
The share of recordings the classifier got right.
Sensitivity
Of the recordings with a murmur, the share it flagged as murmur present.
Specificity
Of the recordings without a murmur, the share it cleared as absent.
AUC (area under the ROC curve)
How well the model's probability ranks murmur recordings above normal ones, whatever threshold is used. 1 is perfect and 0.5 is chance.

To tell whether a change between two conditions is real and not luck, the files are paired and each class is tested separately with a per-class McNemar test, which looks only at the files where the two conditions disagree.

Injected (control) on the bench set

Accuracy

—

—

 

Sensitivity

—

—

Specificity

—

—

AUC

—

1 is perfect, 0.5 is chance

Threshold

—

fixed from training data

Loading the results…

The full results, with confusion matrices and the simulated comparison, are on the Data & AI page.

The software layers

The code is split into layers that talk through small, fixed interfaces. That is what lets the data source change from a file to live hardware without touching the rest. Hover, focus or tap a block to see which files it is.

Analysis (Python) Sources swappable Features 60 numbers Model classifier Web server (Python) Calls pcg and sends the results as JSON. No signal maths here. JSON API Flask Browser (JavaScript) plot.js never calls the server and has not changed since the midterm. hmi.js controller plot.js renderer JSON over HTTP

Scroll sideways to see the whole diagram.

Figure 2. The software layers. Data flows from the sources, through the features and the model, to the server and on to the browser.

A swappable source

Review mode reads a file. Live mode reads blocks of samples from a BlockSource. Today FileReplaySource replays .wav files in real time and no hardware is attached. A hardware capture source will implement the same interface, so the server, the page and the classifier do not change.

One feature path

The same feature code serves training, both test conditions and the live view. That is what keeps the comparison fair: the only thing that differs between conditions is the audio that goes in.

A renderer that did not change

plot.js draws the waveform and has not changed since the midterm. The display built for the example waveform now shows real recordings and the live replay.

Where to look in the code