|
|
|
import numpy as np |
|
import pybdf |
|
from biosppy.signals import ecg |
|
from pyVHR.datasets.dataset import Dataset |
|
from pyVHR.signals.ecg import ECGsignal |
|
|
|
class MAHNOB(Dataset): |
|
""" |
|
Mahnob dataset structure: |
|
----------------- |
|
datasetDIR/ |
|
| |
|
||-- vidDIR1/ |
|
| |-- videoFile.avi |
|
| |-- physioFile.bdf |
|
|... |
|
|... |
|
""" |
|
name = 'MAHNOB' |
|
signalGT = 'ECG' |
|
numLevels = 2 |
|
numSubjects = 40 |
|
video_EXT = 'avi' |
|
frameRate = 20 |
|
VIDEO_SUBSTRING = 'Section' |
|
SIG_EXT = 'bdf' |
|
SIG_SUBSTRING = 'emotion' |
|
SIG_SampleRate = 256 |
|
|
|
def readSigfile(self, filename): |
|
""" Load ECG signal. |
|
Return a 2-dim signal (t, bmp(t)) |
|
""" |
|
bdfRec = pybdf.bdfRecording(filename) |
|
rec = bdfRec.getData(channels=[33]) |
|
self.SIG_SampleRate = bdfRec.sampRate[33] |
|
data = np.array(rec['data'][0])[rec['eventTable']['idx'][2]:] |
|
return ECGsignal(data, self.SIG_SampleRate) |
|
|
|
|