Weights for the reproduction of PPGNet Experiments

Prediction for EDF file

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)

Prediction from custom Signal

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)

Prediction from registered Loader

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)

Plot Hypnogram

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()

assets/hypnogram.png

Original Study

Kotzen, Kevin, et al. "SleepPPG-Net: A deep learning algorithm for robust sleep staging from continuous photoplethysmography." IEEE Journal of Biomedical and Health Informatics 27.2 (2022): 924-932.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support