Press "p" to play/pause frame animation

Press "e" to play/pause ecg animation

Press "+/-" to change frame rate

          
          

let demoFiles = []; // init all larvitar.initializeImageLoader(); larvitar.registerMultiFrameImageLoader(); larvitar.initializeCSTools(); larvitar.store.initialize(); larvitar.store.addViewport("viewer"); function renderSerie() { larvitar.readFiles(demoFiles).then(seriesStack => { let seriesId = _.keys(seriesStack)[0]; let serie = seriesStack[seriesId]; larvitar.populateLarvitarManager(seriesId, serie); let manager = larvitar.getLarvitarManager(); let multiFrameSerie = manager[seriesId]; let frameId = 0; // check if the series has waveform data if (multiFrameSerie.waveform) { larvitar.parseECG(seriesId, manager[seriesId].dataSet, "x50003000"); } larvitar.renderImage(multiFrameSerie, "viewer", frameId).then(() => { console.log("Image has been rendered"); larvitar.addDefaultTools(); let animation = false; let animationId = null; let numberOfFrames = multiFrameSerie.numberOfFrames; let frameTime = multiFrameSerie.frameTime; // generate trace data and render the ECG const trace_data = larvitar.renderECG( manager[seriesId].ecgData, "ecg", "red", numberOfFrames, frameTime, 0 ); // save trace data in the manager for futrue use manager[seriesId].trace_data = trace_data; // sync the ECG frame with the image frame larvitar.syncECGFrame( trace_data, seriesId, "viewer", numberOfFrames, "ecg" ); let frameRate = multiFrameSerie.frameTime; $("#frame-rate").html("Frame Rate: " + parseInt(frameRate) + "ms"); $("#current-frame").html("Current Frame: 1 of " + numberOfFrames); document.onkeypress = function (e) { e = e || window.event; if (e.keyCode == 112) { animation = !animation; if (animation) { frameId = larvitar.store.get([ "viewports", "viewer", "sliceId" ]); animationId = setInterval(function () { let series = larvitar.getSeriesDataFromLarvitarManager(seriesId); frameId = frameId == numberOfFrames - 1 ? 0 : frameId + 1; larvitar.updateImage(series, "viewer", frameId, false); larvitar.updateStackToolState("viewer", frameId); $("#current-frame").html( "Current Frame: " + parseInt(frameId + 1) + " of " + numberOfFrames ); larvitar.updateECGMarker( trace_data, frameId, numberOfFrames, "ecg" ); }, frameRate); } else { clearInterval(animationId); $("#current-frame").html(); } } }; }); }); } async function createFile(fileName, cb) { let response = await fetch("./demo/" + fileName); let data = await response.blob(); let file = new File([data], fileName); demoFiles.push(file); cb(); } createFile("119265", renderSerie);