|
import csv |
|
import numpy as np |
|
from pyVHR.datasets.dataset import Dataset |
|
from pyVHR.signals.bvp import BVPsignal |
|
|
|
class UBFC1(Dataset): |
|
""" |
|
UBFC dataset structure: |
|
----------------- |
|
datasetDIR/ |
|
| |-- SubjDIR1/ |
|
| |-- vid.avi |
|
|... |
|
| |-- SubjDIRM/ |
|
| |-- vid.avi |
|
""" |
|
name = 'UBFC1' |
|
signalGT = 'BVP' |
|
numLevels = 2 |
|
numSubjects = 8 |
|
video_EXT = 'avi' |
|
frameRate = 30 |
|
VIDEO_SUBSTRING = '' |
|
SIG_EXT = 'xmp' |
|
SIG_SUBSTRING = '' |
|
SIG_SampleRate = 62 |
|
skinThresh = [40,60] |
|
|
|
def readSigfile(self, filename): |
|
""" Load BVP signal. |
|
Must return a 1-dim (row array) signal |
|
""" |
|
gtTrace = [] |
|
gtTime = [] |
|
gtHR = [] |
|
with open(filename, 'r') as csvfile: |
|
xmp = csv.reader(csvfile) |
|
for row in xmp: |
|
gtTrace.append(float(row[3])) |
|
gtTime.append(float(row[0])/1000.) |
|
gtHR.append(float(row[1])) |
|
|
|
data = np.array(gtTrace) |
|
time = np.array(gtTime) |
|
hr = np.array(gtHR) |
|
self.SIG_SampleRate = np.round(1/np.mean(np.diff(time))) |
|
|
|
'''import matplotlib.pyplot as plt |
|
plt.plot(hr) |
|
plt.show()''' |
|
|
|
return BVPsignal(data, self.SIG_SampleRate) |
|
|