-
Notifications
You must be signed in to change notification settings - Fork 0
/
microannotate_right.py
executable file
·86 lines (63 loc) · 2.14 KB
/
microannotate_right.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
__author__ = 'ArseneLupin'
# this program is for re-annotate the falls
# 2, 6, 10, 11, 12, 13 --> fall annotation
# annotation = data[21]
import csv
import searchmax
from collections import deque, namedtuple
import reannotright
import itertools
import source_var
FALL_FORWARD = 2
FALL_BACKWARD = 6
FALL_LEFT = 10
FALL_RIGHT = 11
FALL_BLIND_FORWARD = 12
FALL_BLIND_BACKWARD = 13
FALL_SET = set([FALL_FORWARD,
FALL_BACKWARD,
FALL_LEFT,
FALL_RIGHT,
FALL_BLIND_FORWARD,
FALL_BLIND_BACKWARD])
def micro_annotate_search(sourceFile):
flag = False
counter = 0
tempData = []
output = []
quemican = deque
ARRAY_TUPLED = namedtuple('ARRAY_TUPLED', 'AXC AYC AZC GXC GYC GZC AVMC GVMC'
' AXT AYT AZT GXT GYT GZT AVMT GVMT ANNOT')
print('start to re-annotate')
with open(sourceFile) as objectFile:
for line in objectFile:
dataread = line.split()
ori_data = [float(x) for x in dataread[:len(dataread)]]
data = ARRAY_TUPLED(*ori_data)
if data.ANNOT in FALL_SET: #change this for OJ's data
tempData.append(data)
if not flag:
flag = True
elif flag and (data.ANNOT not in FALL_SET) :
micanDat = searchmax.micAn(tempData) #search for maximum value
for x in range(len(micanDat)):
output.append(micanDat[x])
flag = False
tempData = []
output.append(reannotright.reanotright(data))
else:
saveData = reannotright.reanotright(data)
output.append(saveData)
#write_csv(destFile, output)
return output
def micro_annotate(sourceFile, dest_file):
outF = open(dest_file, "w")
csvWriter = csv.writer(outF, delimiter='\t')
output = micro_annotate_search(sourceFile)
for n in range(len(output)):
filout = output[n]
ff1 = filout[0] #chest data
ff2 = filout[1] #thigh data
finout = ff1 + ff2
csvWriter.writerow(finout)
outF.close()