-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.py
30 lines (23 loc) · 1.01 KB
/
data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import os
import numpy as np
class Data:
def __init__(self, data_dir, data_folder):
self.data_path = os.path.join(data_dir, data_folder)
self.data_dirs = os.listdir(self.data_path)
self.data_dirs.remove("LICENSE")
self.data_dirs.remove("README.md")
self.user_id = None
self.user_path = None
self.user_info = None
self.sample_id = None
def describe(self, user_id):
self.user_id = user_id
self.user_path = os.path.join(self.data_path, "user{}".format(self.user_id))
self.user_info = os.listdir(self.user_path)
print("_______________________________________")
print("Description:\n user{} has {}, ecg samples {}".format(str(self.user_id), len(self.user_info), self.user_info))
return
def load_raw(self, user_id, sample_id):
self.sample_id = sample_id
data = np.load(os.path.join(self.data_path, "user{}".format(self.user_id), self.user_info[self.sample_id]))
return data