Administrator approval is now required for registering new accounts. If you are registering a new account, and are external to the University, please ask the repository owner to contact ServiceLine to request your account be approved. Repository owners must include the newly registered email address, and specific repository in the request for approval.

Commit 25ff75c4 authored by Ed Rogers's avatar Ed Rogers
Browse files

Fix bugs: lower-upper logic and choices not affecting bounds

parent a4af3255
......@@ -5,10 +5,10 @@ from SoundLibrary import SoundLibrary
class SoundRecord:
def __init__(self, freq, volume, time):
def __init__(self, freq, volume, event_time):
self.freq = freq
self.volume = volume
self.time = time
self.time = event_time
self.heard = None
......@@ -38,8 +38,8 @@ class HearingTest:
sound = self.sounds[-1]
if not sound.heard and (_time - sound.time <= self.max_response_time):
sound.heard = True
if self.lower_bounds[self.freqs == sound.freq] < sound.volume:
self.set_lower_bound(sound.freq, sound.volume)
if self.upper_bounds[self.freqs == sound.freq] > sound.volume:
self.set_upper_bound(sound.freq, sound.volume)
else:
self.false_presses += 1
self.check_for_not_heard(_time)
......@@ -48,10 +48,9 @@ class HearingTest:
def play_next_sound(self):
# TODO allow tone outside lims with low prob?
choices = []
# TODO fix bug here meaning that some choices do not reduce bounds
for i, freq in enumerate(self.freqs):
choices.extend([(freq, v) for v in
np.arange(self.lower_bounds[i],
np.arange(self.lower_bounds[i]+self.block_size(),
self.upper_bounds[i],
self.block_size())])
freq, volume = random.choice(choices)
......@@ -69,7 +68,7 @@ class HearingTest:
@property
def finished_freqs(self):
return self.upper_bounds - self.lower_bounds < self.block_size() * 0.9
return self.upper_bounds - self.lower_bounds < self.block_size() * 1.2
def check_for_not_heard(self, event_time):
for sound in reversed(self.sounds):
......@@ -79,8 +78,8 @@ class HearingTest:
break
elif delay > self.max_response_time:
sound.heard = False
if self.upper_bounds[self.freqs == sound.freq] > sound.volume:
self.set_upper_bound(sound.freq, sound.volume)
if self.lower_bounds[self.freqs == sound.freq] < sound.volume:
self.set_lower_bound(sound.freq, sound.volume)
def set_lower_bound(self, freq, volume):
self.lower_bounds[self.freqs == freq] = volume
......
......@@ -145,7 +145,7 @@ class TestWindow(QMainWindow):
central_widget.setLayout(grid_layout)
text_style = "QLabel { background-color: black; color: white; font: 24pt}"
self.title = QLabel(start_text, self)
self.title = QLabel(self.start_text, self)
self.title.setStyleSheet(text_style)
self.title.setAlignment(QtCore.Qt.AlignCenter)
......@@ -228,8 +228,6 @@ class TestWindow(QMainWindow):
thresholds = thresholds.reshape(thresholds.shape[0], -1) # convert to 2d
with open('data.csv', 'ba') as file:
np.savetxt(file, thresholds.T, fmt='%.2f', delimiter=',')
# TODO calculate score
# TODO display score
score_str = self.test.get_score_text()
self.score_label.setText(score_str)
self.score_label.show()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment