Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Active Movement
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
that-team
Active Movement
Commits
985cf7fa
Commit
985cf7fa
authored
Feb 23, 2020
by
dy1g18
Browse files
Options
Downloads
Patches
Plain Diff
python file to extrapolate data
parent
30e85c01
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
extrapolate.py
+65
-0
65 additions, 0 deletions
extrapolate.py
with
65 additions
and
0 deletions
extrapolate.py
0 → 100644
+
65
−
0
View file @
985cf7fa
import
matplotlib.pyplot
as
plt
from
matplotlib.pyplot
import
figure
import
numpy
as
np
import
os
import
glob
accuracy
=
glob
.
glob
(
'
C:
\\
Users
\\
ASUS-CORE-i7
\\
Desktop
\\
data
\\
accuracy
\\
*.txt
'
)
motion
=
glob
.
glob
(
'
C:
\\
Users
\\
ASUS-CORE-i7
\\
Desktop
\\
data
\\
motion
\\
*.txt
'
)
xs
,
ys
,
heads
,
arms
,
yss
=
[],[],[],[],[]
fig
,
axs
=
plt
.
subplots
(
2
)
def
read_accuracy
():
for
x
in
accuracy
:
if
not
os
.
path
.
isfile
(
x
):
print
(
"
File does not exist
"
)
else
:
with
open
(
x
)
as
f
:
content
=
f
.
readlines
()
arm_av
=
[
x
.
split
()[
0
]
for
x
in
content
]
neck_av
=
[
x
.
split
()[
1
]
for
x
in
content
]
average
=
sum
(
map
(
int
,
arm_av
))
/
len
(
arm_av
)
ys
.
append
(
average
)
average
=
sum
(
map
(
int
,
neck_av
))
/
len
(
neck_av
)
yss
.
append
(
average
)
xs
.
append
(
x
.
split
(
"
_
"
)[
1
][
0
:
-
4
])
def
read_motion
():
for
x
in
motion
:
if
not
os
.
path
.
isfile
(
x
):
print
(
"
File does not exist
"
)
else
:
with
open
(
x
)
as
f
:
content
=
f
.
readlines
()
heads
.
append
(
content
[
0
].
split
()[
0
])
arms
.
append
(
content
[
0
].
split
()[
1
])
def
extrapolate
(
x1
,
y
,
y1
,
y2
,
x2
):
return
x1
+
((
y
-
y1
)
/
(
y2
-
y1
)
*
(
x2
-
x1
))
def
create_accuracy_graph
():
read_accuracy
()
arms_xs
=
[
1
,
extrapolate
(
1
,
80
,
int
(
ys
[
0
]),
int
(
ys
[
-
1
]),
int
(
xs
[
-
1
]))]
neck_xs
=
[
1
,
extrapolate
(
1
,
80
,
int
(
yss
[
0
]),
int
(
ys
[
-
1
]),
int
(
xs
[
-
1
]))]
axs
[
0
].
plot
(
list
(
map
(
int
,
arms_xs
)),
[
int
(
ys
[
0
]),
80
],
color
=
'
g
'
,
label
=
'
Acc of arms
'
)
axs
[
0
].
plot
(
list
(
map
(
int
,
neck_xs
)),
[
int
(
yss
[
0
]),
80
],
color
=
'
r
'
,
label
=
'
Acc of neck
'
)
axs
[
0
].
set_xlabel
(
'
Sessions
'
)
axs
[
0
].
set_ylabel
(
'
Accuracy of Motion (%)
'
)
axs
[
0
].
set_title
(
'
Accuracy of limb movement over time
'
)
axs
[
0
].
legend
()
def
create_rom_graph
():
read_motion
()
arms_xs
=
[
1
,
extrapolate
(
1
,
160
,
int
(
arms
[
0
]),
int
(
arms
[
-
1
]),
int
(
xs
[
-
1
]))]
neck_xs
=
[
1
,
extrapolate
(
1
,
75
,
int
(
heads
[
0
]),
int
(
heads
[
-
1
]),
int
(
xs
[
-
1
]))]
axs
[
1
].
plot
(
list
(
map
(
int
,
arms_xs
)),
[
int
(
arms
[
0
]),
160
],
color
=
'
g
'
,
label
=
'
Arm ROM
'
)
axs
[
1
].
plot
(
list
(
map
(
int
,
neck_xs
)),
[
int
(
heads
[
0
]),
75
],
color
=
'
r
'
,
label
=
'
Neck ROM
'
)
axs
[
1
].
legend
()
axs
[
1
].
set_xlabel
(
'
Sessions
'
)
axs
[
1
].
set_ylabel
(
'
Degrees
'
)
axs
[
1
].
set_title
(
'
Range Of Motion
'
)
create_accuracy_graph
()
create_rom_graph
()
plt
.
show
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment