-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresults_position_validation.py
More file actions
98 lines (66 loc) · 2.3 KB
/
results_position_validation.py
File metadata and controls
98 lines (66 loc) · 2.3 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
"""
Usage:
results_position_validation.py <results_directory>
"""
import os
from os.path import join
import sys
from position_validate import results_file
import pandas as pd
import inspect
import numpy as np
import matplotlib.pyplot as plt
import pdb
from configurations import col_names, data_dir, validation_results_dir, data_file
import configurations
# do linear regression
def plotWithBestFitLine(xL, yL, outputFileNameS):
xL = np.array(xL)
yL = np.array(yL)
m, b = np.polyfit(xL, yL, 1)
# plotting both scatter plot and linear regression
plt.scatter(xL, yL)
plt.plot(xL, m*xL+b, '-r')
plt.xlabel("generated x-coordinates")
plt.ylabel("manually inspected x-coordinates ")
plt.savefig(outputFileNameS)
plt.show()
return m, b
if __name__ == "__main__":
print __name__
import docopt
print 'dflkj'
d = docopt.docopt(__doc__)
ee = execfile
poing = inspect.getabsfile(inspect.currentframe())
results_dir = join(configurations.output_dir, d['<results_directory>'])
file_path = os.path.join(results_dir, validation_results_dir, results_file)
if not os.path.exists(file_path):
print "run your analysis first !"
print file_path
curated = pd.read_csv(file_path, names=col_names[:4])
generatedFilePathS = os.path.join(data_file)
generated = pd.read_csv(generatedFilePathS, names=col_names)
xL = []
curated_x = []
generated_x = []
curated_y = []
generated_y = []
for row in curated.values:
frame_number = row[0] # getting the frame number in the curated row
fly_number = row[1] # getting the fly string in the curated row
# getting the appropriate match in the values.
values = generated[generated.frame_number == frame_number]
for i in values.values:
if i[1] == fly_number:
row_in_generated = i
break
if abs(row_in_generated[2] - row[2]) > 5:
print row_in_generated
print row
generated_x.append(row_in_generated[2])
curated_x.append(row[2])
generated_y.append(row_in_generated[3])
curated_y.append(row[3])
m, b = plotWithBestFitLine(generated_x, curated_x, "xlinreg.png")
m, b = plotWithBestFitLine(generated_y, curated_y, "ylinreg.png")