This repository was archived by the owner on Jul 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathConsts.py
More file actions
134 lines (111 loc) · 3.63 KB
/
Consts.py
File metadata and controls
134 lines (111 loc) · 3.63 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
"""
This file is part of BeSafeBox Android application.
Copyright (C) 2019 Tomáš Repčík
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
from typing import Optional
class Consts:
"""
Holds constants, which are used as the keys for accessing different dictionaries
"""
# types of the motions in which we are interested
# they are stored in name of the folder
activity_types = {"SIT", "LAY", "FALL", "WALK", "JUMP", "STAIRS"}
activity_valid = ["SIT", "LAY", "WALK", "FALL"]
activity_legend = {"Sit", "Lay", "Walk", "Fall"}
# placement of the phone in EN, CZ, SK
hold = [
["Pocket", "Kapsa", "Vrecko"],
["Handbag", "Kabelka"],
["Backpack", "Batoh"],
["Holder", "Držák", "Držiak"],
["Plain surface", "Volná plocha", "Voľná plocha"],
]
# activities of the person in EN, CZ, SK
environment = [
["Walk", "Chůze", "Chôdza"],
["Run", "Běh", "Beh"],
["Bike", "Kolo", "Bicykel"],
["Public transport", "MHD"],
["Train", "Vlak"],
["Car / Bus", "Auto / autobus"],
]
# constants for the sensor and list of them
ACC = "ACC"
ACG = "ACG"
AGG = "AGG"
GYRO = "GYRO"
MAGNET = "MAGNET"
ROTATION = "ROTATION"
PROXI = "PROXI"
sensor_types = {ACC, ACG, AGG, GYRO, MAGNET, ROTATION, PROXI}
# modified data
TIME_SECONDS = "TIME_SECONDS"
MAGNITUDE = "MAGNITUDE"
# list of all calculated parameters
parameters_names = [
"average",
"deviation",
"variance",
"mobility",
"complexity",
"average_tkeo",
"output",
"entropy",
"waveform_length",
"crest_factor",
"change_in_angle",
"change_in_angle_cos",
"angle_deviation",
"free fall index",
"min_max",
"ratio_3g",
"kurtosis",
"skewness",
"1g_crosses",
]
binary_categories = {0: "Other activity", 1: "Fall"}
multiple_categories = {0: "Sit", 1: "Lay", 2: "Walk", 3: "Fall"}
def determine_activity_type(path: str) -> Optional[str]:
"""
finds activity of the folder
:param path: name of the folder
:return: measured activity string
"""
for t in Consts.activity_types:
if t in path:
return t
return None
def determine_sensor_type(path: str) -> Optional[str]:
"""
Determines type of the file - sensor type
:param path: path to file
:return: type of the sensor
"""
for t in Consts.sensor_types:
if t in path:
return t
return None
def string_activity_to_number(y: str) -> Optional[int]:
"""
Activity is turned to integer for machine learning purposes
:param y: string of the activity
:return: integer of the activity
"""
if y in Consts.activity_valid:
return Consts.activity_valid.index(y)
else:
return None
def number_to_string_activity_binary(y: int) -> str:
return Consts.binary_categories[y]
def number_to_string_activity_multiple(y: int) -> str:
return Consts.multiple_categories[y]