RhythmNet (Puls Malysha): fetal heart rhythm in 8-second phone recordings
Research model. Not a medical device. It is not used for any decision in the Puls Malysha app; it was only evaluated as a "second opinion" next to the app's classical detector. Do not use it to judge anyone's health.
What it is
A small convolutional network (26,019 parameters). It reads 8 s of belly sound at 2 kHz and outputs:
- fetal head: a softmax over 31 autocorrelation lags (30…60 frames at 100 Hz, i.e. 200…100 bpm) plus one "no fetal rhythm" class;
- maternal head (experimental): logits over lags 40…120 (150…50 bpm). It does not generalize (see below), do not use it.
The architecture copies the project's classical detector, but the parts are learned. A learned filter bank (101 taps)
feeds |·| and average pooling into 100 Hz envelopes in 32 bands, with log compression. Two temporal convolutions
refine them. A normalized autocorrelation is taken at lags of 0.3–1.2 s, then convolutions over lags and bands
produce the logits. The code is in model.py.
Training data
- PhysioNet IIScFHSDB and SUFHSDB (both ODC-By 1.0) and the Fetal PCG Database: stethoscope recordings of fetal heart sounds.
- Labels: windows where the project's classical detector reports a stable rhythm (no human labels). The labels are circular, so the network learns to imitate the detector.
- Negatives: SUFHSDB maternal heart recordings and empty phone recordings (adult chests, a table).
- Phone sessions: 11 sessions from one pregnancy at about 40 weeks, two Xiaomi phones, phone bottom edge on the belly. These recordings are not published. A stethoscope→phone spectral equalizer and tempo augmentation are applied.
- Validation subjects are listed in
config.json.
Evaluation (summary)
- Leave-one-session-out on phone sessions: close to the classical detector on 3 of 5 sessions. On its own it gives false windows on adult chests, on some recordings without a baby, and on a headphone echo loop.
- As a gated second opinion: a window counts only where the detector's accumulated rhythm spectrum already has a peak of at least 3 dB at the same rate ±5 bpm. This adds about 4% more "stable" windows, with 0 false windows on all negative recordings. It is not integrated into the app.
- Maternal head: 88–95% on sessions it has seen, 3–12% on unseen ones. With one mother it memorizes recordings.
- There is no clinical validation and no human-labelled ground truth for the phone data. The app's classical detector was checked independently on FetalCareDB (Mendeley Data): when it reports "stable", the rate is within ±8 bpm 93–96% of the time.
How to use
import json, numpy as np, torch
from safetensors.torch import load_file
from model import RhythmNet, F_LO
cfg = json.load(open("config.json"))
net = RhythmNet(**cfg["init"])
net.load_state_dict(load_file("model.safetensors"))
net.eval()
x = ... # 8 s of mono audio at 2000 Hz, float32 numpy array
w = x / (np.sqrt(np.mean(x ** 2)) + 1e-9) # the window is divided by its RMS
with torch.no_grad():
p = torch.softmax(net(torch.from_numpy(w[None].astype(np.float32))), dim=1)[0].numpy()
k = int(np.argmax(p[:-1]))
print("p(fetal rhythm) =", 1 - p[-1], " rate ≈", 6000.0 / (F_LO + k), "bpm")
License
- Weights and this card: CC BY-NC-SA 4.0, no commercial use.
model.py: PolyForm Noncommercial 1.0.0, like the rest of the project code.
The project is altruistic: the app is free, and nobody pays or gets paid.
Links
- Project, app and full training code: https://github.com/Annoyt/puls-malysha (
nn/) - Project site: https://annoyt.github.io/puls-malysha/
Кратко по-русски. Маленькая исследовательская сеть (26 тыс. параметров), которая по 8 с звука живота с телефона оценивает ритм сердца малыша (100–200 уд/мин) или «не слышно». Учились на открытых записях PhysioNet и на сеансах одной семьи; метки взяты у классического детектора проекта. В приложении не используется. Не медицинское изделие. Лицензия CC BY-NC-SA 4.0, без коммерческого использования.