Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
HearingTest
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
Ed Rogers
HearingTest
Commits
065caee9
Commit
065caee9
authored
Apr 4, 2018
by
Ed Rogers
Browse files
Options
Downloads
Patches
Plain Diff
Add color change on freq finished
parent
44512c43
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
HearingTest.py
+4
-1
4 additions, 1 deletion
HearingTest.py
HearingTestGUI.py
+18
-2
18 additions, 2 deletions
HearingTestGUI.py
with
22 additions
and
3 deletions
HearingTest.py
+
4
−
1
View file @
065caee9
...
...
@@ -61,11 +61,14 @@ class HearingTest:
next_sleep_time
=
random
.
uniform
(
self
.
max_response_time
*
1.2
,
self
.
max_response_time
*
3
)
self
.
sounds
.
append
(
SoundRecord
(
freq
,
volume
,
played_time
))
test_finished
=
np
.
all
(
self
.
upper_bounds
-
self
.
lower_bounds
<
self
.
get_block_size
()
*
1.2
)
test_finished
=
np
.
all
(
self
.
finished_freqs
()
)
self
.
check_for_not_heard
(
played_time
)
return
test_finished
,
freq
,
volume
,
played_time
,
next_sleep_time
def
finished_freqs
(
self
):
return
self
.
upper_bounds
-
self
.
lower_bounds
<
self
.
get_block_size
()
*
1.2
def
check_for_not_heard
(
self
,
event_time
):
for
sound
in
reversed
(
self
.
sounds
):
delay
=
event_time
-
sound
.
time
...
...
This diff is collapsed.
Click to expand it.
HearingTestGUI.py
+
18
−
2
View file @
065caee9
...
...
@@ -37,6 +37,9 @@ from matplotlib.figure import Figure
class
HearingMplCanvas
(
FigureCanvas
):
"""
Ultimately, this is a QWidget (as well as a FigureCanvasAgg, etc.).
"""
false_color
=
np
.
array
([
0.
,
1.
,
0.
])
true_color
=
np
.
array
([
0.
,
0.
,
1.
])
def
__init__
(
self
,
parent
=
None
,
width
=
5
,
height
=
4
,
dpi
=
100
):
self
.
baseline
=
-
0.1
fig
=
Figure
(
figsize
=
(
width
,
height
),
dpi
=
dpi
)
...
...
@@ -58,8 +61,10 @@ class HearingMplCanvas(FigureCanvas):
def
plot_result
(
self
,
result
:
HearingTest
):
inds
=
np
.
arange
(
0
,
result
.
freqs
.
size
)
self
.
axes
.
set_facecolor
(
'
k
'
)
self
.
ul_bar
=
self
.
axes
.
bar
(
inds
,
result
.
upper_bounds
-
self
.
baseline
,
color
=
(
0
,
0.5
,
0
),
bottom
=
self
.
baseline
)
self
.
ll_bar
=
self
.
axes
.
bar
(
inds
,
result
.
lower_bounds
-
self
.
baseline
,
color
=
(
0
,
1
,
0
),
bottom
=
self
.
baseline
)
self
.
ul_bar
=
self
.
axes
.
bar
(
inds
,
result
.
upper_bounds
-
self
.
baseline
,
color
=
0.5
*
self
.
false_color
,
bottom
=
self
.
baseline
)
self
.
ll_bar
=
self
.
axes
.
bar
(
inds
,
result
.
lower_bounds
-
self
.
baseline
,
color
=
self
.
false_color
,
bottom
=
self
.
baseline
)
xlim
=
self
.
axes
.
get_xlim
()
for
i
in
np
.
arange
(
result
.
lower_lim
+
self
.
baseline
,
result
.
upper_lim
,
result
.
get_block_size
()):
self
.
axes
.
plot
(
self
.
axes
.
get_xlim
(),
np
.
ones
(
2
)
*
i
,
color
=
'
k
'
)
...
...
@@ -72,6 +77,7 @@ class HearingMplCanvas(FigureCanvas):
def
update_result
(
self
,
result
:
HearingTest
)
->
None
:
self
.
set_bar_heights
(
self
.
ul_bar
,
result
.
upper_bounds
-
self
.
baseline
)
self
.
set_bar_heights
(
self
.
ll_bar
,
result
.
lower_bounds
-
self
.
baseline
)
self
.
set_bar_colors
([
self
.
ul_bar
,
self
.
ll_bar
],
result
.
finished_freqs
())
self
.
draw
()
@staticmethod
...
...
@@ -79,6 +85,16 @@ class HearingMplCanvas(FigureCanvas):
for
bar
,
h
in
zip
(
bars
,
vals
):
bar
.
set_height
(
h
)
@staticmethod
def
set_bar_colors
(
bars
,
finished
):
depth
=
[
0.5
,
1
]
for
i
,
bar_line
in
enumerate
(
bars
):
for
bar
,
f
in
zip
(
bar_line
,
finished
):
if
f
:
bar
.
set_facecolor
(
depth
[
i
]
*
HearingMplCanvas
.
true_color
)
else
:
bar
.
set_facecolor
(
depth
[
i
]
*
HearingMplCanvas
.
false_color
)
# TODO add animation
...
...
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