-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsignal_augmentation.py
69 lines (55 loc) · 1.88 KB
/
signal_augmentation.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from Handler import Manipulation, Cleansing
class Augmentation:
def __init__(self, input_sig, input_fs, target_fs, cfg):
self.input_sig = input_sig
self.input_fs = input_fs
self.target_fs = target_fs
self.cfg = cfg
def augment1(self):
"""
Down-sample and normalize
:return:
"""
aug1 = Manipulation(self.input_sig).down_sample(
from_fs=self.input_fs, to_fs=self.target_fs
)
aug1 = Manipulation(aug1).normalize(self.cfg.option.normalize)
return aug1
def augment2(self):
"""
Detrend, down-sample and normalize
:return:
"""
aug2 = Cleansing(self.input_sig, fs=self.input_fs, cpu=True).detrend(
mode=self.cfg.option.detrend
)
aug2 = Manipulation(aug2).down_sample(
from_fs=self.input_fs, to_fs=self.target_fs
)
aug2 = Manipulation(aug2).normalize(self.cfg.option.normalize)
return aug2
def augment3(self):
"""
Denoise, down-sample and normalize
:return:
"""
aug3 = Cleansing(self.input_sig).noise_removal(self.cfg.option.denoise)
aug3 = Manipulation(aug3).down_sample(
from_fs=self.input_fs, to_fs=self.target_fs
)
aug3 = Manipulation(aug3).normalize(self.cfg.option.normalize)
return aug3
def augment4(self):
"""
# TODO: Verification needed through visualization
Flip baseline of original signal, down-sample and norma lize
:return:
"""
aug4 = Cleansing(self.input_sig).baseline_correction(
fs=self.input_fs, flip_baseline=True
)
aug4 = Manipulation(aug4).down_sample(
from_fs=self.input_fs, to_fs=self.target_fs
)
aug4 = Manipulation(aug4).normalize(self.cfg.option.normalize)
return aug4