Downloads · 30 days
0
sleep-is-all-you-need/SPPPPG-Net
SPPPPG-Net is a machine learning model from sleep-is-all-you-need. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as fair-noncommercial-research-license.
Downloads · 30 days
0
Access
Public
Updated Feb 6, 2026
Repo size
9.3 MB
Likes
0
Public
Click a slice to open those files.
Other9.2 MB · 98%
From the Hugging Face model README
from SleePyPhases import SleePyPhases
project = SleePyPhases.create(plugins=["pyPhasesRecordloaderMESA", "SPPPPGNet"])
# directly predict from file
# you can map any channelname to "Pleth", which is the only required channel for ppgnet
# project.setConfig("predict.channelMapping", {"myChannel": "Pleth"})
# this will use the default recordloader, which is pyPhasesRecordloaderMESA, where the signals are stored in edf files
fileName = "export/Example.edf"
prediction = project.predictFromFile(fileName)
import pyedflib
from SleePyPhases import SleePyPhases
from pyPhasesRecordloader import RecordSignal, Signal
project = SleePyPhases.create(plugins=["pyPhasesRecordloaderMESA", "SPPPPGNet"])
# load edf
with pyedflib.EdfReader(fileName) as edf:
n = edf.signals_in_file
signal_labels = edf.getSignalLabels()
print(signal_labels)
# load pleth signal
fs = edf.getSampleFrequency(signal_labels.index("Pleth"))
pleth_signal = edf.readSignal(signal_labels.index("Pleth"))
rs = RecordSignal()
rs.addSignal(Signal("Pleth", pleth_signal, fs, typeStr="ppg")) # type is required for correct preprocessing
prediction = project.predictRecordSignal(rs)
from SleePyPhases import SleePyPhases
from pyPhasesRecordloader import RecordLoader
project = SleePyPhases.create(plugins=["pyPhasesRecordloaderMESA", "SPPPPGNet"])
project.setConfig("mesa-path", "/datasets/mesa")
project.setConfig("useLoader", "mesa") # reload the recordloader
rl = RecordLoader.get()
recordSignal, events = rl.loadRecord("mesa-sleep-0001")
prediction = project.predictRecordSignal(recordSignal)
from matplotlib import pyplot as plt
import numpy as np
hypno = prediction[0]
T = hypno.shape[0]
time = np.arange(T)
labels = ['Wake', 'REM', 'Light', 'Deep']
colors = ['#f94144', '#f3722c', '#90dbf4', '#577590']
plt.figure(figsize=(12, 4))
plt.stackplot(
time,
hypno.T,
labels=labels,
colors=colors
)
plt.ylim(0, 1)
plt.xlim(0, T - 1)
plt.ylabel('Probability')
plt.xlabel('Time')
plt.title('Hypnodensity Plot')
plt.legend(loc='upper right', ncol=4)
plt.tight_layout()
plt.show()
