Added labels to adaptive track plot and added titles to all plots

This commit is contained in:
2018-11-18 11:12:46 +00:00
parent ed214151b4
commit e0aabb5dac
5 changed files with 194 additions and 0 deletions
+12
View File
@@ -342,6 +342,7 @@ class MatTestThread(Thread):
plt.clf()
axes = plt.gca()
psycLine, = axes.plot(x, x_y)
plt.title("Predicted psychometric function")
plt.xlabel("SNR (dB)")
plt.ylabel("% Correct")
srtLine, = axes.plot([snr_50,snr_50], [-50,50.], 'r--')
@@ -377,6 +378,17 @@ class MatTestThread(Thread):
plt.xlim([-1, self.trialN])
plt.xlabel("Trial N")
plt.ylabel("SNR (dB)")
plt.title("Adaptive track")
for i, txt in enumerate(self.snrTrack[:self.trialN]):
plt.annotate("{0}/{1}".format(
np.sum(self.wordsCorrect[i]).astype(int),
self.wordsCorrect[i].size),
(i, self.snrTrack[i]),
xytext=(0, 13),
va="center",
ha="center",
textcoords='offset points'
)
dpi = 300
plt.savefig(self.img, format='png', figsize=(800/dpi, 800/dpi), dpi=dpi)
self.img.seek(0)
Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

+52
View File
@@ -0,0 +1,52 @@
{% extends 'index.html' %}
{% block content %}
<div>
<div class="container p-0">
<div class="row">
<div class="col p-0 m-0">
<img id="mat_plot" src="/static/default_plot.png" width="100%"/>
</div>
<div class="col p-0 m-0">
<img id="mle_plot" src="/static/default_mle_plot.png" width="100%"/>
</div>
</div>
</div>
<div class="d-flex justify-content-center mt-2" role="group">
<button type="button" id="mat-save" class="btn btn-primary mx-3">Save test state as...</button>
</div>
</div>
<script>
$(document).ready(function(){
// Initialise socketio with a namespace called "main"
var socket = io.connect(location.protocol + '//' + document.domain + ':' + location.port + '/main');
$('#mat-save').click(function(event) {
socket.emit("open_save_file_dialog")
});
$('#mat-repeat').click(function(event) {
socket.emit("repeat_stimulus")
});
socket.on('mat_plot_ready', function(msg) {
console.log(msg)
$('#mat_plot').attr('src', msg.data);
});
socket.on('mat_mle_plot_ready', function(msg) {
console.log(msg)
$('#mle_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)
});
socket.on('check-loaded', function(msg) {
socket.emit('mat_page_loaded', {data: "clinician"});
});
});
</script>
{% endblock %}
+12
View File
@@ -0,0 +1,12 @@
{% 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>
<script>
</script>
{% endblock %}
+118
View File
@@ -0,0 +1,118 @@
{% extends 'participant_index.html' %}
{% block content %}
<div id="main-div" class="outer">
<div class="mat_grid">
<button type="button" href="#" disabled id="mat-0" class="Btn Btn-outline-secondary mat-button">Peter</button>
<button type="button" href="#" disabled id="mat-1" class="Btn Btn-outline-secondary mat-button">got</button>
<button type="button" href="#" disabled id="mat-2" class="Btn Btn-outline-secondary mat-button">three</button>
<button type="button" href="#" disabled id="mat-3" class="Btn Btn-outline-secondary mat-button">large</button>
<button type="button" href="#" disabled id="mat-4" class="Btn Btn-outline-secondary mat-button">desks</button>
<button type="button" href="#" disabled id="mat-0" class="Btn Btn-outline-secondary mat-button">Kathy</button>
<button type="button" href="#" disabled id="mat-1" class="Btn Btn-outline-secondary mat-button">sees</button>
<button type="button" href="#" disabled id="mat-2" class="Btn Btn-outline-secondary mat-button">nine</button>
<button type="button" href="#" disabled id="mat-3" class="Btn Btn-outline-secondary mat-button">small</button>
<button type="button" href="#" disabled id="mat-4" class="Btn Btn-outline-secondary mat-button">chairs</button>
<button type="button" href="#" disabled id="mat-0" class="Btn Btn-outline-secondary mat-button">Lucy</button>
<button type="button" href="#" disabled id="mat-1" class="Btn Btn-outline-secondary mat-button">bought</button>
<button type="button" href="#" disabled id="mat-2" class="Btn Btn-outline-secondary mat-button">five</button>
<button type="button" href="#" disabled id="mat-3" class="Btn Btn-outline-secondary mat-button">old</button>
<button type="button" href="#" disabled id="mat-4" class="Btn Btn-outline-secondary mat-button">shoes</button>
<button type="button" href="#" disabled id="mat-0" class="Btn Btn-outline-secondary mat-button">Alan</button>
<button type="button" href="#" disabled id="mat-1" class="Btn Btn-outline-secondary mat-button">gives</button>
<button type="button" href="#" disabled id="mat-2" class="Btn Btn-outline-secondary mat-button">eight</button>
<button type="button" href="#" disabled id="mat-3" class="Btn Btn-outline-secondary mat-button">dark</button>
<button type="button" href="#" disabled id="mat-4" class="Btn Btn-outline-secondary mat-button">toys</button>
<button type="button" href="#" disabled id="mat-0" class="Btn Btn-outline-secondary mat-button">Rachel</button>
<button type="button" href="#" disabled id="mat-1" class="Btn Btn-outline-secondary mat-button">sold</button>
<button type="button" href="#" disabled id="mat-2" class="Btn Btn-outline-secondary mat-button">four</button>
<button type="button" href="#" disabled id="mat-3" class="Btn Btn-outline-secondary mat-button">thin</button>
<button type="button" href="#" disabled id="mat-4" class="Btn Btn-outline-secondary mat-button">spoons</button>
<button type="button" href="#" disabled id="mat-0" class="Btn Btn-outline-secondary mat-button">Barry</button>
<button type="button" href="#" disabled id="mat-1" class="Btn Btn-outline-secondary mat-button">likes</button>
<button type="button" href="#" disabled id="mat-2" class="Btn Btn-outline-secondary mat-button">six</button>
<button type="button" href="#" disabled id="mat-3" class="Btn Btn-outline-secondary mat-button">green</button>
<button type="button" href="#" disabled id="mat-4" class="Btn Btn-outline-secondary mat-button">mugs</button>
<button type="button" href="#" disabled id="mat-0" class="Btn Btn-outline-secondary mat-button">Steven</button>
<button type="button" href="#" disabled id="mat-1" class="Btn Btn-outline-secondary mat-button">has</button>
<button type="button" href="#" disabled id="mat-2" class="Btn Btn-outline-secondary mat-button">two</button>
<button type="button" href="#" disabled id="mat-3" class="Btn Btn-outline-secondary mat-button">cheap</button>
<button type="button" href="#" disabled id="mat-4" class="Btn Btn-outline-secondary mat-button">ships</button>
<button type="button" href="#" disabled id="mat-0" class="Btn Btn-outline-secondary mat-button">Thomas</button>
<button type="button" href="#" disabled id="mat-1" class="Btn Btn-outline-secondary mat-button">kept</button>
<button type="button" href="#" disabled id="mat-2" class="Btn Btn-outline-secondary mat-button">ten</button>
<button type="button" href="#" disabled id="mat-3" class="Btn Btn-outline-secondary mat-button">pink</button>
<button type="button" href="#" disabled id="mat-4" class="Btn Btn-outline-secondary mat-button">rings</button>
<button type="button" href="#" disabled id="mat-0" class="Btn Btn-outline-secondary mat-button">Hannah</button>
<button type="button" href="#" disabled id="mat-1" class="Btn Btn-outline-secondary mat-button">wins</button>
<button type="button" href="#" disabled id="mat-2" class="Btn Btn-outline-secondary mat-button">twelve</button>
<button type="button" href="#" disabled id="mat-3" class="Btn Btn-outline-secondary mat-button">red</button>
<button type="button" href="#" disabled id="mat-4" class="Btn Btn-outline-secondary mat-button">tins</button>
<button type="button" href="#" disabled id="mat-0" class="Btn Btn-outline-secondary mat-button">Nina</button>
<button type="button" href="#" disabled id="mat-1" class="Btn Btn-outline-secondary mat-button">wants</button>
<button type="button" href="#" disabled id="mat-2" class="Btn Btn-outline-secondary mat-button">some</button>
<button type="button" href="#" disabled id="mat-3" class="Btn Btn-outline-secondary mat-button">big</button>
<button type="button" href="#" disabled id="mat-4" class="Btn Btn-outline-secondary mat-button">beds</button>
</div>
<div class="mat_submit">
<button type="button" href="#" disabled id="mat-submit" class="Btn Btn-primary">Submit</button>
</div>
<script>
$(document).ready(function(){
// Initialise socketio with a namespace called "main"
var socket = io.connect(location.protocol + '//' + document.domain + ':' + location.port + '/main');
var choice = Array(5).fill('');
$('.mat-button').click(function(event) {
choice[this.id.slice(-1)] = $(this).text();
$('.mat-button#'+this.id).not(this).removeClass("active");
$(this).addClass("active");
console.log(choice);
return false;
});
$('#mat-submit').click(function(event) {
$('#mat-submit').prop("disabled", true);
if(choice.includes('')) {
alert("Please select a word from each column");
$('#mat-submit').prop("disabled", false);
return false;
}
else {
$('.mat-button').removeClass("active");
socket.emit('submit_mat_response', {
resp: choice
});
choice = Array(5).fill('');
}
});
socket.on('mat_stim_playing', function(msg) {
// Disable all inputs whilst processing
$('#main-div').find('input, textarea, button, select').attr('disabled','disabled');
});
socket.on('mat_stim_done', function(msg) {
$('#main-div').find('input, textarea, button, select').removeAttr('disabled');
});
socket.on('processing-complete', function(msg) {
$('#main-div').find('input, textarea, button, select').attr('disabled','disabled');
});
socket.on('check-loaded', function(msg) {
socket.emit('mat_page_loaded', {data: "participant"});
});
});
</script>
</div>
{% endblock %}