Fixed bug with EEG matrix training backup

This commit is contained in:
2019-01-25 17:10:18 +00:00
parent de5a141d63
commit 4459415ea9
10 changed files with 150 additions and 28 deletions
+2
View File
@@ -66,6 +66,7 @@ class ClickTestThread(BaseThread):
self.waitForPageLoad()
self.socketio.emit('test_ready', namespace='/main')
for self.trial_ind in range(self.trial_ind, self.nTrials):
self.saveState(out=self.backupFilepath)
self.displayInstructions()
self.waitForPartReady()
if self._stopevent.isSet() or self.finishTest:
@@ -76,6 +77,7 @@ class ClickTestThread(BaseThread):
if not self._stopevent.isSet():
self.unsetPageLoaded()
self.socketio.emit('processing-complete', namespace='/main')
self.waitForPageLoad()
self.waitForFinalise()
+6 -17
View File
@@ -67,7 +67,7 @@ class DaTestThread(BaseThread):
socketio=socketio,
participant=participant)
self.toSave = ['trial_ind', 'nTrials', 'wav_file', 'test_name', 'si']
self.toSave = ['stim_paths', 'trial_ind', 'nTrials', 'wav_file', 'test_name', 'si']
self.socketio.on_event('finalise_results', self.finaliseResults, namespace='/main')
@@ -80,39 +80,28 @@ class DaTestThread(BaseThread):
'''
self.waitForPageLoad()
self.socketio.emit('test_ready', namespace='/main')
set_trace()
for wav in self.stim_paths[self.trial_ind:]:
self.saveState(out=self.backupFilepath)
self.displayInstructions()
self.waitForPartReady()
if self._stopevent.isSet() or self.finishTest:
break
# Play concatenated matrix sentences at set SNR
self.playStimulus(wav)
self.playStimulusWav(wav)
self.trial_ind += 1
self.saveState(out=self.backupFilepath)
if not self._stopevent.isSet():
self.unsetPageLoaded()
self.socketio.emit('processing-complete', namespace='/main')
self.waitForPageLoad()
self.waitForFinalise()
def displayInstructions(self):
self.socketio.emit('display_instructions', namespace='/main')
def playStimulus(self, wav_file, replay=False):
self.newResp = False
self.socketio.emit("stim_playing", namespace="/main")
# if not replay:
# self.y = self.generateTrial(self.snr)
# Play audio
# sd.play(self.y, self.fs, blocking=True)
if not self.dev_mode:
self.play_wav(wav_file, 'finish_test')
else:
self.play_wav('./test.wav', 'finish_test')
self.socketio.emit("stim_done", namespace="/main")
def loadStimulus(self):
'''
'''
+3 -3
View File
@@ -164,8 +164,8 @@ class EEGMatTrainThread(BaseThread):
)
# For each stimulus
trials = list(zip(self.stim_paths, self.question))[self.trial_ind:]
set_trace()
for (wav, q) in trials:
self.saveState(out=self.backupFilepath)
self.displayInstructions()
self.waitForPartReady()
if self._stopevent.isSet() or self.finishTest:
@@ -174,12 +174,12 @@ class EEGMatTrainThread(BaseThread):
self.playStimulus(wav)
self.setMatrix(q)
self.saveState(out=self.backupFilepath)
self.finaliseResults()
if not self._stopevent.isSet():
self.unsetPageLoaded()
self.socketio.emit('processing-complete', namespace='/main')
self.waitForPageLoad()
self.fillTable()
self.waitForFinalise()
def displayInstructions(self):
self.socketio.emit(
@@ -192,7 +192,7 @@ class EEGMatTrainThread(BaseThread):
'''
'''
symb = [[symb_dict[x], symb_dict[y]] for x, y in self.answers if not np.isnan([x, y]).any()]
self.socketio.emit('test_fill_table', {'data': symb}, namespace='/main')
self.socketio.emit('eeg_test_fill_table', {'data': symb}, namespace='/main')
def setMatrix(self, questions):
+2 -2
View File
@@ -63,11 +63,11 @@
waitingDialog.hide();
});
socket.on('stim_playing', function(msg) {
socket.on('da_test_stim_playing', function(msg) {
on()
});
socket.on('stim_done', function(msg) {
socket.on('da_test_stim_done', function(msg) {
off()
});
+1 -1
View File
@@ -47,7 +47,7 @@
// Check if matrix stimulus is currently being processed
waitingDialog.show('Generating stimulus');
socket.on('test_fill_table', function(msg) {
socket.on('eeg_test_fill_table', function(msg) {
for(i = 0; i < msg['data'].length; i++) {
for(j = 0; j < msg['data'][i].length; j++) {
$(`#Q${j+1} > .T${i+1}`).text(String.fromCharCode(msg['data'][i][j]));
+9
View File
@@ -0,0 +1,9 @@
{% extends 'participant_index.html' %}
{% block content %}
<div class="card">
<div class="card-body">
<h1>Test complete!</h1>
<p>Please wait for the experimenter to give further instructions...</p>
</div>
</div>
{% endblock %}
+9
View File
@@ -0,0 +1,9 @@
{% extends 'participant_index.html' %}
{% block content %}
<div class="card">
<div class="card-body">
<h1>Test complete!</h1>
<p>Please wait for the experimenter to give further instructions...</p>
</div>
</div>
{% endblock %}
+70
View File
@@ -0,0 +1,70 @@
{% extends 'index.html' %}
{% block content %}
<div class="card">
<div id="main-div" class="card-body">
<h3>You will need:</h3>
<ul>
<li>Hand gel</li>
<li>PTA form</li>
<li>Otoscope</li>
<li>Otoscope tips</li>
</ul>
<h3>Procedure:</h3>
<ol>
<li>Perform otoscopy, checking in particular for redness or bulging
tympanic membrane</li>
<li>Questions to ask:
<ul>
<li>Has the participant experienced discomfort, pain or discharge
in either ear?</li>
<li>Are they currently being
treated for any ear-related problems</li>
<li>Have they previously had surgery involving the ears</li>
<li>Have they been exposed to any loud noises in the last 24 hours?</li>
<li>Do they experience tinnitus?</li>
<li>Do they hear better from a particular ear? (start with that one)</li>
</ul>
</li>
<li>Explain and demonstrate procedure
<ul>
<li>"I will insert a probe into the opening of your ear
canal. The probe has a soft tip to seal the ear. You
will feel some pressure in your ear for a few seconds
while I measure the function of your middle ear. This
test is automatic and I do not require you to do
anything, but please avoid any unnecessary movement and
avoid speaking or swallowing after the probe has been
inserted. Should you find the procedure painful and
want me to stop, please indicate this by either saying
"stop" or by raising your hand."</li>
<li>Tones may be heard in either ear</li>
<li>Instruct participant to report any discomfort or
pain experienced during the examination</li>
<li>If needed the test can be stopped at any time</li>
</ul>
</li>
<li>Perform air coduction procedure
<ul>
<li>Freq. order: 1000, 2000, 4000, 8000, 500, 250, 1000 (again)</li>
<li>Decrease by 10dB until no response, increase by 5 dB until response</li>
<li>When subject responds to 2/3, 3/4 (&gt;50%), take this as the threshold</li>
</ul>
</li>
<li>Perform bone coduction procedure
<ul>
<li>Place bone conductor over the worse ear (based on AC results)</li>
<li>Occlude test ear with headphones</li>
<li>Freq. order: 1000, 2000, 4000, 500</li>
<li>Decrease by 10dB until no response, increase by 5 dB until response</li>
<li>When subject responds to 2/3, 3/4 (&gt;50%), take this as the threshold</li>
</ul>
</li>
</ol>
<div>
<img src=""
</div>
</div>
</div>
{% endblock %}
+47
View File
@@ -0,0 +1,47 @@
{% extends 'index.html' %}
{% block content %}
<div class="card">
<div id="main-div" class="card-body">
<h3>You will need:</h3>
<ul>
<li>Hand gel</li>
<li>Typanometer</li>
<li>Otoscope</li>
<li>Otoscope tips</li>
</ul>
<h3>Procedure:</h3>
<ol>
<li>Questions to ask:
<ul>
</ul>
</li>
<li>Explain and demonstrate procedure
<ul>
<li> "I am going to test your hearing by measuring the
quietest sounds that you can hear. As soon as you hear
a sound (tone), press the button. Keep it pressed for
as long as you hear the sound (tone), no matter which
ear you hear it in. Release the button as soon as you
no longer hear the sound (tone). Whatever the sound,
and no matter how faint the sound, press the button as
soon as you think you hear it, and release it as soon
as you think it stops."</li>
<li>Tones may be heard in either ear</li>
<li>Instruct participant to report any discomfort or
pain experienced during the examination</li>
<li>If needed the test can be stopped at any time</li>
</ul>
</li>
<li>Perform procedure
<ul>
<li>Freq. order: 1000, 2000, 4000, 8000, 500, 250, 1000 (again)</li>
<li>Decrease by 10dB until no response, increase by 5 dB until response</li>
<li>When subject responds to 2/3, 3/4 (&gt;50%), take this as the threshold</li>
</ul>
</li>
</ol>
</div>
</div>
{% endblock %}
-4
View File
@@ -153,9 +153,6 @@ class BaseThread(Thread):
Wait for results to be finalised by socketio handler
'''
while not self.finalised and not self._stopevent.isSet() and not self.finishTest:
print("self.finalised {}".format(self.finalised))
print("self.finishTest {}".format(self.finishTest))
print("self._stopevent {}".format(self._stopevent))
self._stopevent.wait(0.2)
self.socketio.emit("test_finished", namespace='/main')
return
@@ -262,7 +259,6 @@ class BaseThread(Thread):
previously generated pickle file
'''
filepath = msg['data']
set_trace()
self.loadState(filepath)