Skip to content

Commit

Permalink
[UPDATE] Index Server closes #95 closes #77 closes #81 closes #82 clo…
Browse files Browse the repository at this point in the history
…ses #
  • Loading branch information
FMCalisto committed Dec 11, 2018
1 parent 8b0435b commit ac7c299
Show file tree
Hide file tree
Showing 72 changed files with 5,124 additions and 363 deletions.
2 changes: 1 addition & 1 deletion src/client/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ body {

.overlay {
position: absolute;
color: #f1c40f;
color: #75736c;
}

.imageViewer {
Expand Down
34 changes: 23 additions & 11 deletions src/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ $.getJSON(studyListFile, function(data) {
console.log("Creating study list tables...");
// Create one table row for each study in the manifest
var studyRow = '<tr><td>' +
//study.patientId + '</td><td>' +
study.internalId + '</td><td>' +
study.patientId + '</td><td>' +
//study.internalId + '</td><td>' +
study.studyDate + '</td><td>' +
study.modality + '</td><td>' +
study.studyDescription + '</td><td>' +
Expand All @@ -78,13 +78,16 @@ $.getJSON(studyListFile, function(data) {

// On study list row click
$(studyRowElement).click(function() {

// var session = require('client-sessions');

if ($('#tabs li').length >= 2) {
alert('Please close the opened patient first !');
} else {
// Add new tab for this study and switch to it
//var studyTab = '<li><div id=complete-tab><a href="#x' + study.patientId + '" data-toggle="tab">' + study.patientId + '</a>' +
var studyTab = '<li><div id=complete-tab><a href="#x' + study.patientId + '" data-toggle="tab">' + study.internalId + '</a>' +
'<input type="button" class="closeBtn" value="X" />' + '</li></div>';
var studyTab = '<li><div id=complete-tab><a href="#x' + study.patientId + '" data-toggle="tab">' + study.patientId + '</a>' +
//var studyTab = '<li><div id=complete-tab><a href="#x' + study.patientId + '" data-toggle="tab">' + study.internalId + '</a>' +
'<input id="close" href="#" type="button" class="closeBtn" value="X" />' +'<span id="modifiedStar" style="color: white;padding-left: 2px; display:none;">*</span>' + '</li></div>'; ///fmc
$('#tabs').append(studyTab);
// Add tab content by making a copy of the studyViewerTemplate element
var studyViewerCopy = studyViewerTemplate.clone();
Expand All @@ -108,19 +111,28 @@ $.getJSON(studyListFile, function(data) {
});

studyViewerCopy.roiData = {

patientId: study.patientId,
patientName : study.patientName,
studyId: study.studyId,
modality: study.modality,
stacks: [],
};

$('.closeBtn').click(function() {
var element = this.parentNode.parentNode;
$('#tabs a:first').tab('show');
element.remove();
var tabDataElement = element.firstChild.firstChild.getAttribute('href');
if($(tabDataElement).length > 0){
$(tabDataElement)[0].remove();
if($('#modifiedStar').css('display') == 'inline')
{
$('#saveModal').modal('show');
} else {
$('#tabs a:first').tab('show');
element.remove();
var tabDataElement = element.firstChild.firstChild.getAttribute('href');
if($(tabDataElement).length > 0) {
$(tabDataElement)[0].remove();
}
}

});

// Now load the study.json
Expand All @@ -146,7 +158,7 @@ $('#tabs a').click (function(e) {
function resizeMain() {
var height = $(window).height();
$('#main').height(height - 50);
$('#tabContent').height(height - 50 - 42);
$('#tabContent').height(height - 100 - 42);
}

// Call resize main on window resize
Expand Down
1 change: 1 addition & 0 deletions src/client/lib/cornerstone.js
Original file line number Diff line number Diff line change
Expand Up @@ -1809,6 +1809,7 @@ if(typeof cornerstone === 'undefined'){
if(enabledElement.image === undefined) {
throw "updateImage: image has not been loaded yet";
}
$('.loader').css('display', 'none');

cornerstone.drawImage(enabledElement, invalidated);
}
Expand Down
89 changes: 43 additions & 46 deletions src/client/lib/cornerstoneTools.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,5 @@
/**
* @file The cornerstoneTools is a library built on
* top of cornerstone that provides a set of
* common tools needed in medical imaging to
* work with images and stacks of images. The
* hereby file is a modified version of v0.7.2
* from the official cornerstoneTools library.
* The base code was made by (c) 2014 Chris Hafey
* at 2015-09-07 and modified by Francisco Maria
* Calisto during the developement of the MIMBCD-UI
* Project and the respective BreastScreening
* prototypes, systems and assitants.
*
* @desc Cornerstone.js provides a rock solid foundation
* for creating a web medical image viewer. However,
* it is purposefully light weight and extensible. After
* configuring an image loader (getting your images
* to display), the next thing you'll want to do is
* manipulate those images, apply annotations, and
* provide additional tools for diagnosis and
* research. CornerstoneTools sets out to provide
* tools for these common use cases.
*
* @version 0.7.2
*
* @author Chris Hafey
* <chafey@gmail.com>
* @author Francisco Maria Calisto
* <francisco.calisto@tecnico.ulisboa.pt>
*/

/*! cornerstoneTools - v0.7.2 - 2015-09-07 | (c) 2014 Chris Hafey | https://github.com/chafey/cornerstoneTools */
// Begin Source: src/header.js

if (typeof cornerstone === 'undefined') {
cornerstone = {};
}
Expand All @@ -47,7 +16,6 @@ if (typeof cornerstoneTools === 'undefined') {
(function($, cornerstone, cornerstoneTools) {

'use strict';

function mouseWheel(e) {
// !!!HACK/NOTE/WARNING!!!
// for some reason I am getting mousewheel and DOMMouseScroll events on my
Expand All @@ -70,10 +38,24 @@ if (typeof cornerstoneTools === 'undefined') {
var direction = Math.max(-1, Math.min(1, (wheelDelta)));

var mouseWheelData = {
element: element, viewport: cornerstone.getViewport(element), image: cornerstone.getEnabledElement(element).image, direction: direction, pageX: e.pageX || e.originalEvent.pageX, pageY: e.pageY || e.originalEvent.pageY, imageX: startingCoords.x, imageY: startingCoords.y
element: element,
viewport: cornerstone.getViewport(element),
image: cornerstone.getEnabledElement(element).image,
direction: direction,
pageX: e.pageX || e.originalEvent.pageX,
pageY: e.pageY || e.originalEvent.pageY,
imageX: startingCoords.x,
imageY: startingCoords.y
};
// $(element).scale = 0.1;
// var canvas = document.getElementsByTagName('canvas')[3];
// var ctx = canvas.getContext('2d');
// console.log(ctx);
// ctx.scale(2,2);

// cornerstoneTools.changeViewportScale(element);
$(element).trigger('CornerstoneToolsMouseWheel', mouseWheelData);
// triggerEvent(element, EVENTS.MOUSE_WHEEL, mouseWheelData);
}

var mouseWheelEvents = 'mousewheel DOMMouseScroll';
Expand All @@ -83,16 +65,20 @@ if (typeof cornerstoneTools === 'undefined') {
}

function disable(element) {
$(element).unbind(mouseWheelEvents, mouseWheel);
// $(element).unbind(mouseWheelEvents, mouseWheel);
disable(element);//fmc
mouseWheelEvents.forEach((eventType) => {
element.addEventListener(eventType, mouseWheel);
});
}

// module exports
cornerstoneTools.mouseWheelInput = {
enable: enable, disable: disable
enable: enable,
disable: disable
};

})($, cornerstone, cornerstoneTools);

// End Source; src/inputSources/mouseWheelInput.js

// Begin Source: src/inputSources/mouseInput.js
Expand Down Expand Up @@ -634,20 +620,20 @@ if (typeof cornerstoneTools === 'undefined') {

'use strict';

function simpleMouseButtonTool(mouseDownCallback) {
function simpleMouseButtonTool(mouseWheelCallback) {
var configuration = {};

var toolInterface = {
activate: function(element, mouseButtonMask, options) {
$(element).off('CornerstoneToolsMouseDownActivate', mouseDownCallback);
$(element).off('CornerstoneToolsMouseDownActivate', mouseWheelCallback);
var eventData = {
mouseButtonMask: mouseButtonMask, options: options
};
$(element).on('CornerstoneToolsMouseDownActivate', eventData, mouseDownCallback);
$(element).on('CornerstoneToolsMouseDownActivate', eventData, mouseWheelCallback);
},
disable: function(element) {$(element).off('CornerstoneToolsMouseDownActivate', mouseDownCallback);},
enable: function(element) {$(element).off('CornerstoneToolsMouseDownActivate', mouseDownCallback);},
deactivate: function(element) {$(element).off('CornerstoneToolsMouseDownActivate', mouseDownCallback);},
disable: function(element) {$(element).off('CornerstoneToolsMouseDownActivate', mouseWheelCallback);},
enable: function(element) {$(element).off('CornerstoneToolsMouseDownActivate', mouseWheelCallback);},
deactivate: function(element) {$(element).off('CornerstoneToolsMouseDownActivate', mouseWheelCallback);},
getConfiguration: function() { return configuration;},
setConfiguration: function(config) {configuration = config;}
};
Expand Down Expand Up @@ -4795,8 +4781,9 @@ if (typeof cornerstoneTools === 'undefined') {

var startPoints;

function changeViewportScale(viewport, ticks) {
function changeViewportScale(viewport, ticks) {////////fmc zoom
var config = cornerstoneTools.zoom.getConfiguration();
// console.log(config);
var pow = 1.7;

var oldFactor = Math.log(viewport.scale) / Math.log(pow);
Expand Down Expand Up @@ -4955,7 +4942,7 @@ if (typeof cornerstoneTools === 'undefined') {
$(eventData.element).off('CornerstoneToolsMouseUp', mouseUpCallback);
}

function mouseDownCallback(e, eventData) {
function mouseDownCallback(e, eventData) {//fmc zoom mousedown
if (cornerstoneTools.isMouseButtonEnabled(eventData.which, e.data.mouseButtonMask)) {
startPoints = eventData.startPoints; // Used for translateStrategy
$(eventData.element).on('CornerstoneToolsMouseDrag', dragCallback);
Expand Down Expand Up @@ -5015,7 +5002,15 @@ if (typeof cornerstoneTools === 'undefined') {
e = window.event || e; // old IE support

var keyPressData = {
element: element, viewport: cornerstone.getViewport(element), image: cornerstone.getEnabledElement(element).image, pageX: mouseX, pageY: mouseY, imageX: startingCoords.x, imageY: startingCoords.y, keyCode: e.keyCode, which: e.which
element: element,
viewport: cornerstone.getViewport(element),
image: cornerstone.getEnabledElement(element).image,
pageX: mouseX,
pageY: mouseY,
imageX: startingCoords.x,
imageY: startingCoords.y,
keyCode: e.keyCode,
which: e.which
};

if (e.type === 'keydown') {
Expand Down Expand Up @@ -5074,6 +5069,7 @@ if (typeof cornerstoneTools === 'undefined') {

function handleTap(type, e) {
var now = Date.now();
// console.log(now);//fmc
if (type !== lastInteractionType) {
if (now - lastInteractionTime <= antiGhostDelay) {
e.preventDefault();
Expand Down Expand Up @@ -8561,6 +8557,7 @@ Display scroll progress bar across bottom of image.
/*jshint bitwise: false*/
var mouseButton = (1 << (which - 1));
return ((mouseButtonMask & mouseButton) !== 0);
// return (true);
}

// module exports
Expand Down
49 changes: 49 additions & 0 deletions src/client/lib/events.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const EVENTS = {
// Events from Cornerstone Core
IMAGE_RENDERED: 'cornerstoneimagerendered',
NEW_IMAGE: 'cornerstonenewimage',
IMAGE_CACHE_PROMISE_REMOVED: 'cornerstoneimagecachepromiseremoved',
ELEMENT_DISABLED: 'cornerstoneelementdisabled',

// Mouse events
MOUSE_DOWN: 'cornerstonetoolsmousedown',
MOUSE_UP: 'cornerstonetoolsmouseup',
MOUSE_DOWN_ACTIVATE: 'cornerstonetoolsmousedownactivate',
MOUSE_DRAG: 'cornerstonetoolsmousedrag',
MOUSE_MOVE: 'cornerstonetoolsmousemove',
MOUSE_CLICK: 'cornerstonetoolsmouseclick',
MOUSE_DOUBLE_CLICK: 'cornerstonetoolsmousedoubleclick',
MOUSE_WHEEL: 'cornerstonetoolsmousewheel',

// Touch events
TOUCH_START: 'cornerstonetoolstouchstart',
TOUCH_START_ACTIVE: 'cornerstonetoolstouchstartactive',
TOUCH_END: 'cornerstonetoolstouchend',
TOUCH_DRAG: 'cornerstonetoolstouchdrag',
TOUCH_DRAG_END: 'cornerstonetoolstouchdragend',
TOUCH_PINCH: 'cornerstonetoolstouchpinch',
TOUCH_ROTATE: 'cornerstonetoolstouchrotate',
TOUCH_PRESS: 'cornerstonetoolstouchpress',
TAP: 'cornerstonetoolstap',
DOUBLE_TAP: 'cornerstonetoolsdoubletap',
MULTI_TOUCH_START: 'cornerstonetoolsmultitouchstart',
MULTI_TOUCH_START_ACTIVE: 'cornerstonetoolsmultitouchstartactive',
MULTI_TOUCH_DRAG: 'cornerstonetoolsmultitouchdrag',

// Keyboard events
KEY_DOWN: 'cornerstonetoolskeydown',
KEY_UP: 'cornerstonetoolskeyup',
KEY_PRESS: 'cornerstonetoolskeypress',

// Measurement / tool events
MEASUREMENT_ADDED: 'cornerstonetoolsmeasurementadded',
MEASUREMENT_MODIFIED: 'cornerstonetoolsmeasurementmodified',
MEASUREMENT_REMOVED: 'cornerstonemeasurementremoved',
TOOL_DEACTIVATED: 'cornerstonetoolstooldeactivated',
CLIP_STOPPED: 'cornerstonetoolsclipstopped',
STACK_SCROLL: 'cornerstonestackscroll', // Should be renamed

LINE_SAMPLE_UPDATED: 'cornerstonelinesampleupdated'
};

export default EVENTS;
24 changes: 24 additions & 0 deletions src/client/lib/externalModules.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
let cornerstone = window.cornerstone;
let cornerstoneMath = window.cornerstoneMath;
let Hammer = window.Hammer;

export default {
set cornerstone (cs) {
cornerstone = cs;
},
get cornerstone () {
return cornerstone;
},
set cornerstoneMath (cm) {
cornerstoneMath = cm;
},
get cornerstoneMath () {
return cornerstoneMath;
},
set Hammer (module) {
Hammer = module;
},
get Hammer () {
return Hammer;
}
};
2 changes: 0 additions & 2 deletions src/client/lib/md5.min.js

This file was deleted.

46 changes: 46 additions & 0 deletions src/client/lib/util/calculateEllipseStatistics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import pointInEllipse from './pointInEllipse.js';

export default function (sp, ellipse) {
// TODO: Get a real statistics library here that supports large counts

let sum = 0;
let sumSquared = 0;
let count = 0;
let index = 0;

for (let y = ellipse.top; y < ellipse.top + ellipse.height; y++) {
for (let x = ellipse.left; x < ellipse.left + ellipse.width; x++) {
const point = {
x,
y
};

if (pointInEllipse(ellipse, point)) {
sum += sp[index];
sumSquared += sp[index] * sp[index];
count++;
}

index++;
}
}

if (count === 0) {
return {
count,
mean: 0.0,
variance: 0.0,
stdDev: 0.0
};
}

const mean = sum / count;
const variance = sumSquared / count - mean * mean;

return {
count,
mean,
variance,
stdDev: Math.sqrt(variance)
};
}
Loading

0 comments on commit ac7c299

Please sign in to comment.