annotate analyse.html @ 336:378726f0ac91 WAC2016

Paper: Added interface screenshot and box plot example
author Brecht De Man <b.deman@qmul.ac.uk>
date Thu, 15 Oct 2015 20:10:00 +0100
parents 5f27d3eb93fe
children de9a0a740b6e
rev   line source
b@329 1 <!DOCTYPE html>
b@329 2 <html lang="en">
b@329 3 <head>
b@329 4 <meta charset="utf-8">
b@329 5
b@329 6 <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
b@329 7 Remove this if you use the .htaccess -->
b@329 8 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
b@329 9
b@329 10 <title>Analysis</title>
b@329 11 <meta name="description" content="Show results from subjective evaluation">
b@329 12 <meta name="author" content="Brecht De Man">
b@329 13
b@329 14 <script type="text/javascript" src="https://www.google.com/jsapi"></script>
b@329 15 <script type="text/javascript">
b@329 16 // To aid 'one-page set-up' all scripts and CSS must be included directly in this file!
b@329 17
b@329 18 google.load("visualization", "1", {packages:["corechart"]});
b@329 19
b@329 20 /*************
b@336 21 * SETUP *
b@329 22 *************/
b@329 23 // folder where to find the XML files
b@336 24 xmlFileFolder = "analysis_test";
b@329 25 // array of XML files
b@336 26 var xmlFiles = ['QM-1-1.xml','QM-2-1.xml','QM-2-2.xml','QM-2-3.xml','QM-3-1.xml','QM-3-2.xml','QM-4-1.xml','QM-5-1.xml','QM-5-2.xml','QM-6-1.xml','QM-6-2.xml','QM-7-1.xml','QM-7-2.xml','QM-8-1.xml','QM-9-1.xml','QM-10-1.xml','QM-11-1.xml','QM-12-1.xml','QM-12-2.xml','QM-13-1.xml','QM-14-1.xml','QM-15-1.xml','QM-16-1.xml','QM-17-1.xml','QM-18-1.xml','QM-18-2.xml','QM-18-3.xml','QM-19-1.xml','QM-20-1.xml','QM-20-2.xml','QM-20-3.xml','QM-21-1.xml','QM-21-2.xml'];
b@336 27 //['McG-A-2014-03.xml','McG-B-2014-03.xml','McG-C-2014-03.xml','McG-D-2014-03.xml','McG-E-2014-03.xml','McG-F-2014-03.xml','McG-G-2014-03.xml','McG-H-2014-03.xml'];
b@329 28
b@329 29 //TODO: make retrieval of file names automatic / drag files on here
b@329 30
b@329 31 /****************
b@336 32 * VARIABLES *
b@329 33 ****************/
b@329 34
b@329 35 // Counters
b@336 36 // How many files, audioholders, audioelementes and statements annotated (don't count current one)
b@329 37 var numberOfFiles = -1;
b@336 38 var numberOfaudioholders = -1;
b@336 39 var numberOfaudioelementes = -1;
b@329 40 var numberOfStatements = -1;
b@329 41 var numberOfSkippedComments = 0;
b@329 42
b@329 43 // Object arrays
b@329 44 var fileNameArray = [];
b@329 45 var subjectArray = [];
b@336 46 var audioholderArray = [];
b@336 47 var audioelementArray = [];
b@329 48
b@329 49 // End of (file, audioholder, audioelement) flags
b@329 50 var newFile = true;
b@329 51 var newAudioHolder = true;
b@329 52 var newAudioElement = true;
b@329 53
b@329 54 var fileCounter = 0; // file index
b@336 55 var audioholderCounter=0; // audioholder index (current XML file)
b@336 56 var audioelementCounter=0; // audioelement index (current audioholder)
b@329 57 var statementNumber=0; // total number of statements
b@329 58
b@329 59 var root; // root of XML file
b@329 60 var commentInFull = ''; // full comment
b@329 61
b@329 62 var playAudio = true; // whether corresponding audio should be played back
b@329 63
b@329 64 // // Measuring time
b@329 65 // var lastTimeMeasured = -1; //
b@329 66 // var durationLastAnnotation = -1; // duration of last annotation
b@329 67 // var timeArray = [];
b@329 68 // var MIN_TIME = 1.0; // minimum time counted as significant
b@329 69 // var measurementPaused = false; // whether time measurement is paused
b@329 70 // var timeInBuffer = 0; //
b@329 71
b@329 72 var topLevel;
b@329 73 window.onload = function() {
b@329 74 // Initialise page
b@329 75 topLevel = document.getElementById('topLevelBody');
b@329 76 var setup = document.createElement('div');
b@329 77 setup.id = 'setupTagDiv';
b@329 78 loadAllFiles();
b@329 79
b@329 80 makePlots();
b@329 81 // measure time at this point:
b@329 82 lastTimeMeasured = new Date().getTime(); // in milliseconds
b@329 83 };
b@329 84
b@329 85 // Assert function
b@329 86 function assert(condition, message) {
b@329 87 if (!condition) {
b@329 88 message = message || "Assertion failed";
b@329 89 if (typeof Error !== "undefined") {
b@329 90 throw new Error(message);
b@329 91 }
b@329 92 throw message; // Fallback
b@329 93 }
b@329 94 }
b@329 95
b@336 96 function median(values) { // TODO: replace code by '50th percentile' - should be the same?
b@329 97 values.sort( function(a,b) {return a - b;} );
b@329 98 var half = Math.floor(values.length/2);
b@329 99 if(values.length % 2)
b@329 100 return values[half];
b@329 101 else
b@329 102 return (values[half-1] + values[half]) / 2.0;
b@329 103 }
b@336 104
b@336 105 function percentile(values, n) {
b@336 106 values.sort( function(a,b) {return a - b;} );
b@336 107 // get ordinal rank
b@336 108 var rank = Math.min(Math.floor(values.length*n/100), values.length-1);
b@336 109 return values[rank];
b@336 110 }
b@329 111
b@329 112 /***********************
b@336 113 * TIME MEASUREMENT *
b@329 114 ************************/
b@329 115
b@329 116 // measure time since last time this function was called
b@329 117 function timeSinceLastCall() {
b@329 118 // current time
b@329 119 var currentTime = new Date().getTime();
b@329 120 // calculate time difference
b@329 121 var timeDifference = currentTime - lastTimeMeasured + timeInBuffer;
b@329 122 // clear buffer (for pausing)
b@329 123 timeInBuffer = 0;
b@329 124 // remember last measured time
b@329 125 lastTimeMeasured = currentTime;
b@329 126 return timeDifference;
b@329 127 }
b@329 128
b@329 129 // pause time measurement
b@329 130 function pauseTimeMeasurement() {
b@329 131 // UN-PAUSE
b@329 132 if (measurementPaused) { // already paused
b@329 133 // button shows 'pause' again
b@329 134 document.getElementById('pauseButton').innerHTML = 'Pause';
b@329 135 // toggle state
b@329 136 measurementPaused = false;
b@329 137 // resume time measurement
b@329 138 lastTimeMeasured = new Date().getTime(); // reset time, discard time while paused
b@329 139 } else { // PAUSE
b@329 140 // button shows 'resume'
b@329 141 document.getElementById('pauseButton').innerHTML = 'Resume';
b@329 142 // toggle state
b@329 143 measurementPaused = true;
b@329 144 // pause time measurement
b@329 145 timeInBuffer = timeSinceLastCall();
b@329 146 }
b@329 147 }
b@329 148
b@329 149 // show elapsed time on interface
b@329 150 function showTimeElapsedInSeconds() {
b@329 151 // if paused: un-pause
b@329 152 if (measurementPaused) {
b@329 153 pauseTimeMeasurement();
b@329 154 }
b@329 155
b@329 156 // time of last annotation
b@329 157 var lastAnnotationTime = timeSinceLastCall()/1000;
b@329 158 document.getElementById('timeDisplay').innerHTML = lastAnnotationTime.toFixed(2);
b@329 159 // average time over last ... annotations
b@329 160 var avgAnnotationTime;
b@329 161 var numberOfElementsToAverage =
b@329 162 document.getElementById('numberOfTimeAverages').value;
b@329 163 if (isPositiveInteger(numberOfElementsToAverage)) {
b@329 164 avgAnnotationTime =
b@329 165 calculateAverageTime(lastAnnotationTime,
b@329 166 Number(numberOfElementsToAverage));
b@329 167 } else {
b@329 168 // change text field content to 'ALL'
b@329 169 document.getElementById('numberOfTimeAverages').value = 'ALL';
b@329 170 avgAnnotationTime = calculateAverageTime(lastAnnotationTime, -1);
b@329 171 }
b@329 172 document.getElementById('timeAverageDisplay').innerHTML = avgAnnotationTime.toFixed(2);
b@329 173 }
b@329 174
b@329 175 // auxiliary function: is string a positive integer?
b@329 176 // http://stackoverflow.com/questions/10834796/...
b@329 177 // validate-that-a-string-is-a-positive-integer
b@329 178 function isPositiveInteger(str) {
b@329 179 var n = ~~Number(str);
b@329 180 return String(n) === str && n >= 0;
b@329 181 }
b@329 182
b@329 183 // calculate average time
b@329 184 function calculateAverageTime(newTimeMeasurementInSeconds,numberOfPoints) {
b@329 185 // append last measurement time to time array, if significant
b@329 186 if (newTimeMeasurementInSeconds > MIN_TIME) {
b@329 187 timeArray.push(newTimeMeasurementInSeconds);
b@329 188 }
b@329 189 // average over last N elements of this array
b@329 190 if (numberOfPoints < 0 || numberOfPoints>=timeArray.length) { // calculate average over all
b@329 191 var sum = 0;
b@329 192 for (var i = 0; i < timeArray.length; i++) {
b@329 193 sum += timeArray[i];
b@329 194 }
b@329 195 averageOfTimes = sum/timeArray.length;
b@329 196 } else { // calculate average over specified number of times measured last
b@329 197 var sum = 0;
b@329 198 for (var i = timeArray.length-numberOfPoints; i < timeArray.length; i++) {
b@329 199 sum += timeArray[i];
b@329 200 }
b@329 201 averageOfTimes = sum/numberOfPoints;
b@329 202 }
b@329 203 return averageOfTimes;
b@329 204 }
b@329 205
b@329 206
b@329 207 /********************************
b@336 208 * PLAYBACK OF AUDIO *
b@329 209 ********************************/
b@329 210
b@336 211 //PLAYaudioelement
b@329 212 // Keep track of whether audio should be played
b@329 213 function playFlagChanged(){
b@329 214 playAudio = playFlag.checked; // global variable
b@329 215
b@329 216 if (!playAudio){ // if audio needs to stop
b@329 217 audio.pause(); // stop audio - if anything is playing
b@336 218 currently_playing = ''; // back to empty string so playaudioelement knows nothing's playing
b@329 219 }
b@329 220 }
b@329 221
b@336 222 // audioholder that's currently playing
b@336 223 var currently_playing_audioholder = ''; // at first: empty string
b@336 224 var currently_playing_audioelement = '';
b@329 225 var audio;
b@329 226
b@336 227 // Play audioelement of audioholder if available, from start or from same position
b@336 228 function playaudioelement(audioholderName, audioelementerName){
b@329 229 if (playAudio) { // if enabled
b@329 230 // get corresponding file from folder
b@336 231 var file_location = 'audio/'+audioholderName + '/' + audioelementerName + '.mp3'; // fixed path and file name format
b@329 232
b@329 233 // if not available, show error/warning message
b@329 234 //TODO ...
b@329 235
b@329 236 // if nothing playing yet, start playing
b@336 237 if (currently_playing_audioholder == ''){ // signal that nothing is playing
b@329 238 //playSound(audioBuffer);
b@329 239 audio = new Audio(file_location);
b@329 240 audio.loop = true; // loop when end is reached
b@329 241 audio.play();
b@336 242 currently_playing_audioholder = audioholderName;
b@336 243 currently_playing_audioelement = audioelementerName;
b@336 244 } else if (currently_playing_audioholder != audioholderName) {
b@336 245 // if different audioholder playing, stop that and start playing
b@329 246 audio.pause(); // stop audio
b@329 247 audio = new Audio(file_location); // load new file
b@329 248 audio.loop = true; // loop when end is reached
b@329 249 audio.play(); // play audio from the start
b@336 250 currently_playing_audioholder = audioholderName;
b@336 251 currently_playing_audioelement = audioelementerName;
b@336 252 } else if (currently_playing_audioelement != audioelementerName) {
b@336 253 // if same audioholder playing, start playing from where it left off
b@329 254 skipTime = audio.currentTime; // time to skip to
b@329 255 audio.pause(); // stop audio
b@329 256 audio = new Audio(file_location);
b@329 257 audio.addEventListener('loadedmetadata', function() {
b@329 258 this.currentTime = skipTime;
b@336 259 console.log('Loaded '+audioholderName+'-'+audioelementerName+', playing from '+skipTime);
b@329 260 }, false); // skip to same time when audio is loaded!
b@329 261 audio.loop = true; // loop when end is reached
b@329 262 audio.play(); // play from that time
b@329 263 audio.currentTime = skipTime;
b@336 264 currently_playing_audioholder = audioholderName;
b@336 265 currently_playing_audioelement = audioelementerName;
b@329 266 }
b@336 267 // if same audioelement playing: keep on playing (i.e. do nothing)
b@329 268 }
b@329 269 }
b@329 270
b@329 271 /********************
b@336 272 * READING FILES *
b@329 273 ********************/
b@329 274
b@329 275 // Read necessary data from XML file
b@329 276 function readXML(xmlFileName){
b@329 277 if (window.XMLHttpRequest)
b@329 278 {// code for IE7+, Firefox, Chrome, Opera, Safari
b@329 279 xmlhttp=new XMLHttpRequest();
b@329 280 }
b@329 281 else
b@329 282 {// code for IE6, IE5
b@329 283 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
b@329 284 }
b@329 285 xmlhttp.open("GET",xmlFileName,false);
b@329 286 xmlhttp.send();
b@329 287 return xmlhttp.responseXML;
b@329 288 }
b@329 289
b@329 290 // go over all files and compute relevant statistics
b@329 291 function loadAllFiles() {
b@329 292 // retrieve information from XMLs
b@329 293
b@329 294 for (fileIndex = 0; fileIndex < xmlFiles.length; fileIndex++) {
b@329 295 xmlFileName = xmlFileFolder+"/"+xmlFiles[fileIndex];
b@329 296 xml = readXML(xmlFileName);
b@329 297 if (xml != null) { // if file exists
b@329 298 // append file name to array of file names
b@329 299 fileNameArray.push(xmlFiles[fileIndex]);
b@329 300
b@329 301 // get root of XML file
b@329 302 root = xml.getElementsByTagName('browserevaluationresult')[0];
b@329 303
b@329 304 // get subject ID, add to array if not already there
b@329 305 pretest = root.getElementsByTagName('pretest')[0];
b@329 306 subjectID = pretest.getElementsByTagName('comment')[0];
b@329 307 if (subjectID.getAttribute('id')!='sessionId') { // warning in console when not available
b@329 308 console.log(xmlFiles[fileIndex]+': no SessionID available');
b@329 309 }
b@329 310 if (subjectArray.indexOf(subjectID.textContent) == -1) { // if not already in array
b@329 311 subjectArray.push(subjectID.textContent); // append to array
b@329 312 }
b@329 313
b@336 314 // go over all audioholders, add to array if not already there
b@336 315 audioholderNodes = root.getElementsByTagName('audioholder');
b@336 316 // go over audioholderNodes and append audioholder name when not present yet
b@336 317 for (audioholderIndex = 0; audioholderIndex < audioholderNodes.length; audioholderIndex++) {
b@336 318 audioholderName = audioholderNodes[audioholderIndex].getAttribute('id');
b@336 319 if (audioholderArray.indexOf(audioholderName) == -1) { // if not already in array
b@336 320 audioholderArray.push(audioholderName); // append to array
b@329 321 }
b@336 322 // within each audioholder, go over all audioelement IDs, add to array if not already there
b@336 323 audioelementNodes = audioholderNodes[audioholderIndex].getElementsByTagName('audioelement');
b@336 324 for (audioelementIndex = 0; audioelementIndex < audioelementNodes.length; audioelementIndex++) {
b@336 325 audioelementName = audioelementNodes[audioelementIndex].getAttribute('id');
b@336 326 if (audioelementArray.indexOf(audioelementName) == -1) { // if not already in array
b@336 327 audioelementArray.push(audioelementName); // append to array
b@329 328 }
b@329 329 }
b@329 330 }
b@336 331 // count occurrences of each audioholder
b@329 332 // ...
b@329 333 }
b@329 334 else {
b@329 335 console.log('XML file '+xmlFileName+' not found.');
b@329 336 }
b@329 337 }
b@329 338
b@329 339 // sort alphabetically
b@329 340 fileNameArray.sort();
b@329 341 subjectArray.sort();
b@336 342 audioholderArray.sort();
b@336 343 audioelementArray.sort();
b@329 344
b@329 345 // display all information in HTML
b@329 346 // show XML file folder
b@329 347 document.getElementById('xmlFileFolder_span').innerHTML = "\""+xmlFileFolder+"/\"";
b@329 348 // show number of files
b@329 349 document.getElementById('numberOfFiles_span').innerHTML = fileNameArray.length;
b@329 350 // show list of subject names
b@329 351 document.getElementById('subjectArray_span').innerHTML = subjectArray.toString();
b@336 352 // show list of audioholders
b@336 353 document.getElementById('audioholderArray_span').innerHTML = audioholderArray.toString();
b@336 354 // show list of audioelementes
b@336 355 document.getElementById('audioelementArray_span').innerHTML = audioelementArray.toString();
b@329 356 }
b@329 357
b@336 358 function makePlots() { //TODO: split into different functions
b@336 359 // TEMPORARY
b@336 360 makeTimeline(xmlFileFolder+"/"+xmlFiles[7]);
b@336 361
b@329 362 // create value array
b@336 363 var ratings = []; // 3D matrix of ratings (audioholder, audioelement, subject)
b@336 364 for (audioholderIndex = 0; audioholderIndex < audioholderArray.length; audioholderIndex++) {
b@329 365 ratings.push([]);
b@336 366 for (audioelementIndex = 0; audioelementIndex < audioelementArray.length; audioelementIndex++) {
b@336 367 ratings[audioholderIndex].push([]);
b@329 368 }
b@329 369 }
b@329 370
b@329 371 // go over all XML files
b@329 372 for (fileIndex = 0; fileIndex < xmlFiles.length; fileIndex++) {
b@329 373 xmlFileName = xmlFileFolder+"/"+xmlFiles[fileIndex];
b@329 374 xml = readXML(xmlFileName);
b@329 375 if (xml != null) { // if file exists
b@329 376 // get root of XML file
b@329 377 root = xml.getElementsByTagName('browserevaluationresult')[0];
b@336 378 // go over all audioholders
b@336 379 audioholderNodes = root.getElementsByTagName('audioholder');
b@336 380 for (audioholderIndex = 0; audioholderIndex < audioholderNodes.length; audioholderIndex++) {
b@336 381 audioholderName = audioholderNodes[audioholderIndex].getAttribute('id');
b@336 382 audioelementNodes = audioholderNodes[audioholderIndex].getElementsByTagName('audioelement');
b@329 383 // go over all audioelements
b@336 384 for (audioelementIndex = 0; audioelementIndex < audioelementNodes.length; audioelementIndex++) {
b@336 385 audioelementName = audioelementNodes[audioelementIndex].getAttribute('id');
b@329 386 // get value
b@336 387 var value = audioelementNodes[audioelementIndex].getElementsByTagName("value")[0].textContent;
b@329 388 if (value) { // if not empty, null, undefined...
b@329 389 ratingValue = parseFloat(value);
b@336 390 // add to matrix at proper position
b@336 391 aHidx = audioholderArray.indexOf(audioholderName);
b@336 392 aEidx = audioelementArray.indexOf(audioelementName);
b@336 393 ratings[aHidx][aEidx].push(ratingValue);
b@329 394 }
b@329 395 }
b@329 396 }
b@329 397
b@336 398 // go over all audioholders
b@329 399
b@336 400 // go over all audioelements within audioholder, see if present in idMatrix, add if not
b@329 401 // add corresponding rating to 'ratings', at position corresponding with position in idMatrix
b@329 402 }
b@329 403 }
b@329 404
b@336 405 for (audioholderIndex = 0; audioholderIndex < audioholderArray.length; audioholderIndex++) {
b@336 406 audioholderName = audioholderArray[audioholderIndex]; // for this song
b@329 407 tickArray = []
b@329 408
b@329 409 raw_data = [['SubjectID', 'Rating']];
b@329 410 audioElIdx = 0;
b@336 411 for (audioelementIndex = 0; audioelementIndex<ratings[audioholderIndex].length; audioelementIndex++){
b@336 412 if (ratings[audioholderIndex][audioelementIndex].length>0) {
b@329 413 audioElIdx++; // increase if not empty
b@329 414 // make tick label
b@336 415 tickArray.push({v:audioElIdx, f: audioelementArray[audioelementIndex]});
b@329 416 }
b@336 417 for (subject = 0; subject<ratings[audioholderIndex][audioelementIndex].length; subject++){
b@329 418 // add subject-value pair for each subject
b@336 419 raw_data.push([audioElIdx, ratings[audioholderIndex][audioelementIndex][subject]]);
b@329 420 }
b@329 421 }
b@329 422
b@329 423 // create plot (one per song)
b@329 424 var data = google.visualization.arrayToDataTable(raw_data);
b@329 425
b@329 426 var options = {
b@336 427 title: audioholderName,
b@336 428 hAxis: {title: 'audioelement ID', minValue: 0, maxValue: audioElIdx+1,
b@329 429 ticks: tickArray},
b@329 430 vAxis: {title: 'Rating', minValue: 0, maxValue: 1},
b@329 431 seriesType: 'scatter',
b@329 432 legend: 'none'
b@329 433 };
b@329 434 var div = document.createElement('div');
b@329 435 document.body.appendChild(div);
b@336 436 div.id = 'div_'+audioholderName;
b@329 437 div.style.width = '1100px';
b@329 438 div.style.height = '350px';
b@336 439 var chart = new google.visualization.ComboChart(document.getElementById('div_'+audioholderName));
b@329 440 chart.draw(data, options);
b@329 441
b@329 442 // box plots
b@336 443 var div = document.createElement('div');
b@336 444 document.body.appendChild(div);
b@336 445 div.id = 'div_box_'+audioholderName;
b@336 446 div.style.width = '1100px';
b@336 447 div.style.height = '350px';
b@336 448 // Get median, percentiles, maximum and minimum; outliers.
b@336 449 pctl25 = [];
b@336 450 pctl75 = [];
b@336 451 med = [];
b@336 452 min = [];
b@336 453 max = [];
b@336 454 outlierArray = [];
b@336 455 max_n_outliers = 0; // maximum number of outliers for one audioelement
b@336 456 for (audioelementIndex = 0; audioelementIndex<ratings[audioholderIndex].length; audioelementIndex++){
b@336 457 med.push(median(ratings[audioholderIndex][audioelementIndex])); // median
b@336 458 pctl25.push(percentile(ratings[audioholderIndex][audioelementIndex], 25)); // 25th percentile
b@336 459 pctl75.push(percentile(ratings[audioholderIndex][audioelementIndex], 75)); // 75th percentile
b@336 460 IQR = pctl75[pctl75.length-1]-pctl25[pctl25.length-1];
b@336 461 // outliers: range of values which is above pctl75+1.5*IQR or below pctl25-1.5*IQR
b@336 462 outliers = [];
b@336 463 rest = [];
b@336 464 for (idx = 0; idx<ratings[audioholderIndex][audioelementIndex].length; idx++){
b@336 465 if (ratings[audioholderIndex][audioelementIndex][idx] > pctl75[pctl75.length-1]+1.5*IQR ||
b@336 466 ratings[audioholderIndex][audioelementIndex][idx] < pctl25[pctl25.length-1]-1.5*IQR){
b@336 467 outliers.push(ratings[audioholderIndex][audioelementIndex][idx]);
b@336 468 }
b@336 469 else {
b@336 470 rest.push(ratings[audioholderIndex][audioelementIndex][idx]);
b@336 471 }
b@336 472 }
b@336 473 outlierArray.push(outliers);
b@336 474 max_n_outliers = Math.max(max_n_outliers, outliers.length); // update max mber
b@336 475 // max: maximum value which is not outlier
b@336 476 max.push(Math.max.apply(null, rest));
b@336 477 // min: minimum value which is not outlier
b@336 478 min.push(Math.min.apply(null, rest));
b@336 479 }
b@336 480
b@336 481 // Build data array
b@336 482 boxplot_data = [['ID', 'Span', '', '', '', 'Median']];
b@336 483 for (idx = 0; idx < max_n_outliers; idx++) {
b@336 484 boxplot_data[0].push('Outlier');
b@336 485 }
b@336 486 for (audioelementIndex = 0; audioelementIndex<ratings[audioholderIndex].length; audioelementIndex++){
b@336 487 if (ratings[audioholderIndex][audioelementIndex].length>0) { // if rating array not empty for this audioelement
b@336 488 data_array = [
b@336 489 audioelementArray[audioelementIndex], // name
b@336 490 min[audioelementIndex], // minimum
b@336 491 pctl75[audioelementIndex],
b@336 492 pctl25[audioelementIndex],
b@336 493 max[audioelementIndex], // maximum
b@336 494 med[audioelementIndex]
b@336 495 ];
b@336 496 for (idx = 0; idx < max_n_outliers; idx++) {
b@336 497 if (idx<outlierArray[audioelementIndex].length){
b@336 498 data_array.push(outlierArray[audioelementIndex][idx]);
b@336 499 }
b@336 500 else {
b@336 501 data_array.push(null);
b@336 502 }
b@336 503 }
b@336 504 boxplot_data.push(data_array);
b@336 505 }
b@336 506 }
b@336 507
b@336 508 // Create and populate the data table.
b@336 509 var data = google.visualization.arrayToDataTable(boxplot_data);
b@336 510 // Create and draw the visualization.
b@336 511 var ac = new google.visualization.ComboChart(document.getElementById('div_box_'+audioholderName));
b@336 512 ac.draw(data, {
b@336 513 title : audioholderName,
b@336 514 //width: 600,
b@336 515 //height: 400,
b@336 516 vAxis: {title: "Rating"},
b@336 517 hAxis: {title: "audioelement ID"},
b@336 518 seriesType: "line",
b@336 519 pointSize: 5,
b@336 520 lineWidth: 0,
b@336 521 colors: ['black'],
b@336 522 series: { 0: {type: "candlesticks", color: 'blue'}, // box plot shape
b@336 523 1: {type: "line", pointSize: 10, lineWidth: 0, color: 'red' } }, // median
b@336 524 legend: 'none'
b@336 525 });
b@336 526 }
b@336 527 }
b@336 528
b@336 529 function makeTimeline(xmlFileName){ // WIP
b@336 530 // Based on the XML file name, take time data and plot playback and marker movements
b@336 531
b@336 532 // read XML file and check if exists
b@336 533 xml = readXML(xmlFileName);
b@336 534 if (!xml) { // if file does not exist
b@336 535 console.log('XML file '+xml+'does not exist. ('+xmlFileName+')')
b@336 536 return; // do nothing; exit function
b@336 537 }
b@336 538 // get root of XML file
b@336 539 root = xml.getElementsByTagName('browserevaluationresult')[0];
b@336 540
b@336 541 audioholder_time = 0;
b@336 542 previous_audioholder_time = 0; // time spent before current audioholder
b@336 543 time_offset = 0; // test starts at zero
b@336 544
b@336 545 // go over all audioholders
b@336 546 audioholderNodes = root.getElementsByTagName('audioholder');
b@336 547 for (audioholderIndex = 0; audioholderIndex < audioholderNodes.length; audioholderIndex++) {
b@336 548 audioholderName = audioholderNodes[audioholderIndex].getAttribute('id');
b@336 549 if (!audioholderName) {
b@336 550 console.log('audioholder name is empty; go to next one. ('+xmlFileName+')');
b@336 551 break;
b@336 552 }
b@336 553
b@336 554 // subtract total audioholder length from subsequent audioholder event times
b@336 555 audioholder_children = audioholderNodes[audioholderIndex].childNodes;
b@336 556 foundIt = false;
b@336 557 console.log(audioholder_children[2].getElementsByTagName("metricResult")) // not working!
b@336 558 for (idx = 0; idx<audioholder_children.length; idx++) { // go over children
b@336 559
b@336 560 if (audioholder_children[idx].getElementsByTagName('metricResult').length) {
b@336 561 console.log(audioholder_children[idx].getElementsByTagName('metricResult')[0]);
b@336 562 if (audioholder_children[idx].getElementsByTagName('metricResult')[0].getAttribute('id') == "testTime"){
b@336 563 audioholder_time = parseFloat(audioholder_children[idx].getElementsByTagName('metricResult')[0].textContent);
b@336 564 console.log(audioholder_time);
b@336 565 foundIt = true;
b@336 566 }
b@336 567 }
b@336 568 }
b@336 569 if (!foundIt) {
b@336 570 console.log("Skipping audioholder without total time specified from "+xmlFileName+"."); // always hitting this
b@336 571 break;
b@336 572 }
b@336 573
b@336 574 audioelementNodes = audioholderNodes[audioholderIndex].getElementsByTagName('audioelement');
b@336 575
b@336 576 // make div
b@336 577
b@336 578 // draw chart
b@336 579
b@336 580 // legend with audioelement names
b@329 581 }
b@329 582 }
b@329 583
b@329 584 </script>
b@329 585
b@329 586
b@329 587
b@329 588 <style>
b@329 589 div {
b@329 590 padding: 2px;
b@329 591 margin-top: 2px;
b@329 592 margin-bottom: 2px;
b@329 593 }
b@329 594 div.head{
b@329 595 margin-left: 10px;
b@329 596 border: black;
b@329 597 border-width: 2px;
b@329 598 border-style: solid;
b@329 599 }
b@329 600 div.attrib{
b@329 601 margin-left:25px;
b@329 602 border: black;
b@329 603 border-width: 2px;
b@329 604 border-style: dashed;
b@329 605 margin-bottom: 10px;
b@329 606 }
b@329 607 div#headerMatter{
b@329 608 background-color: #FFFFCC;
b@329 609 }
b@329 610 div#currentStatement{
b@329 611 font-size:3.0em;
b@329 612 font-weight: bold;
b@329 613
b@329 614 }
b@329 615 div#debugDisplay {
b@329 616 color: #CCCCCC;
b@329 617 font-size:0.3em;
b@329 618 }
b@329 619 span#scoreDisplay {
b@329 620 font-weight: bold;
b@329 621 }
b@329 622 div#wrapper {
b@329 623 width: 780px;
b@329 624 border: 1px solid black;
b@329 625 overflow: hidden; /* add this to contain floated children */
b@329 626 }
b@329 627 div#instrumentSection {
b@336 628 width: 250px;
b@336 629 border: 1px solid red;
b@336 630 display: inline-block;
b@329 631 }
b@329 632 div#featureSection {
b@329 633 width: 250px;
b@336 634 border: 1px solid green;
b@336 635 display: inline-block;
b@329 636 }
b@329 637 div#valenceSection {
b@329 638 width: 250px;
b@336 639 border: 1px solid blue;
b@336 640 display: inline-block;
b@329 641 }
b@329 642 button#previousComment{
b@329 643 width: 120px;
b@329 644 height: 150px;
b@329 645 font-size:1.5em;
b@329 646 }
b@329 647 button#nextComment{
b@329 648 width: 666px;
b@329 649 height: 150px;
b@329 650 font-size:1.5em;
b@329 651 }
b@329 652 ul
b@329 653 {
b@329 654 list-style-type: none; /* no bullet points */
b@329 655 margin-left: -20px; /* less indent */
b@329 656 margin-top: 0px;
b@329 657 margin-bottom: 5px;
b@329 658 }
b@329 659 </style>
b@329 660
b@329 661 </head>
b@329 662
b@329 663 <body>
b@329 664 <h1>Subjective evaluation results</h1>
b@329 665
b@329 666 <div id="debugDisplay">
b@329 667 XML file folder: <span id="xmlFileFolder_span"></span>
b@329 668 </div>
b@329 669
b@329 670 <div id="headerMatter">
b@329 671 <div>
b@329 672 <strong>Result XML files:</strong> <span id="numberOfFiles_span"></span>
b@329 673 </div>
b@329 674 <div>
b@336 675 <strong>Audioholders in dataset:</strong> <span id="audioholderArray_span"></span>
b@329 676 </div>
b@329 677 <div>
b@329 678 <strong>Subjects in dataset:</strong> <span id="subjectArray_span"></span>
b@329 679 </div>
b@329 680 <div>
b@336 681 <strong>Audioelements in dataset:</strong> <span id="audioelementArray_span"></span>
b@329 682 </div>
b@329 683 <br>
b@329 684 </div>
b@329 685 <br>
b@329 686
b@329 687 <!-- Show time elapsed
b@329 688 The last annotation took <strong><span id="timeDisplay">(N/A)</span></strong> seconds.
b@329 689 <br>-->
b@329 690
b@329 691 </body>
b@329 692 </html>