-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.py
53 lines (42 loc) · 1.16 KB
/
util.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
import numpy as np
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
options = {0 : 'neus',
1 : 'nek',
2 : 'l-schouder',
3 : 'l-elleboog',
4 : 'l-pols',
5 : 'r-schouder',
6 : 'r-elleboog',
7 : 'r-pols',
8 : 'l-heup',
9 : 'l-knie',
10: 'l-enkel',
11: 'r-heup',
12: 'r-knie',
13: 'r-enkel',
14: 'l-oog',
15: 'r-oog',
16: 'l-oor',
17: 'r-oor',
}
def getBodyPartByIndex(index):
if(index <=17 and index >=0):
return options[index]
return 'no-bodypart (wrong index)'
def corr2_coeff(A,B):
# Rowwise mean of input arrays & subtract from input arrays themeselves
A_mA = A - A.mean(1)[:,None]
B_mB = B - B.mean(1)[:,None]
# Sum of squares across rows
ssA = (A_mA**2).sum(1);
ssB = (B_mB**2).sum(1);
# Finally get corr coeff
return np.dot(A_mA,B_mB.T)/np.sqrt(np.dot(ssA[:,None],ssB[None]))