Fixed bugs and checked over mat test stimulus recording
This commit is contained in:
@@ -80,6 +80,7 @@ class EEGStoryTrainThread(BaseThread):
|
||||
# For each stimulus
|
||||
trials = list(zip(self.wav_files, self.question))[self.trial_ind:]
|
||||
for (wav, q) in trials:
|
||||
self.saveState(out=self.backupFilepath)
|
||||
self.displayInstructions()
|
||||
self.setQuestion(q)
|
||||
self.waitForPartReady()
|
||||
@@ -93,12 +94,12 @@ class EEGStoryTrainThread(BaseThread):
|
||||
self.processResponse()
|
||||
self.trial_ind += 1
|
||||
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 submitTestResponse(self, msg):
|
||||
'''
|
||||
|
||||
+7
-17
@@ -52,6 +52,7 @@ class EEGTestThread(BaseThread):
|
||||
red_coef="./calibration/out/reduction_coefficients/mat_red_coef.npy",
|
||||
cal_coef="./calibration/out/calibration_coefficients/da_cal_coef.npy",
|
||||
socketio=None, participant=None, srt_50=None, s_50=None):
|
||||
self.test_name = 'eeg_test'
|
||||
self.noise_path = noiseFilepath
|
||||
self.listDir = listFolder
|
||||
|
||||
@@ -77,6 +78,8 @@ class EEGTestThread(BaseThread):
|
||||
self.socketio.on_event('submit_eeg_response', self.submitTestResponse, namespace='/main')
|
||||
self.socketio.on_event('finalise_results', self.finaliseResults, namespace='/main')
|
||||
|
||||
self.dev_mode = False
|
||||
|
||||
|
||||
def testLoop(self):
|
||||
'''
|
||||
@@ -92,12 +95,13 @@ class EEGTestThread(BaseThread):
|
||||
# For each stimulus
|
||||
trials = list(zip(self.wav_files, self.question))[self.trial_ind:]
|
||||
for (wav, q) in trials:
|
||||
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.setMatrix(q)
|
||||
self.saveState(out=self.backupFilepath)
|
||||
if not self._stopevent.isSet():
|
||||
@@ -105,6 +109,7 @@ class EEGTestThread(BaseThread):
|
||||
self.socketio.emit('processing-complete', namespace='/main')
|
||||
self.waitForPageLoad()
|
||||
self.fillTable()
|
||||
self.waitForFinalise()
|
||||
|
||||
def displayInstructions(self):
|
||||
self.socketio.emit(
|
||||
@@ -117,7 +122,7 @@ class EEGTestThread(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):
|
||||
@@ -169,21 +174,6 @@ class EEGTestThread(BaseThread):
|
||||
return 1./(1.+np.exp(4.*s_50*(L_50-L)))
|
||||
|
||||
|
||||
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):
|
||||
'''
|
||||
'''
|
||||
|
||||
@@ -119,7 +119,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]));
|
||||
|
||||
+173
-53
@@ -2,66 +2,186 @@
|
||||
{% block content %}
|
||||
<link rel=stylesheet type=text/css href="{{ url_for('static', filename='style.css') }}">
|
||||
<div id="main-div" class="outer">
|
||||
<div class="mat_grid">
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-0" class="Btn Btn-outline-secondary mat-button">Peter</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-1" class="Btn Btn-outline-secondary mat-button">got</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-2" class="Btn Btn-outline-secondary mat-button">three</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-3" class="Btn Btn-outline-secondary mat-button">large</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-4" class="Btn Btn-outline-secondary mat-button">desks</button>
|
||||
<div class="container-fluid mat_grid">
|
||||
<div class="row">
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-0" class="Btn Btn-outline-secondary mat-button">Peter</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-1" class="Btn Btn-outline-secondary mat-button">got</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-2" class="Btn Btn-outline-secondary mat-button">three</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-3" class="Btn Btn-outline-secondary mat-button">large</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-4" class="Btn Btn-outline-secondary mat-button">desks</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-0" class="Btn Btn-outline-secondary mat-button">Kathy</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-1" class="Btn Btn-outline-secondary mat-button">sees</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-2" class="Btn Btn-outline-secondary mat-button">nine</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-3" class="Btn Btn-outline-secondary mat-button">small</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-4" class="Btn Btn-outline-secondary mat-button">chairs</button>
|
||||
<div class="row">
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-0" class="Btn Btn-outline-secondary mat-button">Kathy</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-1" class="Btn Btn-outline-secondary mat-button">sees</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-2" class="Btn Btn-outline-secondary mat-button">nine</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-3" class="Btn Btn-outline-secondary mat-button">small</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-4" class="Btn Btn-outline-secondary mat-button">chairs</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-0" class="Btn Btn-outline-secondary mat-button">Lucy</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-1" class="Btn Btn-outline-secondary mat-button">bought</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-2" class="Btn Btn-outline-secondary mat-button">five</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-3" class="Btn Btn-outline-secondary mat-button">old</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-4" class="Btn Btn-outline-secondary mat-button">shoes</button>
|
||||
<div class="row">
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-0" class="Btn Btn-outline-secondary mat-button">Lucy</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-1" class="Btn Btn-outline-secondary mat-button">bought</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-2" class="Btn Btn-outline-secondary mat-button">five</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-3" class="Btn Btn-outline-secondary mat-button">old</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-4" class="Btn Btn-outline-secondary mat-button">shoes</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-0" class="Btn Btn-outline-secondary mat-button">Alan</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-1" class="Btn Btn-outline-secondary mat-button">gives</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-2" class="Btn Btn-outline-secondary mat-button">eight</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-3" class="Btn Btn-outline-secondary mat-button">dark</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-4" class="Btn Btn-outline-secondary mat-button">toys</button>
|
||||
<div class="row">
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-0" class="Btn Btn-outline-secondary mat-button">Alan</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-1" class="Btn Btn-outline-secondary mat-button">gives</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-2" class="Btn Btn-outline-secondary mat-button">eight</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-3" class="Btn Btn-outline-secondary mat-button">dark</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-4" class="Btn Btn-outline-secondary mat-button">toys</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-0" class="Btn Btn-outline-secondary mat-button">Rachel</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-1" class="Btn Btn-outline-secondary mat-button">sold</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-2" class="Btn Btn-outline-secondary mat-button">four</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-3" class="Btn Btn-outline-secondary mat-button">thin</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-4" class="Btn Btn-outline-secondary mat-button">spoons</button>
|
||||
<div class="row">
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-0" class="Btn Btn-outline-secondary mat-button">Rachel</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-1" class="Btn Btn-outline-secondary mat-button">sold</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-2" class="Btn Btn-outline-secondary mat-button">four</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-3" class="Btn Btn-outline-secondary mat-button">thin</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-4" class="Btn Btn-outline-secondary mat-button">spoons</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-0" class="Btn Btn-outline-secondary mat-button">Barry</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-1" class="Btn Btn-outline-secondary mat-button">likes</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-2" class="Btn Btn-outline-secondary mat-button">six</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-3" class="Btn Btn-outline-secondary mat-button">green</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-4" class="Btn Btn-outline-secondary mat-button">mugs</button>
|
||||
<div class="row">
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-0" class="Btn Btn-outline-secondary mat-button">Barry</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-1" class="Btn Btn-outline-secondary mat-button">likes</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-2" class="Btn Btn-outline-secondary mat-button">six</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-3" class="Btn Btn-outline-secondary mat-button">green</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-4" class="Btn Btn-outline-secondary mat-button">mugs</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-0" class="Btn Btn-outline-secondary mat-button">Steven</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-1" class="Btn Btn-outline-secondary mat-button">has</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-2" class="Btn Btn-outline-secondary mat-button">two</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-3" class="Btn Btn-outline-secondary mat-button">cheap</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-4" class="Btn Btn-outline-secondary mat-button">ships</button>
|
||||
<div class="row">
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-0" class="Btn Btn-outline-secondary mat-button">Steven</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-1" class="Btn Btn-outline-secondary mat-button">has</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-2" class="Btn Btn-outline-secondary mat-button">two</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-3" class="Btn Btn-outline-secondary mat-button">cheap</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-4" class="Btn Btn-outline-secondary mat-button">ships</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-0" class="Btn Btn-outline-secondary mat-button">Thomas</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-1" class="Btn Btn-outline-secondary mat-button">kept</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-2" class="Btn Btn-outline-secondary mat-button">ten</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-3" class="Btn Btn-outline-secondary mat-button">pink</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-4" class="Btn Btn-outline-secondary mat-button">rings</button>
|
||||
<div class="row">
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-0" class="Btn Btn-outline-secondary mat-button">Thomas</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-1" class="Btn Btn-outline-secondary mat-button">kept</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-2" class="Btn Btn-outline-secondary mat-button">ten</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-3" class="Btn Btn-outline-secondary mat-button">pink</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-4" class="Btn Btn-outline-secondary mat-button">rings</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-0" class="Btn Btn-outline-secondary mat-button">Hannah</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-1" class="Btn Btn-outline-secondary mat-button">wins</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-2" class="Btn Btn-outline-secondary mat-button">twelve</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-3" class="Btn Btn-outline-secondary mat-button">red</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-4" class="Btn Btn-outline-secondary mat-button">tins</button>
|
||||
<div class="row">
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-0" class="Btn Btn-outline-secondary mat-button">Hannah</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-1" class="Btn Btn-outline-secondary mat-button">wins</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-2" class="Btn Btn-outline-secondary mat-button">twelve</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-3" class="Btn Btn-outline-secondary mat-button">red</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-4" class="Btn Btn-outline-secondary mat-button">tins</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-0" class="Btn Btn-outline-secondary mat-button">Nina</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-1" class="Btn Btn-outline-secondary mat-button">wants</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-2" class="Btn Btn-outline-secondary mat-button">some</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-3" class="Btn Btn-outline-secondary mat-button">big</button>
|
||||
<button type="button" href="#" data-toggle="button" aria-pressed="false" disabled id="mat-4" class="Btn Btn-outline-secondary mat-button">beds</button>
|
||||
<div class="row">
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-0" class="Btn Btn-outline-secondary mat-button">Nina</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-1" class="Btn Btn-outline-secondary mat-button">wants</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-2" class="Btn Btn-outline-secondary mat-button">some</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-3" class="Btn Btn-outline-secondary mat-button">big</button>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<button type="button" href="#" disabled id="mat-4" class="Btn Btn-outline-secondary mat-button">beds</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="eeg_submit">
|
||||
<button type="button" href="#" disabled id="eeg-submit" class="Btn Btn-primary">Submit</button>
|
||||
@@ -154,12 +274,12 @@
|
||||
return false;
|
||||
});
|
||||
|
||||
socket.on('stim_playing', function(msg) {
|
||||
socket.on('eeg_test_stim_playing', function(msg) {
|
||||
$('.eeg_submit').find('input, textarea, button, select').attr('disabled', 'disabled');
|
||||
on()
|
||||
});
|
||||
|
||||
socket.on('stim_done', function(msg) {
|
||||
socket.on('eeg_test_stim_done', function(msg) {
|
||||
$('.eeg_submit').find('input, textarea, button, select').removeAttr('disabled');
|
||||
off()
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user