Static test now functional - Number of stimulus/SNRs potentially incorrect
This commit is contained in:
+20
-3
@@ -68,12 +68,15 @@ class EEGTestThread(Thread):
|
||||
self.marker_files = []
|
||||
self.question_files = []
|
||||
self.question = []
|
||||
self.response = []
|
||||
|
||||
self.socketio.on_event('page_loaded', self.setPageLoaded, namespace='/main')
|
||||
self.socketio.on_event('part_ready', self.setPartReady, namespace='/main')
|
||||
self.socketio.on_event('submit_eeg_response', self.submitTestResponse, namespace='/main')
|
||||
self.socketio.on_event('finish_eeg_test', self.finishTestEarly, namespace='/main')
|
||||
self.socketio.on_event('finalise_results', self.finaliseResults, namespace='/main')
|
||||
self.socketio.on_event('save_file_dialog_resp', self.manualSave, namespace='/main')
|
||||
self.socketio.on_event('load_file_dialog_resp', self.loadStateSocketHandle, namespace='/main')
|
||||
# Percent speech inteligibility (estimated using behavioural measure)
|
||||
# to present stimuli at
|
||||
self.si = np.array([20.0, 35.0, 50.0, 65.0, 80.0, 90.0, 100.0])
|
||||
@@ -200,6 +203,7 @@ class EEGTestThread(Thread):
|
||||
while not self.pageLoaded and not self._stopevent.isSet():
|
||||
self.socketio.emit("check-loaded", namespace='/main')
|
||||
self._stopevent.wait(0.5)
|
||||
self.pageLoaded = False
|
||||
return
|
||||
|
||||
def waitForPartReady(self):
|
||||
@@ -265,6 +269,9 @@ class EEGTestThread(Thread):
|
||||
noise_file = PySndfile(self.noise_path, 'r')
|
||||
stim_dirs = os.listdir(listDir)
|
||||
shuffle(stim_dirs)
|
||||
wav_files = []
|
||||
question = []
|
||||
marker_files = []
|
||||
self.socketio.emit('eeg_test_stim_load', namespace='/main')
|
||||
for ind, dir_name in enumerate(stim_dirs):
|
||||
stim_dir = os.path.join(listDir, dir_name)
|
||||
@@ -294,9 +301,9 @@ class EEGTestThread(Thread):
|
||||
sndio.write(out_wav_path,speech+(noise*snr_fs), fs, fmt, enc)
|
||||
np.save(out_meta_path, snr)
|
||||
wf.append(out_wav_path)
|
||||
self.wav_files.append(wf)
|
||||
wav_files.append(wf)
|
||||
out_marker_path = os.path.join(save_dir, "Marker_{0}.csv".format(ind))
|
||||
self.marker_files.append(out_marker_path)
|
||||
marker_files.append(out_marker_path)
|
||||
out_q_path = os.path.join(save_dir, "Questions_{0}.csv".format(ind))
|
||||
self.question_files.append(out_q_path)
|
||||
copyfile(marker_file, out_marker_path)
|
||||
@@ -306,11 +313,21 @@ class EEGTestThread(Thread):
|
||||
q_reader = csv.reader(q_file)
|
||||
for line in q_reader:
|
||||
q.append(line)
|
||||
self.question.append(q)
|
||||
question.append(q)
|
||||
|
||||
self.wav_files = [item for sublist in wav_files for item in sublist]
|
||||
|
||||
for item in question:
|
||||
self.question.extend([item] * 4)
|
||||
|
||||
for item in marker_files:
|
||||
self.marker_files.extend([item] * 4)
|
||||
|
||||
|
||||
c = list(zip(self.wav_files, self.marker_files, self.question))
|
||||
shuffle(c)
|
||||
self.wav_files, self.marker_files, self.question = zip(*c)
|
||||
|
||||
self.answers = np.empty(np.shape(self.question)[:2])
|
||||
self.answers[:] = np.nan
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ def main():
|
||||
a = 0
|
||||
for ind, (wav, txt) in enumerate(zip(merged_wavs, words)):
|
||||
csv_line = [counter]
|
||||
silence = np.zeros(np.random.uniform(int(0.3*44100), int(0.5*44100), 1).astype(int))
|
||||
silence = np.zeros(np.random.uniform(int(0.3*44100), int(0.4*44100), 1).astype(int))
|
||||
out_wav.write_frames(silence)
|
||||
counter += silence.size
|
||||
csv_line.append(counter)
|
||||
|
||||
@@ -14,6 +14,27 @@
|
||||
<th scope="col">5</th>
|
||||
<th scope="col">6</th>
|
||||
<th scope="col">7</th>
|
||||
<th scope="col">8</th>
|
||||
<th scope="col">9</th>
|
||||
<th scope="col">10</th>
|
||||
<th scope="col">11</th>
|
||||
<th scope="col">12</th>
|
||||
<th scope="col">13</th>
|
||||
<th scope="col">14</th>
|
||||
<th scope="col">15</th>
|
||||
<th scope="col">16</th>
|
||||
<th scope="col">17</th>
|
||||
<th scope="col">18</th>
|
||||
<th scope="col">19</th>
|
||||
<th scope="col">20</th>
|
||||
<th scope="col">21</th>
|
||||
<th scope="col">22</th>
|
||||
<th scope="col">23</th>
|
||||
<th scope="col">24</th>
|
||||
<th scope="col">25</th>
|
||||
<th scope="col">26</th>
|
||||
<th scope="col">27</th>
|
||||
<th scope="col">28</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -26,6 +47,27 @@
|
||||
<td class="T5">-</td>
|
||||
<td class="T6">-</td>
|
||||
<td class="T7">-</td>
|
||||
<td class="T8">-</td>
|
||||
<td class="T9">-</td>
|
||||
<td class="T10">-</td>
|
||||
<td class="T11">-</td>
|
||||
<td class="T12">-</td>
|
||||
<td class="T13">-</td>
|
||||
<td class="T14">-</td>
|
||||
<td class="T15">-</td>
|
||||
<td class="T16">-</td>
|
||||
<td class="T17">-</td>
|
||||
<td class="T18">-</td>
|
||||
<td class="T19">-</td>
|
||||
<td class="T20">-</td>
|
||||
<td class="T21">-</td>
|
||||
<td class="T22">-</td>
|
||||
<td class="T23">-</td>
|
||||
<td class="T24">-</td>
|
||||
<td class="T25">-</td>
|
||||
<td class="T26">-</td>
|
||||
<td class="T27">-</td>
|
||||
<td class="T28">-</td>
|
||||
</tr>
|
||||
<tr id="Q2">
|
||||
<th scope="row">Q2</th>
|
||||
@@ -36,6 +78,27 @@
|
||||
<td class="T5">-</td>
|
||||
<td class="T6">-</td>
|
||||
<td class="T7">-</td>
|
||||
<td class="T8">-</td>
|
||||
<td class="T9">-</td>
|
||||
<td class="T10">-</td>
|
||||
<td class="T11">-</td>
|
||||
<td class="T12">-</td>
|
||||
<td class="T13">-</td>
|
||||
<td class="T14">-</td>
|
||||
<td class="T15">-</td>
|
||||
<td class="T16">-</td>
|
||||
<td class="T17">-</td>
|
||||
<td class="T18">-</td>
|
||||
<td class="T19">-</td>
|
||||
<td class="T20">-</td>
|
||||
<td class="T21">-</td>
|
||||
<td class="T22">-</td>
|
||||
<td class="T23">-</td>
|
||||
<td class="T24">-</td>
|
||||
<td class="T25">-</td>
|
||||
<td class="T26">-</td>
|
||||
<td class="T27">-</td>
|
||||
<td class="T28">-</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -14,6 +14,27 @@
|
||||
<th scope="col">5</th>
|
||||
<th scope="col">6</th>
|
||||
<th scope="col">7</th>
|
||||
<th scope="col">8</th>
|
||||
<th scope="col">9</th>
|
||||
<th scope="col">10</th>
|
||||
<th scope="col">11</th>
|
||||
<th scope="col">12</th>
|
||||
<th scope="col">13</th>
|
||||
<th scope="col">14</th>
|
||||
<th scope="col">15</th>
|
||||
<th scope="col">16</th>
|
||||
<th scope="col">17</th>
|
||||
<th scope="col">18</th>
|
||||
<th scope="col">19</th>
|
||||
<th scope="col">20</th>
|
||||
<th scope="col">21</th>
|
||||
<th scope="col">22</th>
|
||||
<th scope="col">23</th>
|
||||
<th scope="col">24</th>
|
||||
<th scope="col">25</th>
|
||||
<th scope="col">26</th>
|
||||
<th scope="col">27</th>
|
||||
<th scope="col">28</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -26,6 +47,27 @@
|
||||
<td class="T5">-</td>
|
||||
<td class="T6">-</td>
|
||||
<td class="T7">-</td>
|
||||
<td class="T8">-</td>
|
||||
<td class="T9">-</td>
|
||||
<td class="T10">-</td>
|
||||
<td class="T11">-</td>
|
||||
<td class="T12">-</td>
|
||||
<td class="T13">-</td>
|
||||
<td class="T14">-</td>
|
||||
<td class="T15">-</td>
|
||||
<td class="T16">-</td>
|
||||
<td class="T17">-</td>
|
||||
<td class="T18">-</td>
|
||||
<td class="T19">-</td>
|
||||
<td class="T20">-</td>
|
||||
<td class="T21">-</td>
|
||||
<td class="T22">-</td>
|
||||
<td class="T23">-</td>
|
||||
<td class="T24">-</td>
|
||||
<td class="T25">-</td>
|
||||
<td class="T26">-</td>
|
||||
<td class="T27">-</td>
|
||||
<td class="T28">-</td>
|
||||
</tr>
|
||||
<tr id="Q2">
|
||||
<th scope="row">Q2</th>
|
||||
@@ -36,6 +78,27 @@
|
||||
<td class="T5">-</td>
|
||||
<td class="T6">-</td>
|
||||
<td class="T7">-</td>
|
||||
<td class="T8">-</td>
|
||||
<td class="T9">-</td>
|
||||
<td class="T10">-</td>
|
||||
<td class="T11">-</td>
|
||||
<td class="T12">-</td>
|
||||
<td class="T13">-</td>
|
||||
<td class="T14">-</td>
|
||||
<td class="T15">-</td>
|
||||
<td class="T16">-</td>
|
||||
<td class="T17">-</td>
|
||||
<td class="T18">-</td>
|
||||
<td class="T19">-</td>
|
||||
<td class="T20">-</td>
|
||||
<td class="T21">-</td>
|
||||
<td class="T22">-</td>
|
||||
<td class="T23">-</td>
|
||||
<td class="T24">-</td>
|
||||
<td class="T25">-</td>
|
||||
<td class="T26">-</td>
|
||||
<td class="T27">-</td>
|
||||
<td class="T28">-</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -70,6 +133,10 @@
|
||||
waitingDialog.hide();
|
||||
});
|
||||
|
||||
$('#eeg_test_save').click(function(event) {
|
||||
socket.emit("open_save_file_dialog")
|
||||
});
|
||||
|
||||
$('#eeg_test_finish').click(function(event) {
|
||||
socket.emit("finish_eeg_test")
|
||||
});
|
||||
@@ -79,6 +146,7 @@
|
||||
alert("Matrix stimulus processing complete!")
|
||||
window.location.href = '/eeg/test/clinician/complete';
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -134,11 +134,8 @@
|
||||
});
|
||||
|
||||
socket.on('eeg_test_ready', function(msg) {
|
||||
$("#sentence_1").text(msg['sentence_1'])
|
||||
$("#sentence_2").text(msg['sentence_2'])
|
||||
loading = false;
|
||||
waitingDialog.hide();
|
||||
displayInstructions();
|
||||
});
|
||||
|
||||
var choice = Array(5).fill('');
|
||||
|
||||
@@ -112,6 +112,15 @@
|
||||
socket.on('check-loaded', function(msg) {
|
||||
socket.emit('page_loaded', {data: "clinician"});
|
||||
});
|
||||
|
||||
// FIXME: A terrible hack because I can't get the main thread to talk to
|
||||
// the subthread directly using socketio...
|
||||
socket.on('save_file_dialog_resp', function(msg) {
|
||||
socket.emit("save_file_dialog_resp", msg)
|
||||
});
|
||||
socket.on('load_file_dialog_resp', function(msg) {
|
||||
socket.emit("load_file_dialog_resp", msg)
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@@ -29,14 +29,6 @@ $(document).ready(function(){
|
||||
socket.on('mat_plot_ready', function(msg) {
|
||||
$('#mat_plot').attr('src', msg.data);
|
||||
});
|
||||
// FIXME: A terrible hack because I can't get the main thread to talk to
|
||||
// the subthread directly using socketio...
|
||||
socket.on('save_file_dialog_resp', function(msg) {
|
||||
socket.emit("save_file_dialog_resp", msg)
|
||||
});
|
||||
socket.on('load_file_dialog_resp', function(msg) {
|
||||
socket.emit("load_file_dialog_resp", msg)
|
||||
});
|
||||
|
||||
// Catch message when asynchronous process is complete
|
||||
socket.on('processing-complete', function(msg) {
|
||||
|
||||
Reference in New Issue
Block a user