Fixed bug LT-85 (Location Response Selections). Work on LT-9 and LT-12
This commit is contained in:
parent
28cee350ff
commit
220ff065dc
@ -14,9 +14,16 @@ Meteor.startup(function() {
|
||||
touch: cornerstoneTools.biDirectionalTouch
|
||||
});
|
||||
|
||||
toolManager.addTool('deleteLesionKeyboardTool', {
|
||||
mouse: cornerstoneTools.deleteLesionKeyboardTool,
|
||||
touch: cornerstoneTools.deleteLesionKeyboardTool
|
||||
});
|
||||
|
||||
var states = toolManager.getToolDefaultStates();
|
||||
states.deactivate.push('lesion');
|
||||
states.deactivate.push('nonTarget');
|
||||
|
||||
states.deactivate.push('biDirectional');
|
||||
|
||||
states.activate.push('deleteLesionKeyboardTool');
|
||||
toolManager.setToolDefaultStates(states);
|
||||
});
|
||||
@ -1,7 +1,9 @@
|
||||
<template name="viewer">
|
||||
<div id="viewer">
|
||||
{{>confirmDeleteDialog}}
|
||||
{{>lesionLocationDialog}}
|
||||
{{>nonTargetLesionDialog}}
|
||||
{{>nonTargetResponseDialog}}
|
||||
{{>timepointTextDialog}}
|
||||
|
||||
{{>hidingPanel}}
|
||||
|
||||
@ -52,9 +52,6 @@ Template.viewer.onCreated(function() {
|
||||
OHIF.viewer.defaultHotkeys.lesion = "T"; // Target
|
||||
OHIF.viewer.defaultHotkeys.nonTarget = "N"; // Non-target
|
||||
|
||||
// Enable hotkeys
|
||||
enableHotkeys();
|
||||
|
||||
if (isTouchDevice()) {
|
||||
OHIF.viewer.tooltipConfig = {
|
||||
trigger: 'manual'
|
||||
@ -101,66 +98,111 @@ Template.viewer.onCreated(function() {
|
||||
self.subscribe('timepoints', patientId);
|
||||
self.subscribe('measurements', patientId);
|
||||
|
||||
if (!self.subscriptionsReady()) {
|
||||
return;
|
||||
if (self.subscriptionsReady()) {
|
||||
ViewerStudies.find().observe({
|
||||
added: function(study) {
|
||||
// TODO = Replace this whole section when we have a
|
||||
// timepoint-to-study association modal
|
||||
|
||||
// First, check if we have a timepoint related to this
|
||||
// study date already
|
||||
var timepoint = Timepoints.findOne({
|
||||
timepointName: study.studyDate
|
||||
});
|
||||
|
||||
// If we do, stop here
|
||||
if (timepoint) {
|
||||
log.warn("A timepoint with that study date already exists!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Next, check the first timepoint in the collection
|
||||
var testTimepoint = Timepoints.findOne({});
|
||||
|
||||
// If it relates to another subject, we need to stop here as well
|
||||
// because the tab may be changing.
|
||||
if (testTimepoint && testTimepoint.patientId !== study.patientId) {
|
||||
log.warn("Timepoints collection related to the wrong subject");
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, we need to add a timepoint related to this study date
|
||||
log.info('Inserting a new timepoint');
|
||||
Timepoints.insert({
|
||||
patientId: study.patientId,
|
||||
timepointName: study.studyDate,
|
||||
timepointID: uuid.v4()
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// This is used to re-add tools from the database into the
|
||||
// Cornerstone ToolData structure
|
||||
Measurements.find().observe({
|
||||
added: function(data) {
|
||||
if (data.toolDataInsertedManually === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Activate first measurements in image box as default if exists
|
||||
if (!firstMeasurementsActivated) {
|
||||
var templateData = {
|
||||
contentId: Session.get("activeContentId")
|
||||
};
|
||||
|
||||
// Activate measurement
|
||||
activateLesion(data._id, templateData);
|
||||
firstMeasurementsActivated = true;
|
||||
}
|
||||
|
||||
log.info('Measurement added');
|
||||
|
||||
addMeasurementAsToolData(data);
|
||||
|
||||
updateRelatedElements(data.imageId);
|
||||
},
|
||||
removed: function(data) {
|
||||
// Check that this Measurement actually contains timepoint data
|
||||
if (!data.timepoints) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the Measurement ID and relevant tool so we can remove
|
||||
// tool data for this Measurement
|
||||
var measurementId = data._id;
|
||||
var toolType = data.isTarget ? 'lesion' : 'nonTarget';
|
||||
|
||||
// Find the list of imageIds that needs to be updated
|
||||
var imageIds = [];
|
||||
Object.keys(data.timepoints).forEach(function(timepointID) {
|
||||
// Clear the toolData for this timepoint
|
||||
var imageId = data.timepoints[timepointID].imageId;
|
||||
removeToolDataWithMeasurementId(imageId, toolType, measurementId);
|
||||
|
||||
// Add this imageId to the list to be updated
|
||||
// (if they are currently displayed)
|
||||
imageIds.push(imageId);
|
||||
});
|
||||
|
||||
// Find the enabled Cornerstone elements currently displaying these image IDs
|
||||
var enabledElements = [];
|
||||
imageIds.forEach(function(imageId) {
|
||||
var elems = cornerstone.getEnabledElementsByImageId(imageId);
|
||||
enabledElements = enabledElements.concat(elems);
|
||||
});
|
||||
|
||||
// Update each related viewport
|
||||
enabledElements.forEach(function(enabledElement) {
|
||||
// Skip thumbnails or other elements that are not primary viewports
|
||||
var element = enabledElement.element;
|
||||
if (!element.classList.contains('imageViewerViewport')) {
|
||||
return;
|
||||
}
|
||||
cornerstone.updateImage(element);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ViewerStudies.find().observe({
|
||||
added: function(study) {
|
||||
var timepoint = Timepoints.findOne({timepointName: study.studyDate});
|
||||
if (timepoint) {
|
||||
log.warn("A timepoint with that study date already exists!");
|
||||
return;
|
||||
}
|
||||
|
||||
var timepointID = uuid.v4();
|
||||
|
||||
var testTimepoint = Timepoints.findOne({});
|
||||
if (testTimepoint && testTimepoint.patientId !== study.patientId) {
|
||||
log.warn("Timepoints collection related to the wrong subject");
|
||||
return;
|
||||
}
|
||||
|
||||
log.info('Inserting a new timepoint');
|
||||
Timepoints.insert({
|
||||
patientId: study.patientId,
|
||||
timepointID: timepointID,
|
||||
timepointName: study.studyDate
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// This is used to re-add tools from the database into the
|
||||
// Cornerstone ToolData structure
|
||||
Measurements.find().observe({
|
||||
added: function (data) {
|
||||
if (data.toolDataInsertedManually === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Activate first measurements in image box as default if exists
|
||||
if (!firstMeasurementsActivated) {
|
||||
var templateData = {contentId: Session.get("activeContentId")};
|
||||
// Activate measurement
|
||||
activateLesion(data._id, templateData);
|
||||
firstMeasurementsActivated = true;
|
||||
}
|
||||
|
||||
log.info('Measurement added');
|
||||
|
||||
addMeasurementAsToolData(data);
|
||||
|
||||
updateRelatedElements(data.imageId);
|
||||
},
|
||||
changed: function(data) {
|
||||
log.info('Measurement changed');
|
||||
updateRelatedElements(data.imageId);
|
||||
},
|
||||
removed: function(data) {
|
||||
log.info('Measurement removed');
|
||||
updateRelatedElements(data.imageId);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
OHIF.viewer.updateImageSynchronizer = new cornerstoneTools.Synchronizer("CornerstoneNewImage", cornerstoneTools.updateImageSynchronizer);
|
||||
@ -252,6 +294,11 @@ function addMeasurementAsToolData(data) {
|
||||
});
|
||||
}
|
||||
|
||||
Template.viewer.onRendered(function() {
|
||||
// Enable hotkeys
|
||||
enableHotkeys();
|
||||
});
|
||||
|
||||
Template.viewer.onDestroyed(function() {
|
||||
log.info("onDestroyed");
|
||||
|
||||
@ -277,7 +324,7 @@ function handleMeasurementModified(e, eventData) {
|
||||
switch (eventData.toolType) {
|
||||
case 'nonTarget':
|
||||
case 'lesion':
|
||||
measurementManagerDAL.updateTimepointData(measurementData);
|
||||
LesionManager.updateLesionData(measurementData);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -285,18 +332,19 @@ function handleMeasurementModified(e, eventData) {
|
||||
function handleMeasurementRemoved(e, eventData) {
|
||||
log.info('CornerstoneToolsMeasurementRemoved');
|
||||
var measurementData = eventData.measurementData;
|
||||
var databaseEntry;
|
||||
|
||||
switch (eventData.toolType) {
|
||||
case 'nonTarget':
|
||||
case 'lesion':
|
||||
databaseEntry = Measurements.findOne(measurementData.id, {reactive: false});
|
||||
if (!databaseEntry) {
|
||||
var measurement = Measurements.findOne(measurementData.id, {
|
||||
reactive: false
|
||||
});
|
||||
|
||||
if (!measurement) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO= Fix this when we have Findings that relate to more than one viewport
|
||||
Measurements.remove(databaseEntry._id);
|
||||
clearMeasurementTimepointData(measurement._id, measurementData.timepointID);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
/*! cornerstoneTools - v0.7.7 - 2015-11-26 | (c) 2014 Chris Hafey | https://github.com/chafey/cornerstoneTools */
|
||||
/*! cornerstoneTools - v0.7.7 - 2015-12-18 | (c) 2014 Chris Hafey | https://github.com/chafey/cornerstoneTools */
|
||||
// Begin Source: src/header.js
|
||||
if (typeof cornerstone === 'undefined') {
|
||||
cornerstone = {};
|
||||
@ -56,6 +56,9 @@ if (typeof cornerstoneTools === 'undefined') {
|
||||
var mouseWheelEvents = 'mousewheel DOMMouseScroll';
|
||||
|
||||
function enable(element) {
|
||||
// Prevent handlers from being attached multiple times
|
||||
disable(element);
|
||||
|
||||
$(element).on(mouseWheelEvents, mouseWheel);
|
||||
}
|
||||
|
||||
@ -897,6 +900,13 @@ if (typeof cornerstoneTools === 'undefined') {
|
||||
handleMover = cornerstoneTools.moveNewHandle;
|
||||
}
|
||||
|
||||
var preventHandleOutsideImage;
|
||||
if (mouseToolInterface.options.preventHandleOutsideImage !== undefined) {
|
||||
preventHandleOutsideImage = mouseToolInterface.options.preventHandleOutsideImage;
|
||||
} else {
|
||||
preventHandleOutsideImage = false;
|
||||
}
|
||||
|
||||
handleMover(mouseEventData, mouseToolInterface.toolType, measurementData, measurementData.handles.end, function() {
|
||||
measurementData.active = false;
|
||||
measurementData.invalidated = true;
|
||||
@ -914,7 +924,7 @@ if (typeof cornerstoneTools === 'undefined') {
|
||||
}
|
||||
|
||||
cornerstone.updateImage(element);
|
||||
});
|
||||
}, preventHandleOutsideImage);
|
||||
}
|
||||
|
||||
function mouseDownActivateCallback(e, eventData) {
|
||||
@ -994,6 +1004,14 @@ if (typeof cornerstoneTools === 'undefined') {
|
||||
|
||||
// now check to see if there is a handle we can move
|
||||
if (toolData) {
|
||||
|
||||
var preventHandleOutsideImage;
|
||||
if (mouseToolInterface.options && mouseToolInterface.options.preventHandleOutsideImage !== undefined) {
|
||||
preventHandleOutsideImage = mouseToolInterface.options.preventHandleOutsideImage;
|
||||
} else {
|
||||
preventHandleOutsideImage = false;
|
||||
}
|
||||
|
||||
for (i = 0; i < toolData.data.length; i++) {
|
||||
data = toolData.data[i];
|
||||
var distanceSq = 25;
|
||||
@ -1001,7 +1019,7 @@ if (typeof cornerstoneTools === 'undefined') {
|
||||
if (handle) {
|
||||
$(element).off('CornerstoneToolsMouseMove', mouseToolInterface.mouseMoveCallback || mouseMoveCallback);
|
||||
data.active = true;
|
||||
cornerstoneTools.moveHandle(eventData, mouseToolInterface.toolType, data, handle, handleDoneMove);
|
||||
cornerstoneTools.moveHandle(eventData, mouseToolInterface.toolType, data, handle, handleDoneMove, preventHandleOutsideImage);
|
||||
e.stopImmediatePropagation();
|
||||
return false;
|
||||
}
|
||||
@ -1011,7 +1029,7 @@ if (typeof cornerstoneTools === 'undefined') {
|
||||
// Now check to see if there is a line we can move
|
||||
// now check to see if we have a tool that we can move
|
||||
if (toolData && mouseToolInterface.pointNearTool) {
|
||||
var options = {
|
||||
var options = mouseToolInterface.options || {
|
||||
deleteIfHandleOutsideImage: true,
|
||||
preventHandleOutsideImage: false
|
||||
};
|
||||
@ -2452,7 +2470,14 @@ if (typeof cornerstoneTools === 'undefined') {
|
||||
startLoadingHandler(targetElement);
|
||||
}
|
||||
|
||||
cornerstone.loadAndCacheImage(stackData.imageIds[newImageIdIndex]).then(function(image) {
|
||||
var loader;
|
||||
if (stackData.preventCache === true) {
|
||||
loader = cornerstone.loadImage(stackData.imageIds[newImageIdIndex]);
|
||||
} else {
|
||||
loader = cornerstone.loadAndCacheImage(stackData.imageIds[newImageIdIndex]);
|
||||
}
|
||||
|
||||
loader.then(function(image) {
|
||||
var viewport = cornerstone.getViewport(targetElement);
|
||||
stackData.currentImageIdIndex = newImageIdIndex;
|
||||
cornerstone.displayImage(targetElement, image, viewport);
|
||||
@ -3214,8 +3239,13 @@ if (typeof cornerstoneTools === 'undefined') {
|
||||
var data = toolData.data[config.currentTool];
|
||||
|
||||
// Set the mouseLocation handle
|
||||
config.mouseLocation.handles.start.x = eventData.currentPoints.image.x;
|
||||
config.mouseLocation.handles.start.y = eventData.currentPoints.image.y;
|
||||
var x = Math.max(eventData.currentPoints.image.x, 0);
|
||||
x = Math.min(x, eventData.image.width);
|
||||
config.mouseLocation.handles.start.x = x;
|
||||
|
||||
var y = Math.max(eventData.currentPoints.image.y, 0);
|
||||
y = Math.min(y, eventData.image.height);
|
||||
config.mouseLocation.handles.start.y = y;
|
||||
|
||||
var currentHandle = config.currentHandle;
|
||||
|
||||
@ -5943,29 +5973,33 @@ if (typeof cornerstoneTools === 'undefined') {
|
||||
|
||||
function keyPress(e) {
|
||||
var element = e.currentTarget;
|
||||
var startingCoords = cornerstone.pageToPixel(element, mouseX, mouseY);
|
||||
|
||||
e = window.event || e; // old IE support
|
||||
|
||||
var keyPressData = {
|
||||
event: window.event || e, // old IE support
|
||||
element: element,
|
||||
viewport: cornerstone.getViewport(element),
|
||||
image: cornerstone.getEnabledElement(element).image,
|
||||
pageX: mouseX,
|
||||
pageY: mouseY,
|
||||
imageX: startingCoords.x,
|
||||
imageY: startingCoords.y,
|
||||
currentPoints: {
|
||||
page: {
|
||||
x: mouseX,
|
||||
y: mouseY
|
||||
},
|
||||
image: cornerstone.pageToPixel(element, mouseX, mouseY),
|
||||
},
|
||||
keyCode: e.keyCode,
|
||||
which: e.which
|
||||
};
|
||||
|
||||
if (e.type === 'keydown') {
|
||||
$(element).trigger('CornerstoneToolsKeyDown', keyPressData);
|
||||
} else if (e.type === 'keypress') {
|
||||
$(element).trigger('CornerstoneToolsKeyPress', keyPressData);
|
||||
} else if (e.type === 'keyup') {
|
||||
$(element).trigger('CornerstoneToolsKeyUp', keyPressData);
|
||||
}
|
||||
keyPressData.currentPoints.canvas = cornerstone.pixelToCanvas(element, keyPressData.currentPoints.image);
|
||||
|
||||
var keyPressEvents = {
|
||||
keydown: 'CornerstoneToolsKeyDown',
|
||||
keypress: 'CornerstoneToolsKeyPress',
|
||||
keyup: 'CornerstoneToolsKeyUp',
|
||||
|
||||
};
|
||||
|
||||
$(element).trigger(keyPressEvents[e.type], keyPressData);
|
||||
}
|
||||
|
||||
function mouseMove(e) {
|
||||
@ -5976,12 +6010,16 @@ if (typeof cornerstoneTools === 'undefined') {
|
||||
var keyboardEvent = 'keydown keypress keyup';
|
||||
|
||||
function enable(element) {
|
||||
$(element).bind(keyboardEvent, keyPress);
|
||||
// Prevent handlers from being attached multiple times
|
||||
disable(element);
|
||||
|
||||
$(element).on(keyboardEvent, keyPress);
|
||||
$(element).on('mousemove', mouseMove);
|
||||
}
|
||||
|
||||
function disable(element) {
|
||||
$(element).unbind(keyboardEvent, keyPress);
|
||||
$(element).off(keyboardEvent, keyPress);
|
||||
$(element).off('mousemove', mouseMove);
|
||||
}
|
||||
|
||||
// module exports
|
||||
@ -7097,7 +7135,7 @@ if (typeof cornerstoneTools === 'undefined') {
|
||||
|
||||
function requestPoolManager() {
|
||||
|
||||
function addRequest(element, imageId, type, doneCallback, failCallback) {
|
||||
function addRequest(element, imageId, type, preventCache, doneCallback, failCallback) {
|
||||
if (!requestPool.hasOwnProperty(type)) {
|
||||
throw 'Request type must be one of interaction, thumbnail, or prefetch';
|
||||
}
|
||||
@ -7110,6 +7148,7 @@ if (typeof cornerstoneTools === 'undefined') {
|
||||
var requestDetails = {
|
||||
type: type,
|
||||
imageId: imageId,
|
||||
preventCache: preventCache,
|
||||
doneCallback: doneCallback,
|
||||
failCallback: failCallback
|
||||
};
|
||||
@ -7154,7 +7193,6 @@ if (typeof cornerstoneTools === 'undefined') {
|
||||
setTimeout(function() {
|
||||
var requestDetails = getNextRequest();
|
||||
if (!requestDetails) {
|
||||
awake = false;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -7191,8 +7229,15 @@ if (typeof cornerstoneTools === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
var loader;
|
||||
if (requestDetails.preventCache === true) {
|
||||
loader = cornerstone.loadImage(imageId);
|
||||
} else {
|
||||
loader = cornerstone.loadAndCacheImage(imageId);
|
||||
}
|
||||
|
||||
// Load and cache the image
|
||||
cornerstone.loadAndCacheImage(imageId).then(function(image) {
|
||||
loader.then(function(image) {
|
||||
numRequests[type]--;
|
||||
// console.log(numRequests);
|
||||
doneCallback(image);
|
||||
@ -7366,7 +7411,15 @@ if (typeof cornerstoneTools === 'undefined') {
|
||||
}
|
||||
|
||||
var viewport = cornerstone.getViewport(element);
|
||||
cornerstone.loadAndCacheImage(stackData.imageIds[newImageIdIndex]).then(function(image) {
|
||||
|
||||
var loader;
|
||||
if (stackData.preventCache === true) {
|
||||
loader = cornerstone.loadImage(stackData.imageIds[newImageIdIndex]);
|
||||
} else {
|
||||
loader = cornerstone.loadAndCacheImage(stackData.imageIds[newImageIdIndex]);
|
||||
}
|
||||
|
||||
loader.then(function(image) {
|
||||
stackData.currentImageIdIndex = newImageIdIndex;
|
||||
cornerstone.displayImage(element, image, viewport);
|
||||
if (endLoadingHandler) {
|
||||
@ -7611,7 +7664,8 @@ Display scroll progress bar across bottom of image.
|
||||
var nearest = nearestIndex(stackPrefetch.indicesToRequest, stack.currentImageIdIndex);
|
||||
|
||||
var imageId,
|
||||
nextImageIdIndex;
|
||||
nextImageIdIndex,
|
||||
preventCache = false;
|
||||
|
||||
// Prefetch images around the current image (before and after)
|
||||
var lowerIndex = nearest.low;
|
||||
@ -7620,13 +7674,13 @@ Display scroll progress bar across bottom of image.
|
||||
if (lowerIndex >= 0 ) {
|
||||
nextImageIdIndex = stackPrefetch.indicesToRequest[lowerIndex--];
|
||||
imageId = stack.imageIds[nextImageIdIndex];
|
||||
requestPoolManager.addRequest(element, imageId, requestType, doneCallback, failCallback);
|
||||
requestPoolManager.addRequest(element, imageId, requestType, preventCache, doneCallback, failCallback);
|
||||
}
|
||||
|
||||
if (higherIndex < stackPrefetch.indicesToRequest.length) {
|
||||
nextImageIdIndex = stackPrefetch.indicesToRequest[higherIndex++];
|
||||
imageId = stack.imageIds[nextImageIdIndex];
|
||||
requestPoolManager.addRequest(element, imageId, requestType, doneCallback, failCallback);
|
||||
requestPoolManager.addRequest(element, imageId, requestType, preventCache, doneCallback, failCallback);
|
||||
}
|
||||
}
|
||||
|
||||
@ -7702,6 +7756,12 @@ Display scroll progress bar across bottom of image.
|
||||
|
||||
var stack = stackData.data[0];
|
||||
|
||||
// Check if we are allowed to cache images in this stack
|
||||
if (stack.preventCache === true) {
|
||||
console.warn('A stack that should not be cached was given the stackPrefetch');
|
||||
return;
|
||||
}
|
||||
|
||||
// Use the currentImageIdIndex from the stack as the initalImageIdIndex
|
||||
var stackPrefetchData = {
|
||||
indicesToRequest: range(0, stack.imageIds.length - 1),
|
||||
@ -8765,7 +8825,14 @@ Display scroll progress bar across bottom of image.
|
||||
startLoadingHandler(targetElement);
|
||||
}
|
||||
|
||||
cornerstone.loadAndCacheImage(targetStackData.imageIds[newImageIdIndex]).then(function(image) {
|
||||
var loader;
|
||||
if (targetStackData.preventCache === true) {
|
||||
loader = cornerstone.loadImage(targetStackData.imageIds[newImageIdIndex]);
|
||||
} else {
|
||||
loader = cornerstone.loadAndCacheImage(targetStackData.imageIds[newImageIdIndex]);
|
||||
}
|
||||
|
||||
loader.then(function(image) {
|
||||
var viewport = cornerstone.getViewport(targetElement);
|
||||
targetStackData.currentImageIdIndex = newImageIdIndex;
|
||||
synchronizer.displayImage(targetElement, image, viewport);
|
||||
@ -8843,7 +8910,14 @@ Display scroll progress bar across bottom of image.
|
||||
startLoadingHandler(targetElement);
|
||||
}
|
||||
|
||||
cornerstone.loadAndCacheImage(stackData.imageIds[newImageIdIndex]).then(function(image) {
|
||||
var loader;
|
||||
if (stackData.preventCache === true) {
|
||||
loader = cornerstone.loadImage(stackData.imageIds[newImageIdIndex]);
|
||||
} else {
|
||||
loader = cornerstone.loadAndCacheImage(stackData.imageIds[newImageIdIndex]);
|
||||
}
|
||||
|
||||
loader.then(function(image) {
|
||||
var viewport = cornerstone.getViewport(targetElement);
|
||||
stackData.currentImageIdIndex = newImageIdIndex;
|
||||
synchronizer.displayImage(targetElement, image, viewport);
|
||||
@ -8913,7 +8987,14 @@ Display scroll progress bar across bottom of image.
|
||||
}
|
||||
|
||||
if (newImageIdIndex !== -1) {
|
||||
cornerstone.loadAndCacheImage(stackData.imageIds[newImageIdIndex]).then(function(image) {
|
||||
var loader;
|
||||
if (stackData.preventCache === true) {
|
||||
loader = cornerstone.loadImage(stackData.imageIds[newImageIdIndex]);
|
||||
} else {
|
||||
loader = cornerstone.loadAndCacheImage(stackData.imageIds[newImageIdIndex]);
|
||||
}
|
||||
|
||||
loader.then(function(image) {
|
||||
var viewport = cornerstone.getViewport(targetElement);
|
||||
stackData.currentImageIdIndex = newImageIdIndex;
|
||||
synchronizer.displayImage(targetElement, image, viewport);
|
||||
@ -8977,7 +9058,14 @@ Display scroll progress bar across bottom of image.
|
||||
startLoadingHandler(targetElement);
|
||||
}
|
||||
|
||||
cornerstone.loadAndCacheImage(stackData.imageIds[newImageIdIndex]).then(function(image) {
|
||||
var loader;
|
||||
if (stackData.preventCache === true) {
|
||||
loader = cornerstone.loadImage(stackData.imageIds[newImageIdIndex]);
|
||||
} else {
|
||||
loader = cornerstone.loadAndCacheImage(stackData.imageIds[newImageIdIndex]);
|
||||
}
|
||||
|
||||
loader.then(function(image) {
|
||||
var viewport = cornerstone.getViewport(targetElement);
|
||||
stackData.currentImageIdIndex = newImageIdIndex;
|
||||
synchronizer.displayImage(targetElement, image, viewport);
|
||||
@ -9348,7 +9436,14 @@ Display scroll progress bar across bottom of image.
|
||||
var samples = [];
|
||||
|
||||
measurementData.timeSeries.stacks.forEach(function(stack) {
|
||||
cornerstone.loadAndCacheImage(stack.imageIds[measurementData.imageIdIndex]).then(function(image) {
|
||||
var loader;
|
||||
if (stack.preventCache === true) {
|
||||
loader = cornerstone.loadImage(stack.imageIds[measurementData.imageIdIndex]);
|
||||
} else {
|
||||
loader = cornerstone.loadAndCacheImage(stack.imageIds[measurementData.imageIdIndex]);
|
||||
}
|
||||
|
||||
loader.then(function(image) {
|
||||
var offset = Math.round(measurementData.handles.end.x) + Math.round(measurementData.handles.end.y) * image.width;
|
||||
var sample = image.getPixelData()[offset];
|
||||
samples.push(sample);
|
||||
@ -9484,7 +9579,14 @@ Display scroll progress bar across bottom of image.
|
||||
startLoadingHandler(element);
|
||||
}
|
||||
|
||||
cornerstone.loadAndCacheImage(newStack.imageIds[currentImageIdIndex]).then(function(image) {
|
||||
var loader;
|
||||
if (newStack.preventCache === true) {
|
||||
loader = cornerstone.loadImage(newStack.imageIds[currentImageIdIndex]);
|
||||
} else {
|
||||
loader = cornerstone.loadAndCacheImage(newStack.imageIds[currentImageIdIndex]);
|
||||
}
|
||||
|
||||
loader.then(function(image) {
|
||||
if (timeSeriesData.currentImageIdIndex !== currentImageIdIndex) {
|
||||
newStack.currentImageIdIndex = currentImageIdIndex;
|
||||
timeSeriesData.currentStackIndex = newStackIndex;
|
||||
@ -10373,7 +10475,10 @@ Display scroll progress bar across bottom of image.
|
||||
|
||||
cornerstoneTools.requestPoolManager.clearRequestStack(type);
|
||||
|
||||
requestPoolManager.addRequest(element, newImageId, type, doneCallback, failCallback);
|
||||
// Convert the preventCache value in stack data to a boolean
|
||||
var preventCache = !!stackData.preventCache;
|
||||
|
||||
requestPoolManager.addRequest(element, newImageId, type, preventCache, doneCallback, failCallback);
|
||||
requestPoolManager.startGrabbing();
|
||||
|
||||
$(element).trigger('CornerstoneStackScroll', eventData);
|
||||
|
||||
@ -12,12 +12,6 @@ LocationResponses.insert({
|
||||
description: ""
|
||||
});
|
||||
|
||||
LocationResponses.insert({
|
||||
text: "Complete response",
|
||||
code: "CR",
|
||||
description: ""
|
||||
});
|
||||
|
||||
LocationResponses.insert({
|
||||
text: "Stable disease",
|
||||
code: "SD",
|
||||
@ -25,14 +19,8 @@ LocationResponses.insert({
|
||||
});
|
||||
|
||||
LocationResponses.insert({
|
||||
text: "Non-measurable",
|
||||
code: "NM",
|
||||
description: ""
|
||||
});
|
||||
|
||||
LocationResponses.insert({
|
||||
text: "Unknown",
|
||||
code: "UN",
|
||||
text: "Present",
|
||||
code: false,
|
||||
description: ""
|
||||
});
|
||||
|
||||
|
||||
174
Packages/lesiontracker/client/compatibility/LesionManager.js
Normal file
174
Packages/lesiontracker/client/compatibility/LesionManager.js
Normal file
@ -0,0 +1,174 @@
|
||||
var LesionManager = (function() {
|
||||
PatientLocations = new Meteor.Collection(null);
|
||||
|
||||
/**
|
||||
* Retrieve a location name (e.g. Liver Right) from the
|
||||
* PatientLocations Collection by id, if it exists. Otherwise,
|
||||
* return an empty string.
|
||||
*
|
||||
* @param id
|
||||
* @returns {*|string}
|
||||
*/
|
||||
function getLocationName(id) {
|
||||
var locationObject = PatientLocations.findOne(id);
|
||||
if (!locationObject || !locationObject.location) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return locationObject.location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the Timepoint object for a specific Measurement.
|
||||
* If no measurement exists yet, one will be created.
|
||||
*
|
||||
* Input is toolData from the lesion or nonTarget tool
|
||||
*
|
||||
* @param lesionData
|
||||
*/
|
||||
function updateLesionData(lesionData) {
|
||||
// Find the related Timepoint from the Timepoints Collection
|
||||
var timepointID = lesionData.timepointID;
|
||||
var timepoint = Timepoints.findOne({timepointID: timepointID});
|
||||
if (!timepoint) {
|
||||
log.warn('Timepoint in an image is not present in the Timepoints Collection?');
|
||||
return;
|
||||
}
|
||||
|
||||
// Find the specific lesion to be updated
|
||||
var existingMeasurement;
|
||||
if (lesionData.id) {
|
||||
existingMeasurement = Measurements.findOne(lesionData.id);
|
||||
} else {
|
||||
existingMeasurement = Measurements.findOne({
|
||||
lesionNumber: lesionData.lesionNumber,
|
||||
isTarget: lesionData.isTarget
|
||||
});
|
||||
}
|
||||
|
||||
// Create a structure for the timepointData based
|
||||
// on this Lesion's toolData
|
||||
var timepointData = {
|
||||
seriesInstanceUid: lesionData.seriesInstanceUid,
|
||||
studyInstanceUid: lesionData.studyInstanceUid,
|
||||
handles: lesionData.handles,
|
||||
imageId: lesionData.imageId
|
||||
};
|
||||
|
||||
if (lesionData.isTarget === true) {
|
||||
// TODO = Add short axis
|
||||
timepointData.longestDiameter = lesionData.measurementText;
|
||||
} else {
|
||||
timepointData.response = lesionData.response;
|
||||
}
|
||||
|
||||
// If no such lesion exists, we need to add one
|
||||
if (!existingMeasurement) {
|
||||
// Create a data structure for the Measurement
|
||||
// based on the current tool data
|
||||
var measurement = {
|
||||
lesionNumber: lesionData.lesionNumber,
|
||||
isTarget: lesionData.isTarget,
|
||||
patientId: lesionData.patientId,
|
||||
id: lesionData.id
|
||||
};
|
||||
|
||||
// Retrieve the location name given the locationUID
|
||||
if (lesionData.locationUID !== undefined) {
|
||||
measurement.location = getLocationName(lesionData.locationUID);
|
||||
}
|
||||
|
||||
// Add toolData parameters to the Measurement at this Timepoint
|
||||
measurement.timepoints = {};
|
||||
measurement.timepoints[timepointID] = timepointData;
|
||||
|
||||
// Set a flag to prevent duplication of toolData
|
||||
measurement.toolDataInsertedManually = true;
|
||||
|
||||
// Increment and store the Lesion Number for this Measurement
|
||||
measurement.lesionNumber = Measurements.find().count() + 1;
|
||||
|
||||
// Insert this into the Measurements Collection
|
||||
// Save the ID into the toolData (not sure if this works?)
|
||||
measurement.id = Measurements.insert(measurement);
|
||||
} else {
|
||||
lesionData.id = existingMeasurement._id;
|
||||
|
||||
// Update timepoints from lesion data
|
||||
existingMeasurement.timepoints[timepointID] = timepointData;
|
||||
|
||||
Measurements.update(existingMeasurement._id, {
|
||||
$set: {
|
||||
timepoints: existingMeasurement.timepoints
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new lesion number according to timepointID
|
||||
* @param timepointID
|
||||
* @param isTarget
|
||||
* @returns {*}
|
||||
*/
|
||||
function getNewLesionNumber(timepointID, isTarget) {
|
||||
// Get all current lesion measurements
|
||||
var measurements = Measurements.find({
|
||||
isTarget: isTarget
|
||||
}, {
|
||||
sort: {lesionNumber: 1}
|
||||
}).fetch();
|
||||
|
||||
// If no measurements exist yet, start at 1
|
||||
if (!measurements.length) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// If measurements exist, find the last lesion number
|
||||
// from the given timepoint
|
||||
var lesionNumberCounter = 1;
|
||||
var numMeasurements = measurements.length;
|
||||
|
||||
// Search through Measurements to see which ones
|
||||
// already have data for this Timepoint
|
||||
for (var i = 0; i < numMeasurements; i++) {
|
||||
var measurement = measurements[i];
|
||||
|
||||
// If this measurement has no data for this Timepoint,
|
||||
// use this as the current Measurement
|
||||
if (!measurement.timepoints[timepointID]) {
|
||||
return measurement.lesionNumber;
|
||||
}
|
||||
|
||||
lesionNumberCounter++;
|
||||
}
|
||||
|
||||
return lesionNumberCounter;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the current Lesion Number already exists
|
||||
* for any other timepoint, returns lesion locationUID
|
||||
* @param lesionData
|
||||
* @returns {*}
|
||||
*/
|
||||
function lesionNumberExists(lesionData) {
|
||||
var measurement = Measurements.findOne({
|
||||
lesionNumber: lesionData.lesionNumber,
|
||||
isTarget: lesionData.isTarget
|
||||
});
|
||||
|
||||
if (!measurement) {
|
||||
return;
|
||||
}
|
||||
|
||||
return measurement.locationUID;
|
||||
}
|
||||
|
||||
return {
|
||||
updateLesionData: updateLesionData,
|
||||
getNewLesionNumber: getNewLesionNumber,
|
||||
lesionNumberExists: lesionNumberExists,
|
||||
getLocationName: getLocationName
|
||||
};
|
||||
})();
|
||||
@ -856,7 +856,7 @@ var cornerstoneTools = (function($, cornerstone, cornerstoneMath, cornerstoneToo
|
||||
|
||||
if (lesionData.timepointID && lesionData.timepointID !== "") {
|
||||
// Update Measurements Collection
|
||||
measurementManagerDAL.updateTimepointData(lesionData);
|
||||
LesionManager.updateLesionData(lesionData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,91 @@
|
||||
(function(cornerstoneTools) {
|
||||
|
||||
'use strict';
|
||||
|
||||
// Delete a lesion if Ctrl+D or DELETE is pressed while a lesion is selected
|
||||
var keys = {
|
||||
D: 68,
|
||||
DELETE: 46
|
||||
};
|
||||
|
||||
function removeMeasurementTimepoint(data, index, toolType) {
|
||||
var imageId = data.imageId;
|
||||
var enabledElements = cornerstone.getEnabledElementsByImageId(imageId);
|
||||
enabledElements.forEach(function(enabledElement) {
|
||||
var element = enabledElement.element;
|
||||
|
||||
// The HandleMeasurementRemoved handler should do the rest
|
||||
cornerstoneTools.removeToolState(element, toolType, data);
|
||||
|
||||
//Update element
|
||||
cornerstone.updateImage(element);
|
||||
});
|
||||
}
|
||||
|
||||
function getNearbyToolData(element, coords, toolTypes) {
|
||||
var allTools = toolManager.getTools();
|
||||
var pointNearTool = false;
|
||||
var touchDevice = isTouchDevice();
|
||||
var nearbyTool,
|
||||
nearbyToolIndex,
|
||||
nearbyToolType;
|
||||
|
||||
toolTypes.forEach(function(toolType){
|
||||
var toolData = cornerstoneTools.getToolState(element, toolType);
|
||||
if (!toolData) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < toolData.data.length; i++) {
|
||||
var data = toolData.data[i];
|
||||
|
||||
var toolInterface;
|
||||
if (touchDevice) {
|
||||
toolInterface = allTools[toolType].touch;
|
||||
} else {
|
||||
toolInterface = allTools[toolType].mouse;
|
||||
}
|
||||
|
||||
if (toolInterface.pointNearTool(element, data, coords)) {
|
||||
pointNearTool = true;
|
||||
nearbyTool = data;
|
||||
nearbyToolIndex = i;
|
||||
nearbyToolType = toolType;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pointNearTool === true) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if (pointNearTool === true) {
|
||||
return {
|
||||
nearbyTool: nearbyTool,
|
||||
nearbyToolIndex: nearbyToolIndex,
|
||||
nearbyToolType: nearbyToolType
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function keyDownCallback(e, eventData) {
|
||||
var keyCode = eventData.keyCode;
|
||||
if (keyCode === keys.DELETE ||
|
||||
(keyCode === keys.D && eventData.event.ctrlKey === true)) {
|
||||
|
||||
var toolTypes = ["lesion", "nonTarget"];
|
||||
var nearbyToolData = getNearbyToolData(eventData.element, eventData.currentPoints.canvas, toolTypes);
|
||||
|
||||
if (nearbyToolData) {
|
||||
removeMeasurementTimepoint(nearbyToolData.nearbyTool,
|
||||
nearbyToolData.nearbyToolIndex,
|
||||
nearbyToolData.nearbyToolType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// module/private exports
|
||||
cornerstoneTools.deleteLesionKeyboardTool = cornerstoneTools.keyboardTool(keyDownCallback);
|
||||
|
||||
})(cornerstoneTools);
|
||||
@ -78,8 +78,6 @@ var cornerstoneTools = (function($, cornerstone, cornerstoneMath, cornerstoneToo
|
||||
$(element).on('CornerstoneToolsMouseDown', eventData, cornerstoneTools.lesion.mouseDownCallback);
|
||||
$(element).on('CornerstoneToolsMouseDownActivate', eventData, cornerstoneTools.lesion.mouseDownActivateCallback);
|
||||
cornerstone.updateImage(element);
|
||||
|
||||
updateLesionCollection(measurementData);
|
||||
});
|
||||
}
|
||||
|
||||
@ -287,18 +285,6 @@ var cornerstoneTools = (function($, cornerstone, cornerstoneMath, cornerstoneToo
|
||||
}
|
||||
}
|
||||
|
||||
function updateLesionCollection(lesionData) {
|
||||
// TODO = Remove this in favour of measurement events
|
||||
if (!lesionData.active) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (lesionData.timepointID && lesionData.timepointID !== "") {
|
||||
// Update Measurements Collection
|
||||
measurementManagerDAL.updateTimepointData(lesionData);
|
||||
}
|
||||
}
|
||||
|
||||
function doubleClickCallback(e, eventData) {
|
||||
// Prevent other double click handlers from firing after this one
|
||||
//e.stopImmediatePropagation();
|
||||
@ -310,16 +296,7 @@ var cornerstoneTools = (function($, cornerstone, cornerstoneMath, cornerstoneToo
|
||||
if (deleteTool === true) {
|
||||
cornerstoneTools.removeToolState(element, toolType, data);
|
||||
cornerstone.updateImage(element);
|
||||
//return;
|
||||
}
|
||||
|
||||
/*// TODO= Find a better way to do this! This is very messy
|
||||
config.setLesionNumberCallback(data, eventData, function(lesionNumber) {
|
||||
data.lesionName = "Target " + lesionNumber;
|
||||
data.lesionNumber = lesionNumber;
|
||||
data.active = false;
|
||||
cornerstone.updateImage(element);
|
||||
});*/
|
||||
}
|
||||
|
||||
if (e.data && e.data.mouseButtonMask && !cornerstoneTools.isMouseButtonEnabled(eventData.which, e.data.mouseButtonMask)) {
|
||||
|
||||
@ -1,167 +0,0 @@
|
||||
var measurementManagerDAL = (function() {
|
||||
PatientLocations = new Meteor.Collection(null);
|
||||
|
||||
function getLocationName(id) {
|
||||
var locationObject = PatientLocations.findOne(id);
|
||||
return locationObject.location || "";
|
||||
}
|
||||
|
||||
// Add timepoint data to Measurements collection
|
||||
function addTimepointData(lesionData) {
|
||||
var timepoints = Timepoints.find().fetch();
|
||||
|
||||
var timepointsObject = {};
|
||||
|
||||
for (var i = 0; i < timepoints.length; i++) {
|
||||
var timepointId = timepoints[i].timepointID;
|
||||
var lesionTimepointId = lesionData.timepointID;
|
||||
|
||||
var timepointObject;
|
||||
if (timepointId === lesionTimepointId) {
|
||||
// Add real measurement
|
||||
timepointObject = {
|
||||
longestDiameter: lesionData.measurementText,
|
||||
imageId: lesionData.imageId,
|
||||
seriesInstanceUid: lesionData.seriesInstanceUid,
|
||||
studyInstanceUid: lesionData.studyInstanceUid,
|
||||
handles: lesionData.handles
|
||||
};
|
||||
} else {
|
||||
// Add null measurement
|
||||
timepointObject = {
|
||||
longestDiameter: "",
|
||||
imageId: "",
|
||||
seriesInstanceUid: "",
|
||||
studyInstanceUid: "",
|
||||
handles: undefined
|
||||
};
|
||||
}
|
||||
timepointsObject[timepointId] = timepointObject;
|
||||
}
|
||||
|
||||
var lesionDataObject = lesionData;
|
||||
|
||||
lesionDataObject.patientId = timepoints[0].patientId;
|
||||
lesionDataObject.location = getLocationName(lesionData.locationUID);
|
||||
lesionDataObject.timepoints = timepointsObject;
|
||||
|
||||
// Is there a use for this?
|
||||
lesionDataObject.number = Measurements.find().count() + 1;
|
||||
|
||||
lesionDataObject.id = Measurements.insert(lesionDataObject);
|
||||
}
|
||||
|
||||
// Update timepoint data in Measurements collection
|
||||
function updateTimepointData(lesionData) {
|
||||
// Find the specific lesion to be updated
|
||||
var measurement = Measurements.findOne({
|
||||
lesionNumber: lesionData.lesionNumber,
|
||||
isTarget: lesionData.isTarget
|
||||
});
|
||||
|
||||
// If no such lesion exists, stop here
|
||||
if (!measurement) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Update this specific lesion at the given timepoint
|
||||
var timepointID = lesionData.timepointID;
|
||||
|
||||
// Update timepoints from lesion data
|
||||
var timepoints = measurement.timepoints;
|
||||
if (timepoints[timepointID] === undefined) {
|
||||
timepoints[timepointID] = {};
|
||||
}
|
||||
|
||||
timepoints[timepointID].longestDiameter = lesionData.measurementText;
|
||||
timepoints[timepointID].imageId = lesionData.imageId;
|
||||
timepoints[timepointID].seriesInstanceUid = lesionData.seriesInstanceUid;
|
||||
timepoints[timepointID].studyInstanceUid = lesionData.studyInstanceUid;
|
||||
timepoints[timepointID].handles = lesionData.handles;
|
||||
|
||||
lesionData.id = measurement._id;
|
||||
|
||||
Measurements.update(measurement._id, {
|
||||
$set: {
|
||||
timepoints: timepoints
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Check timepointData is found in Measurements collection
|
||||
function hasTimepointData(lesionData) {
|
||||
var timepointData = Measurements.findOne({
|
||||
lesionNumber: lesionData.lesionNumber,
|
||||
isTarget: lesionData.isTarget
|
||||
});
|
||||
|
||||
if (timepointData) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Adds new timepoint item to timepoints array
|
||||
function addLesionData(lesionData) {
|
||||
if (hasTimepointData(lesionData)) {
|
||||
// Update data
|
||||
updateTimepointData(lesionData);
|
||||
} else {
|
||||
// Insert data
|
||||
addTimepointData(lesionData);
|
||||
}
|
||||
}
|
||||
|
||||
// Returns new lesion number according to timepointID
|
||||
function getNewLesionNumber(timepointID, isTarget) {
|
||||
// Get all current lesion measurements
|
||||
var measurements = Measurements.find({isTarget: isTarget},{sort: {lesionNumber: 1}}).fetch();
|
||||
|
||||
// If no measurements exist yet, start at 1
|
||||
if (!measurements.length) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// If measurements exist, find the last lesion number
|
||||
// from the given timepoint
|
||||
var lesionNumberCounter = 0;
|
||||
for (var i = 0; i < measurements.length; i++) {
|
||||
var measurement = measurements[i];
|
||||
var timepoints = measurement.timepoints;
|
||||
|
||||
if (!timepoints[timepointID]) {
|
||||
// Find lesion number for this timepointID
|
||||
return measurement.lesionNumber;
|
||||
}
|
||||
|
||||
if (timepoints[timepointID].longestDiameter === '') {
|
||||
return measurement.lesionNumber;
|
||||
} else {
|
||||
lesionNumberCounter = lesionNumberCounter + 1;
|
||||
}
|
||||
}
|
||||
return lesionNumberCounter + 1;
|
||||
}
|
||||
|
||||
// If lesion number is added for any timepoint, returns lesion locationUID
|
||||
function lesionNumberExists(lesionData) {
|
||||
if (!hasTimepointData(lesionData)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var measurement = Measurements.findOne({
|
||||
lesionNumber: lesionData.lesionNumber,
|
||||
isTarget: lesionData.isTarget
|
||||
});
|
||||
|
||||
return measurement.locationUID;
|
||||
}
|
||||
|
||||
return {
|
||||
addLesionData: addLesionData,
|
||||
getNewLesionNumber: getNewLesionNumber,
|
||||
lesionNumberExists: lesionNumberExists,
|
||||
updateTimepointData: updateTimepointData,
|
||||
getLocationName: getLocationName
|
||||
};
|
||||
})();
|
||||
@ -32,7 +32,6 @@
|
||||
/// --- Mouse Tool --- ///
|
||||
///////// BEGIN ACTIVE TOOL ///////
|
||||
function addNewMeasurement(mouseEventData) {
|
||||
|
||||
var element = mouseEventData.element;
|
||||
|
||||
function doneCallback(lesionNumber) {
|
||||
@ -53,9 +52,9 @@
|
||||
|
||||
// since we are dragging to another place to drop the end point, we can just activate
|
||||
// the end point and let the moveHandle move it for us.
|
||||
$(mouseEventData.element).off('CornerstoneToolsMouseMove', cornerstoneTools.nonTarget.mouseMoveCallback);
|
||||
$(mouseEventData.element).off('CornerstoneToolsMouseDown', cornerstoneTools.nonTarget.mouseDownCallback);
|
||||
$(mouseEventData.element).off('CornerstoneToolsMouseDownActivate', cornerstoneTools.nonTarget.mouseDownActivateCallback);
|
||||
$(element).off('CornerstoneToolsMouseMove', cornerstoneTools.nonTarget.mouseMoveCallback);
|
||||
$(element).off('CornerstoneToolsMouseDown', cornerstoneTools.nonTarget.mouseDownCallback);
|
||||
$(element).off('CornerstoneToolsMouseDownActivate', cornerstoneTools.nonTarget.mouseDownActivateCallback);
|
||||
|
||||
var config = cornerstoneTools.nonTarget.getConfiguration();
|
||||
|
||||
@ -75,9 +74,9 @@
|
||||
|
||||
}
|
||||
|
||||
$(mouseEventData.element).on('CornerstoneToolsMouseMove', eventData, cornerstoneTools.nonTarget.mouseMoveCallback);
|
||||
$(mouseEventData.element).on('CornerstoneToolsMouseDown', eventData, cornerstoneTools.nonTarget.mouseDownCallback);
|
||||
$(mouseEventData.element).on('CornerstoneToolsMouseDownActivate', eventData, cornerstoneTools.nonTarget.mouseDownActivateCallback);
|
||||
$(element).on('CornerstoneToolsMouseMove', eventData, cornerstoneTools.nonTarget.mouseMoveCallback);
|
||||
$(element).on('CornerstoneToolsMouseDown', eventData, cornerstoneTools.nonTarget.mouseDownCallback);
|
||||
$(element).on('CornerstoneToolsMouseDownActivate', eventData, cornerstoneTools.nonTarget.mouseDownActivateCallback);
|
||||
|
||||
cornerstone.updateImage(mouseEventData.element);
|
||||
});
|
||||
@ -127,8 +126,7 @@
|
||||
studyInstanceUid: studyInstanceUid,
|
||||
patientId: patientId,
|
||||
measurementText: '',
|
||||
isTarget: false,
|
||||
uid: uuid.v4()
|
||||
isTarget: false
|
||||
};
|
||||
|
||||
return measurementData;
|
||||
@ -184,8 +182,8 @@
|
||||
// configurable shadow from CornerstoneTools
|
||||
if (config && config.shadow) {
|
||||
context.shadowColor = '#000000';
|
||||
context.shadowOffsetX = +1;
|
||||
context.shadowOffsetY = +1;
|
||||
context.shadowOffsetX = 1;
|
||||
context.shadowOffsetY = 1;
|
||||
}
|
||||
|
||||
if (data.active) {
|
||||
@ -286,6 +284,7 @@
|
||||
if (deleteTool === true) {
|
||||
cornerstoneTools.removeToolState(element, toolType, data);
|
||||
cornerstone.updateImage(element);
|
||||
return;
|
||||
}
|
||||
|
||||
data.active = false;
|
||||
|
||||
@ -0,0 +1,8 @@
|
||||
<template name="confirmDeleteDialog">
|
||||
<div id="confirmDeleteDialog">
|
||||
<h5>Remove Measurement?</h5>
|
||||
<p>Are you sure you would like to remove this measurement?</p>
|
||||
<button id="cancel" class="btn btn-link">Cancel</button>
|
||||
<button id="confirm" class="btn btn-primary">OK</button>
|
||||
</div>
|
||||
</template>
|
||||
@ -0,0 +1,51 @@
|
||||
function closeHandler() {
|
||||
// Hide the lesion dialog
|
||||
$("#confirmDeleteDialog").css('display', 'none');
|
||||
|
||||
// Remove the backdrop
|
||||
$(".removableBackdrop").remove();
|
||||
|
||||
// Remove the callback from the template data
|
||||
delete Template.confirmDeleteDialog.doneCallback;
|
||||
}
|
||||
|
||||
showConfirmDialog = function(doneCallback) {
|
||||
// Show the backdrop
|
||||
UI.render(Template.removableBackdrop, document.body);
|
||||
|
||||
// Make sure the context menu is closed when the user clicks away
|
||||
$(".removableBackdrop").one('mousedown touchstart', function() {
|
||||
closeHandler();
|
||||
});
|
||||
|
||||
$("#confirmDeleteDialog").css('display', 'block');
|
||||
|
||||
if (doneCallback && typeof doneCallback === 'function') {
|
||||
Template.confirmDeleteDialog.doneCallback = doneCallback;
|
||||
}
|
||||
};
|
||||
|
||||
Template.confirmDeleteDialog.events({
|
||||
'click #cancel, click #close': function() {
|
||||
closeHandler();
|
||||
},
|
||||
'click #confirm': function() {
|
||||
var doneCallback = Template.confirmDeleteDialog.doneCallback;
|
||||
|
||||
if (doneCallback && typeof doneCallback === 'function') {
|
||||
doneCallback();
|
||||
}
|
||||
|
||||
closeHandler();
|
||||
},
|
||||
'keypress #confirmDeleteDialog': function(e) {
|
||||
if (this.keyPressAllowed === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If Enter is pressed, close the dialog
|
||||
if (e.which === 13) {
|
||||
closeHandler();
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,24 @@
|
||||
#confirmDeleteDialog
|
||||
display: none
|
||||
position: absolute
|
||||
top: 0
|
||||
bottom: 0
|
||||
left: 0
|
||||
right: 0
|
||||
z-index: 100
|
||||
width: 300px
|
||||
height: fit-content
|
||||
margin: auto
|
||||
border-radius: 5px
|
||||
padding: 10px 20px 10px 20px
|
||||
background-color: rgba(255,255,255,1)
|
||||
|
||||
.btn
|
||||
outline: none
|
||||
text-decoration: none
|
||||
|
||||
#cancel
|
||||
float: left
|
||||
|
||||
#confirm
|
||||
float: right
|
||||
@ -23,7 +23,7 @@ function setLesionNumberCallback(measurementData, eventData, doneCallback) {
|
||||
|
||||
// Get a lesion number for this lesion, depending on whether or not the same lesion previously
|
||||
// exists at a different timepoint
|
||||
var lesionNumber = measurementManagerDAL.getNewLesionNumber(measurementData.timepointID, isTarget=true);
|
||||
var lesionNumber = LesionManager.getNewLesionNumber(measurementData.timepointID, isTarget=true);
|
||||
measurementData.lesionNumber = lesionNumber;
|
||||
|
||||
// Set lesion number
|
||||
@ -57,13 +57,13 @@ function getLesionLocationCallback(measurementData, eventData) {
|
||||
|
||||
// Find out if this lesion number is already added in the lesion manager for another timepoint
|
||||
// If it is, stop here because we don't need the dialog.
|
||||
var locationUID = measurementManagerDAL.lesionNumberExists(measurementData);
|
||||
var locationUID = LesionManager.lesionNumberExists(measurementData);
|
||||
if (locationUID) {
|
||||
// Add an ID value to the tool data to link it to the Measurements collection
|
||||
measurementData.id = 'notready';
|
||||
|
||||
measurementData.locationUID = locationUID;
|
||||
measurementManagerDAL.updateTimepointData(measurementData);
|
||||
LesionManager.updateLesionData(measurementData);
|
||||
closeHandler();
|
||||
return;
|
||||
}
|
||||
@ -90,7 +90,7 @@ function getLesionLocationCallback(measurementData, eventData) {
|
||||
dialog.css(dialogProperty);
|
||||
}
|
||||
|
||||
function changeLesionLocationCallback(measurementData, eventData, doneCallback) {
|
||||
changeLesionLocationCallback = function(measurementData, eventData, doneCallback) {
|
||||
Template.lesionLocationDialog.measurementData = measurementData;
|
||||
Template.lesionLocationDialog.doneCallback = doneCallback;
|
||||
|
||||
@ -107,21 +107,22 @@ function changeLesionLocationCallback(measurementData, eventData, doneCallback)
|
||||
});
|
||||
|
||||
// Show the lesion location dialog above
|
||||
var dialogProperty = {
|
||||
top: eventData.currentPoints.page.y - dialog.outerHeight() - 40,
|
||||
left: eventData.currentPoints.page.x - dialog.outerWidth() / 2,
|
||||
var dialogProperty = {
|
||||
display: 'block'
|
||||
};
|
||||
|
||||
// Device is touch device or not
|
||||
// If device is touch device, set position center of screen vertically and horizontally
|
||||
if (isTouchDevice()) {
|
||||
if (!eventData || isTouchDevice()) {
|
||||
// add dialogMobile class to provide a black,transparent background
|
||||
dialog.addClass("dialogMobile");
|
||||
dialogProperty.top = 0;
|
||||
dialogProperty.left = 0;
|
||||
dialogProperty.right = 0;
|
||||
dialogProperty.bottom = 0;
|
||||
} else {
|
||||
dialogProperty.top = eventData.currentPoints.page.y - dialog.outerHeight() - 40;
|
||||
dialogProperty.left = eventData.currentPoints.page.x - dialog.outerWidth() / 2;
|
||||
}
|
||||
|
||||
dialog.css(dialogProperty);
|
||||
@ -131,20 +132,24 @@ function changeLesionLocationCallback(measurementData, eventData, doneCallback)
|
||||
return;
|
||||
}
|
||||
|
||||
LesionLocations.update({},
|
||||
{$set: {selected: false}},
|
||||
{ multi: true });
|
||||
|
||||
var currentLocation = LesionLocations.findOne({
|
||||
id: measurement.locationId
|
||||
});
|
||||
|
||||
LesionLocations.update({},
|
||||
{$set: {selected: false}},
|
||||
{ multi: true });
|
||||
if (!currentLocation) {
|
||||
return;
|
||||
}
|
||||
|
||||
LesionLocations.update(currentLocation._id, {
|
||||
$set: {
|
||||
selected: true
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var config = {
|
||||
setLesionNumberCallback: setLesionNumberCallback,
|
||||
@ -189,6 +194,7 @@ Template.lesionLocationDialog.events({
|
||||
measurementData.id = 'notready';
|
||||
|
||||
// Link locationUID with active lesion measurementData
|
||||
measurementData.location = locationObj.location;
|
||||
measurementData.locationId = locationObj.id;
|
||||
measurementData.locationUID = id;
|
||||
|
||||
@ -196,7 +202,7 @@ Template.lesionLocationDialog.events({
|
||||
measurementData.isTarget = true;
|
||||
|
||||
// Adds lesion data to timepoints array
|
||||
measurementManagerDAL.addLesionData(measurementData);
|
||||
LesionManager.updateLesionData(measurementData);
|
||||
} else {
|
||||
Measurements.update(measurementData.id, {
|
||||
$set: {
|
||||
@ -219,10 +225,12 @@ Template.lesionLocationDialog.events({
|
||||
var doneCallback = Template.lesionLocationDialog.doneCallback;
|
||||
var dialog = Template.lesionLocationDialog.dialog;
|
||||
|
||||
if (doneCallback && typeof doneCallback === 'function') {
|
||||
var deleteTool = true;
|
||||
doneCallback(measurementData, deleteTool);
|
||||
}
|
||||
showConfirmDialog(function() {
|
||||
if (doneCallback && typeof doneCallback === 'function') {
|
||||
var deleteTool = true;
|
||||
doneCallback(measurementData, deleteTool);
|
||||
}
|
||||
});
|
||||
|
||||
closeHandler(dialog);
|
||||
},
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
right: 0
|
||||
z-index: 100
|
||||
width: 300px
|
||||
margin: auto
|
||||
border-radius: 5px
|
||||
padding: 10px 20px 10px 20px
|
||||
background-color: rgba(255,255,255,1)
|
||||
|
||||
@ -1,221 +1,17 @@
|
||||
/**
|
||||
* Activates a set of lesions when lesion table row is clicked
|
||||
*
|
||||
* @param measurementId The unique key for a specific Measurement
|
||||
*/
|
||||
activateLesion = function(measurementId, templateData) {
|
||||
|
||||
// Set background color of selected row
|
||||
$("tr[data-measurementid="+measurementId+"]").addClass("selectedRow").siblings().removeClass("selectedRow");
|
||||
|
||||
var measurementData = Measurements.findOne(measurementId);
|
||||
|
||||
// If there is no measurement with this ID, stop here
|
||||
if (!measurementData) {
|
||||
log.warn('No Measurements entry associated to an ID in a lesion table row');
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the timepoint data from this Measurement
|
||||
var timepoints = measurementData.timepoints;
|
||||
|
||||
// Get all non-dummy timepoint entries in the Measurement
|
||||
// TODO=Re-evaluate this approach to populating viewports with timepoints
|
||||
// What is the desired behaviour here?
|
||||
var timepointsWithEntries = [];
|
||||
Object.keys(timepoints).forEach(function(key) {
|
||||
var timepoint = timepoints[key];
|
||||
|
||||
if (timepoint.imageId === "" ||
|
||||
timepoint.studyInstanceUid === "" ||
|
||||
timepoint.seriesInstanceUid === "") {
|
||||
return;
|
||||
}
|
||||
|
||||
timepointsWithEntries.push(timepoint);
|
||||
});
|
||||
|
||||
// If there are no non-dummy timepoint entries, stop here
|
||||
if (!timepointsWithEntries.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Loop through the viewports and display each timepoint
|
||||
$(".imageViewerViewport").each(function(viewportIndex, element) {
|
||||
// Stop if we run out of timepoints before viewports
|
||||
if (viewportIndex >= timepointsWithEntries.length) {
|
||||
// Update the element anyway, to remove any other highlights that are present
|
||||
deactivateAllToolData(element, 'lesion');
|
||||
deactivateAllToolData(element, 'nonTarget');
|
||||
cornerstone.updateImage(element);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Find measurements related to the Nth timepoint
|
||||
// TODO=Re-evaluate this approach to populating viewports with timepoints
|
||||
// What is the desired behaviour here?
|
||||
var measurementAtTimepoint = timepointsWithEntries[viewportIndex];
|
||||
|
||||
// Find the image that is currently in this viewport
|
||||
var enabledElement = cornerstone.getEnabledElement(element);
|
||||
if (!enabledElement || !enabledElement.image) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If there is no measurement data to display, stop here
|
||||
if (!measurementAtTimepoint) {
|
||||
// Update the element anyway, to remove any other highlights that are present
|
||||
deactivateAllToolData(element, 'lesion');
|
||||
deactivateAllToolData(element, 'nonTarget');
|
||||
cornerstone.updateImage(element);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check which study and series are required to display the measurement at this timepoint
|
||||
var requiredSeriesData = {
|
||||
seriesInstanceUid: measurementAtTimepoint.seriesInstanceUid,
|
||||
studyInstanceUid: measurementAtTimepoint.studyInstanceUid
|
||||
};
|
||||
|
||||
// Check if the study / series we need is already the one in the viewport
|
||||
var currentSeriesData = OHIF.viewer.loadedSeriesData[viewportIndex];
|
||||
if (currentSeriesData.seriesInstanceUid === measurementAtTimepoint.seriesInstanceUid &&
|
||||
currentSeriesData.studyInstanceUid === measurementAtTimepoint.studyInstanceUid) {
|
||||
// If it is, activate the measurements in this viewport and stop here
|
||||
activateMeasurements(element, measurementId, templateData, viewportIndex);
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, re-render the viewport with the required study/series, then
|
||||
// add an onRendered callback to activate the measurements
|
||||
rerenderViewportWithNewSeries(element, requiredSeriesData, function(element) {
|
||||
activateMeasurements(element, measurementId, templateData, viewportIndex);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns timepoint object based on timepoint id of the enabled element
|
||||
*
|
||||
* @param timepoints
|
||||
* @param enabledElement
|
||||
* @returns {*|{}} Timepoint object based on timepoint id of the enabled element (or an empty Object)
|
||||
*/
|
||||
function getTimepointObject(imageId) {
|
||||
var study = cornerstoneTools.metaData.get('study', imageId);
|
||||
return Timepoints.findOne({timepointName: study.studyDate});
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch to the image of the correct image index
|
||||
* Activate the selected measurement on the switched image (color to be green)
|
||||
* Deactivate all other measurements on the switched image (color to be white)
|
||||
*/
|
||||
function activateMeasurements(element, measurementId, templateData, viewportIndex) {
|
||||
// TODO=Switch this to use the new CornerstoneToolMeasurementModified event,
|
||||
// Once it has 'modified on activation' set up
|
||||
|
||||
var enabledElement = cornerstone.getEnabledElement(element);
|
||||
var imageId = enabledElement.image.imageId;
|
||||
var timepointData = getTimepointObject(imageId);
|
||||
var measurementData = Measurements.findOne(measurementId);
|
||||
|
||||
var measurementAtTimepoint = measurementData.timepoints[timepointData.timepointID];
|
||||
if (!measurementAtTimepoint) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If type is active, load image and activate lesion
|
||||
// If type is inactive, update lesions of enabledElement as inactive
|
||||
//TODO: !stackData.currentImageIdIndex returns incorrect value
|
||||
// Get loadedSeriesData currentImageIdIndex from ViewerData
|
||||
var contentId = templateData.contentId;
|
||||
var viewerData = ViewerData[contentId];
|
||||
var elementCurrentImageIdIndex = viewerData.loadedSeriesData[viewportIndex].currentImageIdIndex;
|
||||
|
||||
var stackToolDataSource = cornerstoneTools.getToolState(element, 'stack');
|
||||
var stackData = stackToolDataSource.data[0];
|
||||
var imageIds = stackData.imageIds;
|
||||
var imageIdIndex = imageIds.indexOf(measurementAtTimepoint.imageId);
|
||||
|
||||
if (imageIdIndex < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (imageIdIndex === elementCurrentImageIdIndex){
|
||||
activateTool(element, measurementData, timepointData.timepointID);
|
||||
} else {
|
||||
cornerstone.loadAndCacheImage(imageIds[imageIdIndex]).then(function(image) {
|
||||
cornerstone.displayImage(element, image);
|
||||
activateTool(element, measurementData, timepointData.timepointID);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Activates a specific tool data instance and deactivates all other
|
||||
* target and non-target measurement data
|
||||
*
|
||||
* @param element
|
||||
* @param measurementData
|
||||
* @param timepointID
|
||||
*/
|
||||
function activateTool(element, measurementData, timepointID) {
|
||||
deactivateAllToolData(element, 'lesion');
|
||||
deactivateAllToolData(element, 'nonTarget');
|
||||
|
||||
var toolType = measurementData.isTarget ? 'lesion' : 'nonTarget';
|
||||
var toolData = cornerstoneTools.getToolState(element, toolType);
|
||||
if (!toolData) {
|
||||
return;
|
||||
}
|
||||
|
||||
var measurementAtTimepoint = measurementData.timepoints[timepointID];
|
||||
|
||||
for (var i = 0; i < toolData.data.length; i++) {
|
||||
data = toolData.data[i];
|
||||
|
||||
// When click a row of table measurements, measurement will be active and color will be green
|
||||
// TODO= Remove this with the measurementId once it is in the tool data
|
||||
if (data.seriesInstanceUid === measurementAtTimepoint.seriesInstanceUid &&
|
||||
data.studyInstanceUid === measurementAtTimepoint.studyInstanceUid &&
|
||||
data.lesionNumber === measurementData.lesionNumber &&
|
||||
data.isTarget == measurementData.isTarget) {
|
||||
|
||||
data.active = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets all tool data entries value for 'active' to false
|
||||
* This is used to remove the active color on entire sets of tools
|
||||
*
|
||||
* @param element The Cornerstone element that is being used
|
||||
* @param toolType The tooltype of the tools that will be deactivated
|
||||
*/
|
||||
function deactivateAllToolData(element, toolType) {
|
||||
var toolData = cornerstoneTools.getToolState(element, toolType);
|
||||
if (!toolData) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < toolData.data.length; i++) {
|
||||
var data = toolData.data[i];
|
||||
data.active = false;
|
||||
}
|
||||
}
|
||||
|
||||
Template.lesionTable.helpers({
|
||||
'measurement': function() {
|
||||
return Measurements.find({}, {sort: {number: 1}});
|
||||
return Measurements.find({}, {
|
||||
sort: {
|
||||
lesionNumber: 1
|
||||
}
|
||||
});
|
||||
},
|
||||
'timepoints': function() {
|
||||
return Timepoints.find({}, {sort: {timepointName: 1}});
|
||||
return Timepoints.find({}, {
|
||||
sort: {
|
||||
timepointName: 1
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@ -224,9 +20,8 @@ Template.lesionTable.events({
|
||||
// Retrieve the lesion id from the DOM data for this row
|
||||
var measurementId = $(e.currentTarget).data('measurementid');
|
||||
|
||||
activateLesion(measurementId,template.data);
|
||||
activateLesion(measurementId, template.data);
|
||||
},
|
||||
|
||||
'mousedown div#dragbar': function(e, template) {
|
||||
var pY = e.pageY;
|
||||
var draggableParent = $(e.currentTarget).parent();
|
||||
@ -235,7 +30,6 @@ Template.lesionTable.events({
|
||||
|
||||
$(document).on('mouseup', function(e) {
|
||||
template.dragging.set(false);
|
||||
console.log(e.pageY);
|
||||
$(document).off('mouseup').off('mousemove');
|
||||
});
|
||||
|
||||
@ -244,7 +38,7 @@ Template.lesionTable.events({
|
||||
var newHeight = startHeight - topPosition;
|
||||
|
||||
// Min lesion table height = 5px
|
||||
if(newHeight < 5) {
|
||||
if (newHeight < 5) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -256,76 +50,67 @@ Template.lesionTable.events({
|
||||
var viewportAndLesionTableHeight = $("#viewportAndLesionTable").height();
|
||||
var newPercentageHeightofLesionTable = (startHeight - topPosition) / viewportAndLesionTableHeight * 100;
|
||||
var newPercentageHeightofViewermain = 100 - newPercentageHeightofLesionTable;
|
||||
$(".viewerMain").height(newPercentageHeightofViewermain+"%");
|
||||
$(".viewerMain").height(newPercentageHeightofViewermain + "%");
|
||||
|
||||
// Resize viewport
|
||||
resizeViewportElements();
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Template.lesionTable.onCreated(function(){
|
||||
this.dragging = new ReactiveVar(false);
|
||||
// Bind document mouse events
|
||||
// $(document).on('mousemove', dragbarMove);
|
||||
Template.lesionTable.onCreated(function() {
|
||||
this.dragging = new ReactiveVar(false);
|
||||
});
|
||||
|
||||
Template.lesionTable.onDestroyed(function(){
|
||||
Template.lesionTable.onRendered(function() {
|
||||
var self = this;
|
||||
|
||||
});
|
||||
// Track ViewerData to get active timepoints
|
||||
// Put a visual indicator (<) in timepoint header in lesion table for active timepoints
|
||||
// timepointLoaded property is used to put indicator for loaded timepoints in viewport
|
||||
self.autorun(function() {
|
||||
// Get study dates of imageViewerViewport elements
|
||||
var loadedStudyDates = {
|
||||
patientId: "",
|
||||
dates: []
|
||||
};
|
||||
|
||||
// Track ViewerData to get active timepoints
|
||||
// Put a visual indicator(<) in timepoint header in lesion table for active timepoints
|
||||
// timepointLoaded property is used to put indicator for loaded timepoints in viewport
|
||||
Tracker.autorun(function () {
|
||||
var allViewerData = Session.get('ViewerData');
|
||||
var contentId = Session.get('activeContentId');
|
||||
if(allViewerData && contentId) {
|
||||
var viewerData = allViewerData[contentId];
|
||||
if (viewerData) {
|
||||
// Get study dates of imageViewerViewport elements
|
||||
var loadedStudyDates = {
|
||||
patientId: "",
|
||||
dates: []
|
||||
};
|
||||
|
||||
$(".imageViewerViewport").each(function(viewportIndex, element) {
|
||||
var enabledElement = cornerstone.getEnabledElement(element);
|
||||
if(enabledElement && enabledElement.image){
|
||||
var imageId = enabledElement.image.imageId;
|
||||
var study = cornerstoneTools.metaData.get('study', imageId);
|
||||
var studyDate = study.studyDate;
|
||||
loadedStudyDates.patientId = study.patientId;
|
||||
// Check studyDate is added before
|
||||
if (loadedStudyDates.dates.indexOf(studyDate) < 0) {
|
||||
loadedStudyDates.dates.push(studyDate);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
// If study date is loaded into viewport, set timepointLoaded property in Timepoints collection as true
|
||||
// Else set timepointLoaded property as false
|
||||
if(loadedStudyDates.dates.length) {
|
||||
var timepoints = Timepoints.find({patientId: loadedStudyDates.patientId}).fetch();
|
||||
timepoints.forEach(function(timepoint){
|
||||
var timepointLoaded = false;
|
||||
if(loadedStudyDates.dates.indexOf(timepoint.timepointName) > -1) {
|
||||
timepointLoaded = true;
|
||||
}
|
||||
|
||||
Timepoints.update(timepoint._id,{
|
||||
$set: {
|
||||
timepointLoaded: timepointLoaded
|
||||
}
|
||||
});
|
||||
});
|
||||
$(".imageViewerViewport").each(function(viewportIndex, element) {
|
||||
var enabledElement = cornerstone.getEnabledElement(element);
|
||||
if (!enabledElement || !enabledElement.image) {
|
||||
return;
|
||||
}
|
||||
|
||||
var imageId = enabledElement.image.imageId;
|
||||
var study = cornerstoneTools.metaData.get('study', imageId);
|
||||
var studyDate = study.studyDate;
|
||||
loadedStudyDates.patientId = study.patientId;
|
||||
|
||||
// Check whether or not studyDate has been added before
|
||||
if (loadedStudyDates.dates.indexOf(studyDate) < 0) {
|
||||
loadedStudyDates.dates.push(studyDate);
|
||||
}
|
||||
});
|
||||
|
||||
// If study date is loaded into viewport, set timepointLoaded property in Timepoints collection as true
|
||||
// Else set timepointLoaded property as false
|
||||
if (loadedStudyDates.dates.length) {
|
||||
var timepoints = Timepoints.find({
|
||||
patientId: loadedStudyDates.patientId
|
||||
}).fetch();
|
||||
|
||||
timepoints.forEach(function(timepoint) {
|
||||
var timepointLoaded = false;
|
||||
if (loadedStudyDates.dates.indexOf(timepoint.timepointName) > -1) {
|
||||
timepointLoaded = true;
|
||||
}
|
||||
|
||||
Timepoints.update(timepoint._id, {
|
||||
$set: {
|
||||
timepointLoaded: timepointLoaded
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
@ -1,7 +1,7 @@
|
||||
<template name="lesionTableRow">
|
||||
<tr id="{{lesionNumber}}" class="lesionTableRow" data-measurementid="{{_id}}">
|
||||
<td class='lesionNumber'>{{number}}</td>
|
||||
<td class='location'>{{location}}</td>
|
||||
<td class='lesionNumber'>{{lesionNumber}}</td>
|
||||
<td class='location' tabindex="0">{{location}}</td>
|
||||
<td class='target'>{{#if isTarget}} Y {{else}} N {{/if}}</td>
|
||||
<!--Each time point as a column-->
|
||||
{{# each timepoints }}
|
||||
|
||||
@ -3,3 +3,40 @@ Template.lesionTableRow.helpers({
|
||||
return Timepoints.find({}, {sort: {timepointName: 1}});
|
||||
}
|
||||
});
|
||||
|
||||
function doneCallback(measurementData, deleteTool) {
|
||||
// If a Lesion or Non-Target is removed via a dialog
|
||||
// opened by the Lesion Table, we should clear the data for
|
||||
// the specified Timepoint Cell
|
||||
if (deleteTool === true) {
|
||||
Meteor.call("removeMeasurement", measurementData.id, function(error, response) {
|
||||
console.log('Removed!');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Template.lesionTableRow.events({
|
||||
'dblclick .location': function() {
|
||||
log.info('Double clicked on Lesion Location cell');
|
||||
|
||||
var measurementData = this;
|
||||
|
||||
// TODO = Fix this weird issue? Need to set toolData's ID properly..
|
||||
measurementData.id = this._id;
|
||||
|
||||
changeLesionLocationCallback(measurementData, null, doneCallback);
|
||||
},
|
||||
'keypress .location': function(e) {
|
||||
var keyCode = e.keyCode;
|
||||
if (keyCode === keys.DELETE ||
|
||||
(keyCode === keys.D && e.ctrlKey === true)) {
|
||||
var currentMeasurement = Template.parentData(1);
|
||||
var currentTimepointID = this.timepointID;
|
||||
|
||||
showConfirmDialog(function() {
|
||||
log.info('Removing Lesion: ' + currentMeasurement._id);
|
||||
clearMeasurementTimepointData(currentMeasurement._id, currentTimepointID);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
.lesionTableRow .location
|
||||
&:hover
|
||||
font-weight: bold
|
||||
@ -1,3 +1,11 @@
|
||||
<template name="lesionTableTimepointCell">
|
||||
<td class="lesionTableTimepointCell">{{longestDiameter}}</td>
|
||||
{{ #if hasDataAtThisTimepoint }}
|
||||
{{ #if isTarget }}
|
||||
<td class="lesionTableTimepointCell target" tabindex="1">{{displayData}}</td>
|
||||
{{ else }}
|
||||
<td class="lesionTableTimepointCell nonTarget" tabindex="2">{{displayData}}</td>
|
||||
{{ /if }}
|
||||
{{ else }}
|
||||
<td class="lesionTableTimepointCell empty"></td>
|
||||
{{ /if }}
|
||||
</template>
|
||||
@ -1,5 +1,13 @@
|
||||
Template.lesionTableTimepointCell.helpers({
|
||||
'longestDiameter': function() {
|
||||
'hasDataAtThisTimepoint': function() {
|
||||
// This simple function just checks whether or not timepoint data
|
||||
// exists for this Measurement at this Timepoint
|
||||
var lesionData = Template.parentData(1);
|
||||
return (lesionData &&
|
||||
lesionData.timepoints &&
|
||||
lesionData.timepoints[this.timepointID]);
|
||||
},
|
||||
'displayData': function() {
|
||||
// Search Measurements by lesion and timepoint
|
||||
var lesionData = Template.parentData(1);
|
||||
if (!lesionData ||
|
||||
@ -8,6 +16,75 @@ Template.lesionTableTimepointCell.helpers({
|
||||
return;
|
||||
}
|
||||
|
||||
return lesionData.timepoints[this.timepointID].longestDiameter;
|
||||
var data = lesionData.timepoints[this.timepointID];
|
||||
|
||||
if (lesionData.isTarget === true) {
|
||||
// TODO = Add short axis data here
|
||||
//return 'LD: ' + data.longestDiameter;
|
||||
return data.longestDiameter;
|
||||
} else {
|
||||
return data.response;
|
||||
}
|
||||
},
|
||||
'isTarget': function() {
|
||||
var lesionData = Template.parentData(1);
|
||||
return lesionData.isTarget;
|
||||
}
|
||||
});
|
||||
|
||||
function doneCallback(measurementData, deleteTool) {
|
||||
// If a Lesion or Non-Target is removed via a dialog
|
||||
// opened by the Lesion Table, we should clear the data for
|
||||
// the specified Timepoint Cell
|
||||
if (deleteTool === true) {
|
||||
log.info('Confirm clicked!');
|
||||
clearMeasurementTimepointData(measurementData.id, measurementData.timepointID);
|
||||
}
|
||||
}
|
||||
|
||||
// Delete a lesion if Ctrl+D or DELETE is pressed while a lesion is selected
|
||||
var keys = {
|
||||
D: 68,
|
||||
DELETE: 46
|
||||
};
|
||||
|
||||
Template.lesionTableTimepointCell.events({
|
||||
'dblclick .lesionTableTimepointCell': function() {
|
||||
log.info('Double clicked on a timepoint cell');
|
||||
// Search Measurements by lesion and timepoint
|
||||
var currentMeasurement = Template.parentData(1);
|
||||
|
||||
// Create some fake measurement data
|
||||
var currentTimepointID = this.timepointID;
|
||||
|
||||
var timepointData = currentMeasurement.timepoints[currentTimepointID];
|
||||
var measurementData = {
|
||||
id: currentMeasurement._id,
|
||||
timepointID: currentTimepointID,
|
||||
response: timepointData.response,
|
||||
imageId: timepointData.imageId,
|
||||
handles: timepointData.handles,
|
||||
seriesInstanceUid: timepointData.seriesInstanceUid,
|
||||
studyInstanceUid: timepointData.studyInstanceUid
|
||||
};
|
||||
|
||||
if (currentMeasurement.isTarget) {
|
||||
showConfirmDialog(function() {
|
||||
log.info('Confirm clicked!');
|
||||
clearMeasurementTimepointData(currentMeasurement._id, currentTimepointID);
|
||||
});
|
||||
} else {
|
||||
changeNonTargetResponse(measurementData, null, doneCallback);
|
||||
}
|
||||
},
|
||||
'keypress .lesionTableTimepointCell': function(e) {
|
||||
var keyCode = e.keyCode;
|
||||
if (keyCode === keys.DELETE ||
|
||||
(keyCode === keys.D && e.ctrlKey === true)) {
|
||||
var currentMeasurement = Template.parentData(1);
|
||||
log.info('Removing Lesion: ' + currentMeasurement._id);
|
||||
// TODO = Add confirm dialog first!
|
||||
clearMeasurementTimepointData(currentMeasurement._id, this.timepointID);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,8 @@
|
||||
.lesionTableTimepointCell
|
||||
&:hover
|
||||
font-weight: bold
|
||||
.nonTarget
|
||||
&:hover
|
||||
color: red
|
||||
|
||||
|
||||
@ -18,7 +18,11 @@
|
||||
<select id="selectNonTargetLesionLocationResponse">
|
||||
<option value="-1"></option>
|
||||
{{ #each locationResponses}}
|
||||
<option value='{{code}}'>{{code}} - {{text}}</option>
|
||||
{{ #if code }}
|
||||
<option value='{{code}}'>{{code}} - {{text}}</option>
|
||||
{{ else }}
|
||||
<option value={{text}}}>{{text}}</option>
|
||||
{{ /if }}
|
||||
{{ /each}}
|
||||
</select>
|
||||
</div>
|
||||
@ -38,7 +42,7 @@
|
||||
<select id="selectNonTargetLesionLocation">
|
||||
<option value="-1"></option>
|
||||
{{ #each lesionLocations}}
|
||||
<option value='{{_id}}'>{{location}}</option>
|
||||
<option value='{{_id}}' selected={{selected}}>{{location}}</option>
|
||||
{{ /each}}
|
||||
</select>
|
||||
</div>
|
||||
@ -47,13 +51,16 @@
|
||||
<select id="selectNonTargetLesionLocationResponse">
|
||||
<option value="-1"></option>
|
||||
{{ #each locationResponses}}
|
||||
<option value='{{code}}'>{{code}} - {{text}}</option>
|
||||
{{ #if code }}
|
||||
<option value={{code}} selected={{selected}}>{{code}} - {{text}}</option>
|
||||
{{ else }}
|
||||
<option value={{text}}} selected={{selected}}>{{text}}</option>
|
||||
{{ /if }}
|
||||
{{ /each}}
|
||||
</select>
|
||||
</div>
|
||||
<div class="locationOK">
|
||||
<button class="btn btn-link" id="removeLesion">Remove</button>
|
||||
|
||||
<button class="btn btn-primary" id="nonTargetLesionOK">OK</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -26,7 +26,7 @@ function setLesionNumberCallback(measurementData, eventData, doneCallback) {
|
||||
|
||||
// Get a lesion number for this lesion, depending on whether or not the same lesion previously
|
||||
// exists at a different timepoint
|
||||
var lesionNumber = measurementManagerDAL.getNewLesionNumber(measurementData.timepointID, isTarget=false);
|
||||
var lesionNumber = LesionManager.getNewLesionNumber(measurementData.timepointID, isTarget=false);
|
||||
measurementData.lesionNumber = lesionNumber;
|
||||
|
||||
// Set lesion number
|
||||
@ -63,19 +63,20 @@ function getLesionLocationCallback(measurementData, eventData) {
|
||||
|
||||
// Find out if this lesion number is already added in the lesion manager for another timepoint
|
||||
// If it is, disable selector location
|
||||
var locationUID = measurementManagerDAL.lesionNumberExists(measurementData);
|
||||
var locationUID = LesionManager.lesionNumberExists(measurementData);
|
||||
if (locationUID) {
|
||||
// Add an ID value to the tool data to link it to the Measurements collection
|
||||
measurementData.id = 'notready';
|
||||
|
||||
measurementData.locationUID = locationUID;
|
||||
|
||||
// Disable the selection of a new location
|
||||
disableLocationSelection(measurementData.locationUID);
|
||||
}
|
||||
|
||||
// Disable selector location to prevent selecting a new location
|
||||
function disableLocationSelection(locationUID) {
|
||||
var locationName = measurementManagerDAL.getLocationName(locationUID);
|
||||
var locationName = LesionManager.getLocationName(locationUID);
|
||||
selectorLocation.find('option').each(function() {
|
||||
if ($(this).text() === locationName) {
|
||||
// Select location in locations dropdown list
|
||||
@ -88,8 +89,8 @@ function getLesionLocationCallback(measurementData, eventData) {
|
||||
|
||||
// Show the nonTargetLesion dialog above
|
||||
var dialogProperty = {
|
||||
top: eventData.currentPoints.page.y,
|
||||
left: eventData.currentPoints.page.x,
|
||||
top: eventData.currentPoints.page.y - dialog.outerHeight() - 40,
|
||||
left: eventData.currentPoints.page.x - dialog.outerWidth() / 2,
|
||||
display: 'block'
|
||||
};
|
||||
|
||||
@ -107,7 +108,7 @@ function getLesionLocationCallback(measurementData, eventData) {
|
||||
dialog.css(dialogProperty);
|
||||
}
|
||||
|
||||
function changeLesionLocationCallback(measurementData, eventData, doneCallback) {
|
||||
changeNonTargetLocationCallback = function(measurementData, eventData, doneCallback) {
|
||||
Template.nonTargetLesionDialog.measurementData = measurementData;
|
||||
Template.nonTargetLesionDialog.doneCallback = doneCallback;
|
||||
|
||||
@ -132,7 +133,6 @@ function changeLesionLocationCallback(measurementData, eventData, doneCallback)
|
||||
var selectorLocation = dialog.find("select#selectNonTargetLesionLocation");
|
||||
var selectorResponse = dialog.find("select#selectNonTargetLesionLocationResponse");
|
||||
|
||||
log.info(measurementData);
|
||||
selectorLocation.find("option:first").prop("selected", "selected");
|
||||
selectorResponse.find("option:first").prop("selected", "selected");
|
||||
|
||||
@ -141,29 +141,75 @@ function changeLesionLocationCallback(measurementData, eventData, doneCallback)
|
||||
|
||||
// Show the nonTargetLesion dialog above
|
||||
var dialogProperty = {
|
||||
top: eventData.currentPoints.page.y,
|
||||
left: eventData.currentPoints.page.x,
|
||||
display: 'block'
|
||||
};
|
||||
|
||||
// Device is touch device or not
|
||||
// If device is touch device, set position center of screen vertically and horizontally
|
||||
if (isTouchDevice()) {
|
||||
if (!eventData || isTouchDevice()) {
|
||||
// add dialogMobile class to provide a black,transparent background
|
||||
dialog.addClass("dialogMobile");
|
||||
dialogProperty.top = 0;
|
||||
dialogProperty.left = 0;
|
||||
dialogProperty.right = 0;
|
||||
dialogProperty.bottom = 0;
|
||||
} else {
|
||||
dialogProperty.top = eventData.currentPoints.page.y - dialog.outerHeight() - 40;
|
||||
dialogProperty.left = eventData.currentPoints.page.x - dialog.outerWidth() / 2;
|
||||
}
|
||||
|
||||
dialog.css(dialogProperty);
|
||||
}
|
||||
|
||||
var measurement = Measurements.findOne(measurementData.id);
|
||||
if (!measurement) {
|
||||
return;
|
||||
}
|
||||
|
||||
LesionLocations.update({},
|
||||
{$set: {selected: false}},
|
||||
{ multi: true });
|
||||
|
||||
var currentLocation = LesionLocations.findOne({
|
||||
id: measurement.locationId
|
||||
});
|
||||
|
||||
if (!currentLocation) {
|
||||
return;
|
||||
}
|
||||
|
||||
LesionLocations.update(currentLocation._id, {
|
||||
$set: {
|
||||
selected: true
|
||||
}
|
||||
});
|
||||
|
||||
LocationResponses.update({},
|
||||
{$set: {selected: false}},
|
||||
{ multi: true });
|
||||
|
||||
var response = measurement.timepoints[measurementData.timepointID].response;
|
||||
|
||||
// TODO = Standardize this. Searching by code probably isn't the best, we should use
|
||||
// some sort of UID
|
||||
var currentResponse = LocationResponses.findOne({
|
||||
code: response
|
||||
});
|
||||
|
||||
if (!currentResponse) {
|
||||
return;
|
||||
}
|
||||
|
||||
LocationResponses.update(currentResponse._id, {
|
||||
$set: {
|
||||
selected: true
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var config = {
|
||||
setLesionNumberCallback: setLesionNumberCallback,
|
||||
getLesionLocationCallback: getLesionLocationCallback,
|
||||
changeLesionLocationCallback: changeLesionLocationCallback
|
||||
changeLesionLocationCallback: changeNonTargetLocationCallback
|
||||
};
|
||||
|
||||
cornerstoneTools.nonTarget.setConfiguration(config);
|
||||
@ -205,22 +251,8 @@ Template.nonTargetLesionDialog.events({
|
||||
id = PatientLocations.insert({location: locationObj.location});
|
||||
}
|
||||
|
||||
if (!measurementData.id) {
|
||||
// Add an ID value to the tool data to link it to the Measurements collection
|
||||
measurementData.id = 'notready';
|
||||
|
||||
// Link locationUID with active lesion measurementData
|
||||
measurementData.locationUID = id;
|
||||
|
||||
/// Set the isTarget value to true, since this is the target-lesion dialog callback
|
||||
measurementData.isTarget = false;
|
||||
|
||||
// measurementText is set from location response list
|
||||
measurementData.measurementText = responseOptionId;
|
||||
|
||||
// Adds lesion data to timepoints array
|
||||
measurementManagerDAL.addLesionData(measurementData);
|
||||
} else {
|
||||
if (measurementData.id) {
|
||||
// Update the location data
|
||||
Measurements.update(measurementData.id, {
|
||||
$set: {
|
||||
location: locationObj.location,
|
||||
@ -228,8 +260,24 @@ Template.nonTargetLesionDialog.events({
|
||||
locationUID: id
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Add an ID value to the tool data to link it to the Measurements collection
|
||||
measurementData.id = 'notready';
|
||||
}
|
||||
|
||||
// Link locationUID with active lesion measurementData
|
||||
measurementData.locationUID = id;
|
||||
|
||||
/// Set the isTarget value to true, since this is the target-lesion dialog callback
|
||||
measurementData.isTarget = false;
|
||||
|
||||
// measurementText is set from location response list
|
||||
measurementData.measurementText = responseOptionId;
|
||||
measurementData.response = responseOptionId;
|
||||
|
||||
// Adds lesion data to timepoints array
|
||||
LesionManager.updateLesionData(measurementData);
|
||||
|
||||
// Close the dialog
|
||||
closeHandler(dialog);
|
||||
},
|
||||
@ -238,10 +286,12 @@ Template.nonTargetLesionDialog.events({
|
||||
var doneCallback = Template.nonTargetLesionDialog.doneCallback;
|
||||
var dialog = Template.nonTargetLesionDialog.dialog;
|
||||
|
||||
if (doneCallback && typeof doneCallback === 'function') {
|
||||
var deleteTool = true;
|
||||
doneCallback(measurementData, deleteTool);
|
||||
}
|
||||
showConfirmDialog(function() {
|
||||
if (doneCallback && typeof doneCallback === 'function') {
|
||||
var deleteTool = true;
|
||||
doneCallback(measurementData, deleteTool);
|
||||
}
|
||||
});
|
||||
|
||||
closeHandler(dialog);
|
||||
},
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
<template name="nonTargetResponseDialog">
|
||||
<div id="nonTargetResponseDialog">
|
||||
<div class="dialogHeader">
|
||||
<h5>Select Response</h5>
|
||||
</div>
|
||||
<div class="dialogContent">
|
||||
<div class="locationResponse">
|
||||
<label>Response</label>
|
||||
<select id="selectNonTargetLesionLocationResponse">
|
||||
<option value="-1"></option>
|
||||
{{ #each locationResponses}}
|
||||
{{ #if code }}
|
||||
<option value={{code}} selected={{selected}}>{{code}} - {{text}}</option>
|
||||
{{ else }}
|
||||
<option value={{text}} selected={{selected}}>{{text}}</option>
|
||||
{{ /if }}
|
||||
{{ /each}}
|
||||
</select>
|
||||
</div>
|
||||
<div class="locationOK">
|
||||
<button class="btn btn-link" id="removeLesion">Remove</button>
|
||||
<button class="btn btn-primary" id="nonTargetLesionOK">OK</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@ -0,0 +1,143 @@
|
||||
function closeHandler(dialog) {
|
||||
// Hide the lesion dialog
|
||||
$(dialog).css('display', 'none');
|
||||
|
||||
// Remove the backdrop
|
||||
$(".removableBackdrop").remove();
|
||||
}
|
||||
|
||||
changeNonTargetResponse = function(measurementData, eventData, doneCallback) {
|
||||
Template.nonTargetResponseDialog.measurementData = measurementData;
|
||||
Template.nonTargetResponseDialog.doneCallback = doneCallback;
|
||||
|
||||
// Get the non-target lesion location dialog
|
||||
var dialog = $("#nonTargetResponseDialog");
|
||||
Template.nonTargetResponseDialog.dialog = dialog;
|
||||
|
||||
// Show the backdrop
|
||||
UI.render(Template.removableBackdrop, document.body);
|
||||
|
||||
// Make sure the context menu is closed when the user clicks away
|
||||
$(".removableBackdrop").one('mousedown touchstart', function() {
|
||||
closeHandler(dialog);
|
||||
|
||||
if (doneCallback && typeof doneCallback === 'function') {
|
||||
var deleteTool = true;
|
||||
doneCallback(measurementData, deleteTool);
|
||||
}
|
||||
});
|
||||
|
||||
// Show the nonTargetLesion dialog above
|
||||
var dialogProperty = {
|
||||
display: 'block'
|
||||
};
|
||||
|
||||
// Device is touch device or not
|
||||
// If device is touch device, set position center of screen vertically and horizontally
|
||||
if (!eventData || isTouchDevice()) {
|
||||
// add dialogMobile class to provide a black,transparent background
|
||||
dialog.addClass("dialogMobile");
|
||||
dialogProperty.top = 0;
|
||||
dialogProperty.left = 0;
|
||||
dialogProperty.right = 0;
|
||||
dialogProperty.bottom = 0;
|
||||
} else {
|
||||
dialogProperty.top = eventData.currentPoints.page.y - dialog.outerHeight() - 40;
|
||||
dialogProperty.left = eventData.currentPoints.page.x - dialog.outerWidth() / 2;
|
||||
}
|
||||
|
||||
dialog.css(dialogProperty);
|
||||
|
||||
var measurement = Measurements.findOne(measurementData.id);
|
||||
if (!measurement) {
|
||||
return;
|
||||
}
|
||||
|
||||
var response = measurement.timepoints[measurementData.timepointID].response;
|
||||
|
||||
// TODO = Standardize this. Searching by code probably isn't the best, we should use
|
||||
// some sort of UID
|
||||
var currentResponse = LocationResponses.findOne({
|
||||
code: response
|
||||
});
|
||||
|
||||
if (!currentResponse) {
|
||||
return;
|
||||
}
|
||||
|
||||
LocationResponses.update(currentResponse._id, {
|
||||
$set: {
|
||||
selected: true
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Template.nonTargetResponseDialog.events({
|
||||
'click #nonTargetLesionOK': function() {
|
||||
var dialog = Template.nonTargetResponseDialog.dialog;
|
||||
var measurementData = Template.nonTargetResponseDialog.measurementData;
|
||||
|
||||
// Find the select option box
|
||||
var selectorResponse = dialog.find("select#selectNonTargetLesionLocationResponse");
|
||||
|
||||
// Get the current value of the selector
|
||||
var responseOptionId = selectorResponse.find("option:selected").val();
|
||||
|
||||
// If the selected response option is still the default (-1)
|
||||
// then stop here
|
||||
if (responseOptionId < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!measurementData.id) {
|
||||
// Add an ID value to the tool data to link it to the Measurements collection
|
||||
measurementData.id = 'notready';
|
||||
}
|
||||
|
||||
/// Set the isTarget value to true, since this is the target-lesion dialog callback
|
||||
measurementData.isTarget = false;
|
||||
|
||||
// measurementText is set from location response list
|
||||
measurementData.measurementText = responseOptionId;
|
||||
measurementData.response = responseOptionId;
|
||||
|
||||
// Adds lesion data to timepoints array
|
||||
LesionManager.updateLesionData(measurementData);
|
||||
|
||||
// Close the dialog
|
||||
closeHandler(dialog);
|
||||
},
|
||||
'click #removeLesion': function() {
|
||||
var measurementData = Template.nonTargetResponseDialog.measurementData;
|
||||
var doneCallback = Template.nonTargetResponseDialog.doneCallback;
|
||||
var dialog = Template.nonTargetResponseDialog.dialog;
|
||||
|
||||
showConfirmDialog(function() {
|
||||
if (doneCallback && typeof doneCallback === 'function') {
|
||||
var deleteTool = true;
|
||||
doneCallback(measurementData, deleteTool);
|
||||
}
|
||||
});
|
||||
|
||||
closeHandler(dialog);
|
||||
},
|
||||
'click #btnCloseLesionPopup': function() {
|
||||
var dialog = Template.nonTargetResponseDialog.dialog;
|
||||
closeHandler(dialog);
|
||||
},
|
||||
'keypress #nonTargetResponseDialog': function(e) {
|
||||
var dialog = Template.nonTargetResponseDialog.dialog;
|
||||
|
||||
// If Enter is pressed, close the dialog
|
||||
if (e.which === 13) {
|
||||
closeHandler(dialog);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Template.nonTargetResponseDialog.helpers({
|
||||
'locationResponses': function() {
|
||||
return LocationResponses.find();
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,23 @@
|
||||
#nonTargetResponseDialog
|
||||
display: none
|
||||
position: absolute
|
||||
top: 0
|
||||
bottom: 0
|
||||
left: 0
|
||||
right: 0
|
||||
z-index: 100
|
||||
width: 300px
|
||||
height: 150px
|
||||
border-radius: 5px
|
||||
padding: 10px 20px 10px 20px
|
||||
background-color: rgba(255,255,255,1)
|
||||
|
||||
#selectNonTargetLesionLocationResponse
|
||||
width: 100%
|
||||
|
||||
.dialogContent, .locationResponse
|
||||
margin-bottom: 20px
|
||||
|
||||
.locationOK
|
||||
text-align: center
|
||||
|
||||
96
Packages/lesiontracker/lib/activateLesion.js
Normal file
96
Packages/lesiontracker/lib/activateLesion.js
Normal file
@ -0,0 +1,96 @@
|
||||
/**
|
||||
* Activates a set of lesions when lesion table row is clicked
|
||||
*
|
||||
* @param measurementId The unique key for a specific Measurement
|
||||
*/
|
||||
activateLesion = function(measurementId, templateData) {
|
||||
|
||||
// Set background color of selected row
|
||||
$("tr[data-measurementid=" + measurementId + "]").addClass("selectedRow").siblings().removeClass("selectedRow");
|
||||
|
||||
var measurementData = Measurements.findOne(measurementId);
|
||||
|
||||
// If there is no measurement with this ID, stop here
|
||||
if (!measurementData) {
|
||||
log.warn('No Measurements entry associated to an ID in a lesion table row');
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the timepoint data from this Measurement
|
||||
var timepoints = measurementData.timepoints;
|
||||
|
||||
// Get all non-dummy timepoint entries in the Measurement
|
||||
// TODO=Re-evaluate this approach to populating viewports with timepoints
|
||||
// What is the desired behaviour here?
|
||||
var timepointsWithEntries = [];
|
||||
Object.keys(timepoints).forEach(function(key) {
|
||||
var timepoint = timepoints[key];
|
||||
|
||||
if (timepoint.imageId === "" ||
|
||||
timepoint.studyInstanceUid === "" ||
|
||||
timepoint.seriesInstanceUid === "") {
|
||||
return;
|
||||
}
|
||||
|
||||
timepointsWithEntries.push(timepoint);
|
||||
});
|
||||
|
||||
// If there are no non-dummy timepoint entries, stop here
|
||||
if (!timepointsWithEntries.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Loop through the viewports and display each timepoint
|
||||
$(".imageViewerViewport").each(function(viewportIndex, element) {
|
||||
// Stop if we run out of timepoints before viewports
|
||||
if (viewportIndex >= timepointsWithEntries.length) {
|
||||
// Update the element anyway, to remove any other highlights that are present
|
||||
deactivateAllToolData(element, 'lesion');
|
||||
deactivateAllToolData(element, 'nonTarget');
|
||||
cornerstone.updateImage(element);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Find measurements related to the Nth timepoint
|
||||
// TODO=Re-evaluate this approach to populating viewports with timepoints
|
||||
// What is the desired behaviour here?
|
||||
var measurementAtTimepoint = timepointsWithEntries[viewportIndex];
|
||||
|
||||
// Find the image that is currently in this viewport
|
||||
var enabledElement = cornerstone.getEnabledElement(element);
|
||||
if (!enabledElement || !enabledElement.image) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If there is no measurement data to display, stop here
|
||||
if (!measurementAtTimepoint) {
|
||||
// Update the element anyway, to remove any other highlights that are present
|
||||
deactivateAllToolData(element, 'lesion');
|
||||
deactivateAllToolData(element, 'nonTarget');
|
||||
cornerstone.updateImage(element);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check which study and series are required to display the measurement at this timepoint
|
||||
var requiredSeriesData = {
|
||||
seriesInstanceUid: measurementAtTimepoint.seriesInstanceUid,
|
||||
studyInstanceUid: measurementAtTimepoint.studyInstanceUid
|
||||
};
|
||||
|
||||
// Check if the study / series we need is already the one in the viewport
|
||||
var currentSeriesData = OHIF.viewer.loadedSeriesData[viewportIndex];
|
||||
if (currentSeriesData.seriesInstanceUid === measurementAtTimepoint.seriesInstanceUid &&
|
||||
currentSeriesData.studyInstanceUid === measurementAtTimepoint.studyInstanceUid) {
|
||||
// If it is, activate the measurements in this viewport and stop here
|
||||
activateMeasurements(element, measurementId, templateData, viewportIndex);
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, re-render the viewport with the required study/series, then
|
||||
// add an onRendered callback to activate the measurements
|
||||
rerenderViewportWithNewSeries(element, requiredSeriesData, function(element) {
|
||||
activateMeasurements(element, measurementId, templateData, viewportIndex);
|
||||
});
|
||||
});
|
||||
};
|
||||
83
Packages/lesiontracker/lib/activateMeasurements.js
Normal file
83
Packages/lesiontracker/lib/activateMeasurements.js
Normal file
@ -0,0 +1,83 @@
|
||||
/**
|
||||
* Switch to the image of the correct image index
|
||||
* Activate the selected measurement on the switched image (color to be green)
|
||||
* Deactivate all other measurements on the switched image (color to be white)
|
||||
*/
|
||||
activateMeasurements = function(element, measurementId, templateData, viewportIndex) {
|
||||
// TODO=Switch this to use the new CornerstoneToolMeasurementModified event,
|
||||
// Once it has 'modified on activation' set up
|
||||
|
||||
var enabledElement = cornerstone.getEnabledElement(element);
|
||||
var imageId = enabledElement.image.imageId;
|
||||
var timepointData = getTimepointObject(imageId);
|
||||
var measurementData = Measurements.findOne(measurementId);
|
||||
|
||||
var measurementAtTimepoint = measurementData.timepoints[timepointData.timepointID];
|
||||
if (!measurementAtTimepoint) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If type is active, load image and activate lesion
|
||||
// If type is inactive, update lesions of enabledElement as inactive
|
||||
//TODO: !stackData.currentImageIdIndex returns incorrect value
|
||||
// Get loadedSeriesData currentImageIdIndex from ViewerData
|
||||
var contentId = templateData.contentId;
|
||||
var viewerData = ViewerData[contentId];
|
||||
var elementCurrentImageIdIndex = viewerData.loadedSeriesData[viewportIndex].currentImageIdIndex;
|
||||
|
||||
var stackToolDataSource = cornerstoneTools.getToolState(element, 'stack');
|
||||
var stackData = stackToolDataSource.data[0];
|
||||
var imageIds = stackData.imageIds;
|
||||
var imageIdIndex = imageIds.indexOf(measurementAtTimepoint.imageId);
|
||||
|
||||
if (imageIdIndex < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (imageIdIndex === elementCurrentImageIdIndex) {
|
||||
activateTool(element, measurementData, timepointData.timepointID);
|
||||
} else {
|
||||
cornerstone.loadAndCacheImage(imageIds[imageIdIndex]).then(function(image) {
|
||||
cornerstone.displayImage(element, image);
|
||||
activateTool(element, measurementData, timepointData.timepointID);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Activates a specific tool data instance and deactivates all other
|
||||
* target and non-target measurement data
|
||||
*
|
||||
* @param element
|
||||
* @param measurementData
|
||||
* @param timepointID
|
||||
*/
|
||||
function activateTool(element, measurementData, timepointID) {
|
||||
deactivateAllToolData(element, 'lesion');
|
||||
deactivateAllToolData(element, 'nonTarget');
|
||||
|
||||
var toolType = measurementData.isTarget ? 'lesion' : 'nonTarget';
|
||||
var toolData = cornerstoneTools.getToolState(element, toolType);
|
||||
if (!toolData) {
|
||||
return;
|
||||
}
|
||||
|
||||
var measurementAtTimepoint = measurementData.timepoints[timepointID];
|
||||
|
||||
for (var i = 0; i < toolData.data.length; i++) {
|
||||
data = toolData.data[i];
|
||||
|
||||
// When click a row of table measurements, measurement will be active and color will be green
|
||||
// TODO= Remove this with the measurementId once it is in the tool data
|
||||
if (data.seriesInstanceUid === measurementAtTimepoint.seriesInstanceUid &&
|
||||
data.studyInstanceUid === measurementAtTimepoint.studyInstanceUid &&
|
||||
data.lesionNumber === measurementData.lesionNumber &&
|
||||
data.isTarget == measurementData.isTarget) {
|
||||
|
||||
data.active = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
34
Packages/lesiontracker/lib/clearMeasurementTimepointData.js
Normal file
34
Packages/lesiontracker/lib/clearMeasurementTimepointData.js
Normal file
@ -0,0 +1,34 @@
|
||||
clearMeasurementTimepointData = function(measurementId, timepointId) {
|
||||
var data = Measurements.findOne(measurementId);
|
||||
|
||||
// Check that this Measurement actually contains data for this timepoint
|
||||
if (!data || !data.timepoints[timepointId]) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear the Measurement data for this timepoint
|
||||
var imageId = data.timepoints[timepointId].imageId;
|
||||
var toolType = data.isTarget ? 'lesion' : 'nonTarget';
|
||||
removeToolDataWithMeasurementId(imageId, toolType, measurementId);
|
||||
|
||||
// Update any viewports that are currently displaying this imageId
|
||||
var enabledElements = cornerstone.getEnabledElementsByImageId(imageId);
|
||||
enabledElements.forEach(function(enabledElement) {
|
||||
cornerstone.updateImage(enabledElement.element);
|
||||
});
|
||||
|
||||
delete data.timepoints[timepointId];
|
||||
|
||||
if (Object.keys(data.timepoints).length === 0) {
|
||||
Meteor.call("removeMeasurement", measurementId, function(error, response) {
|
||||
console.log('Removed!');
|
||||
});
|
||||
} else {
|
||||
// Update the Timepoint object of the Measurement document
|
||||
Measurements.update(measurementId, {
|
||||
$set: {
|
||||
timepoints: data.timepoints
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
18
Packages/lesiontracker/lib/deactivateAllToolData.js
Normal file
18
Packages/lesiontracker/lib/deactivateAllToolData.js
Normal file
@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Sets all tool data entries value for 'active' to false
|
||||
* This is used to remove the active color on entire sets of tools
|
||||
*
|
||||
* @param element The Cornerstone element that is being used
|
||||
* @param toolType The tooltype of the tools that will be deactivated
|
||||
*/
|
||||
deactivateAllToolData = function(element, toolType) {
|
||||
var toolData = cornerstoneTools.getToolState(element, toolType);
|
||||
if (!toolData) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < toolData.data.length; i++) {
|
||||
var data = toolData.data[i];
|
||||
data.active = false;
|
||||
}
|
||||
};
|
||||
13
Packages/lesiontracker/lib/getTimepointObject.js
Normal file
13
Packages/lesiontracker/lib/getTimepointObject.js
Normal file
@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Returns timepoint object given a specified imageId
|
||||
*
|
||||
* @param imageId
|
||||
* @returns {*|{}} Timepoint object
|
||||
*/
|
||||
getTimepointObject = function(imageId) {
|
||||
var study = cornerstoneTools.metaData.get('study', imageId);
|
||||
if (!study) {
|
||||
return;
|
||||
}
|
||||
return Timepoints.findOne({timepointName: study.studyDate});
|
||||
};
|
||||
@ -0,0 +1,28 @@
|
||||
removeToolDataWithMeasurementId = function(imageId, toolType, measurementId) {
|
||||
var toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.toolState;
|
||||
|
||||
// Find any related toolData
|
||||
if (!toolState[imageId] || !toolState[imageId][toolType]) {
|
||||
return;
|
||||
}
|
||||
|
||||
var toolData = toolState[imageId][toolType].data;
|
||||
if (!toolData.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Search toolData for entries linked to the specified Measurement
|
||||
var toRemove = [];
|
||||
toolData.forEach(function(measurement, index) {
|
||||
if (measurement.id === measurementId) {
|
||||
toRemove.push(index);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// If any toolData entries need to be removed, splice them from
|
||||
// the toolData array
|
||||
toRemove.forEach(function(index) {
|
||||
toolData.splice(index, 1);
|
||||
});
|
||||
};
|
||||
@ -15,7 +15,7 @@ toggleLesionTrackerTools = function() {
|
||||
|
||||
// Hide the tools (set them all to disabled)
|
||||
var toolDefaultStates = {
|
||||
activate: [],
|
||||
activate: ['deleteLesionKeyboardTool'],
|
||||
deactivate: [],
|
||||
enable: [],
|
||||
disable: ['lesion', 'nonTarget', 'biDirectional']
|
||||
|
||||
@ -23,7 +23,8 @@ Package.onUse(function (api) {
|
||||
api.addFiles('client/compatibility/lesionTool.js', 'client', {bare: true});
|
||||
api.addFiles('client/compatibility/nonTargetTool.js', 'client', {bare: true});
|
||||
api.addFiles('client/compatibility/biDirectionalTool.js', 'client', {bare: true});
|
||||
api.addFiles('client/compatibility/measurementManagerDAL.js', 'client', {bare: true});
|
||||
api.addFiles('client/compatibility/deleteLesionKeyboardTool.js', 'client', {bare: true});
|
||||
api.addFiles('client/compatibility/LesionManager.js', 'client', {bare: true});
|
||||
|
||||
api.addFiles('client/components/lesionLocationDialog/lesionLocationDialog.html', 'client');
|
||||
api.addFiles('client/components/lesionLocationDialog/lesionLocationDialog.js', 'client');
|
||||
@ -37,6 +38,7 @@ Package.onUse(function (api) {
|
||||
api.addFiles('client/components/lesionTableRow/lesionTableRow.js', 'client');
|
||||
|
||||
api.addFiles('client/components/lesionTableTimepointCell/lesionTableTimepointCell.html', 'client');
|
||||
api.addFiles('client/components/lesionTableTimepointCell/lesionTableTimepointCell.styl', 'client');
|
||||
api.addFiles('client/components/lesionTableTimepointCell/lesionTableTimepointCell.js', 'client');
|
||||
|
||||
api.addFiles('client/components/lesionTableTimepointHeader/lesionTableTimepointHeader.html', 'client');
|
||||
@ -51,6 +53,14 @@ Package.onUse(function (api) {
|
||||
api.addFiles('client/components/studyDateList/studyDateList.styl', 'client');
|
||||
api.addFiles('client/components/studyDateList/studyDateList.js', 'client');
|
||||
|
||||
api.addFiles('client/components/confirmDeleteDialog/confirmDeleteDialog.html', 'client');
|
||||
api.addFiles('client/components/confirmDeleteDialog/confirmDeleteDialog.styl', 'client');
|
||||
api.addFiles('client/components/confirmDeleteDialog/confirmDeleteDialog.js', 'client');
|
||||
|
||||
api.addFiles('client/components/nonTargetResponseDialog/nonTargetResponseDialog.html', 'client');
|
||||
api.addFiles('client/components/nonTargetResponseDialog/nonTargetResponseDialog.styl', 'client');
|
||||
api.addFiles('client/components/nonTargetResponseDialog/nonTargetResponseDialog.js', 'client');
|
||||
|
||||
api.addFiles('client/components/timepointTextDialog/timepointTextDialog.html', 'client');
|
||||
api.addFiles('client/components/timepointTextDialog/timepointTextDialog.styl', 'client');
|
||||
|
||||
@ -64,15 +74,26 @@ Package.onUse(function (api) {
|
||||
// Library functions
|
||||
api.addFiles('lib/uuid.js', 'client');
|
||||
api.addFiles('lib/toggleLesionTrackerTools.js', 'client');
|
||||
api.addFiles('lib/clearMeasurementTimepointData.js', 'client');
|
||||
api.addFiles('lib/removeToolDataWithMeasurementId.js', 'client');
|
||||
api.addFiles('lib/getTimepointObject.js', 'client');
|
||||
api.addFiles('lib/activateMeasurements.js', 'client');
|
||||
api.addFiles('lib/activateLesion.js', 'client');
|
||||
api.addFiles('lib/deactivateAllToolData.js', 'client');
|
||||
api.addFiles('lib/clearTools.js', 'client');
|
||||
api.addFiles('lib/mathUtils.js', 'client');
|
||||
|
||||
|
||||
// Export lesionTable function for activate measurements
|
||||
api.export('activateLesion','client');
|
||||
api.export('activateMeasurements','client');
|
||||
api.export('deactivateAllToolData','client');
|
||||
api.export('toggleLesionTrackerTools', 'client');
|
||||
api.export('clearMeasurementTimepointData', 'client');
|
||||
api.export('removeToolDataWithMeasurementId', 'client');
|
||||
api.export('getTimepointObject', 'client');
|
||||
api.export('clearTools', 'client');
|
||||
api.export('measurementManagerDAL', 'client');
|
||||
api.export('LesionManager', 'client');
|
||||
|
||||
// Export mathUtils functions
|
||||
api.export('sign','client');
|
||||
@ -80,7 +101,6 @@ Package.onUse(function (api) {
|
||||
api.export('getDistance','client');
|
||||
api.export('getDistanceFromPointToLine','client');
|
||||
|
||||
|
||||
// Export client-side collections
|
||||
api.export('LesionLocations', 'client');
|
||||
api.export('LocationResponses', 'client');
|
||||
|
||||
@ -1,23 +1,27 @@
|
||||
Meteor.publish('timepoints', function(patientId) {
|
||||
console.log('Publish timepoints');
|
||||
console.log('patientId ' + patientId);
|
||||
return Timepoints.find({patientId: patientId});
|
||||
return Timepoints.find({
|
||||
patientId: patientId
|
||||
});
|
||||
});
|
||||
|
||||
Meteor.publish('measurements', function(patientId) {
|
||||
console.log('Publish measurements');
|
||||
console.log('patientId ' + patientId);
|
||||
return Measurements.find({patientId: patientId});
|
||||
return Measurements.find({
|
||||
patientId: patientId
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// Temporary fix to drop all Collections on server restart
|
||||
// http://stackoverflow.com/questions/23891631/meteor-how-can-i-drop-all-mongo-collections-and-clear-all-data-on-startup
|
||||
Meteor.startup(function(){
|
||||
var globalObject=Meteor.isClient?window:global;
|
||||
for(var property in globalObject){
|
||||
var object=globalObject[property];
|
||||
if(object instanceof Meteor.Collection){
|
||||
Meteor.startup(function() {
|
||||
var globalObject = Meteor.isClient ? window : global;
|
||||
for (var property in globalObject) {
|
||||
var object = globalObject[property];
|
||||
if (object instanceof Meteor.Collection) {
|
||||
object.remove({});
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,21 +1,21 @@
|
||||
|
||||
Meteor.methods({
|
||||
"removeMeasurementsByPatientId": function(patientId) {
|
||||
Measurements.remove(
|
||||
{patientId: patientId}
|
||||
);
|
||||
"removeMeasurement": function(id) {
|
||||
console.log(Measurements.find().fetch());
|
||||
console.log("Removing: " + id);
|
||||
Measurements.remove(id);
|
||||
console.log(Measurements.find().fetch());
|
||||
},
|
||||
|
||||
"removeMeasurementsByPatientId": function(patientId) {
|
||||
Measurements.remove({patientId: patientId});
|
||||
},
|
||||
// TODO= Check where this is used? Seems like nowhere..
|
||||
"removePatientMeasurement": function(lesionObject) {
|
||||
|
||||
// Find patient data
|
||||
var measurementData = Measurements.findOne(
|
||||
{
|
||||
patientId: lesionObject.patientId,
|
||||
isTarget: lesionObject.isTarget,
|
||||
lesionNumber: lesionObject.lesionNumber
|
||||
}
|
||||
);
|
||||
var measurementData = Measurements.findOne({
|
||||
patientId: lesionObject.patientId,
|
||||
isTarget: lesionObject.isTarget,
|
||||
lesionNumber: lesionObject.lesionNumber
|
||||
});
|
||||
|
||||
// Get timepoints
|
||||
var timepoints = measurementData.timepoints;
|
||||
@ -23,41 +23,32 @@ Meteor.methods({
|
||||
// Create an array to hold keys of timepoints
|
||||
var timepointsIds = Object.keys(timepoints).slice(0);
|
||||
|
||||
timepointsIds.forEach(function(timepointId){
|
||||
if(timepointId === lesionObject.timepointId) {
|
||||
delete timepoints[timepointId];
|
||||
}
|
||||
});
|
||||
timepointsIds.forEach(function(timepointId) {
|
||||
if (timepointId === lesionObject.timepointId) {
|
||||
delete timepoints[timepointId];
|
||||
}
|
||||
});
|
||||
|
||||
var newTimepointsIds = Object.keys(timepoints);
|
||||
// If there is no timepoints object, remove measurement data
|
||||
if(newTimepointsIds.length) {
|
||||
if (newTimepointsIds.length) {
|
||||
//Update measurement timepoints
|
||||
Measurements.update(
|
||||
{
|
||||
patientId: lesionObject.patientId,
|
||||
isTarget: lesionObject.isTarget,
|
||||
lesionNumber: lesionObject.lesionNumber
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
timepoints: timepoints
|
||||
}
|
||||
Measurements.update({
|
||||
patientId: lesionObject.patientId,
|
||||
isTarget: lesionObject.isTarget,
|
||||
lesionNumber: lesionObject.lesionNumber
|
||||
}, {
|
||||
$set: {
|
||||
timepoints: timepoints
|
||||
}
|
||||
);
|
||||
}else {
|
||||
});
|
||||
} else {
|
||||
// Remove all data
|
||||
Measurements.remove(
|
||||
{
|
||||
patientId: lesionObject.patientId,
|
||||
isTarget: lesionObject.isTarget,
|
||||
lesionNumber: lesionObject.lesionNumber
|
||||
}
|
||||
);
|
||||
Measurements.remove({
|
||||
patientId: lesionObject.patientId,
|
||||
isTarget: lesionObject.isTarget,
|
||||
lesionNumber: lesionObject.lesionNumber
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
@ -2,7 +2,8 @@
|
||||
<div class='imageViewerViewport'
|
||||
oncontextmenu='return false;'
|
||||
unselectable='on'
|
||||
onselectstart='return false;'>
|
||||
onselectstart='return false;'
|
||||
tabindex='0'>
|
||||
</div>
|
||||
<div class='viewportInstructions'>
|
||||
Please drag a stack here to view images.
|
||||
|
||||
@ -180,10 +180,11 @@ function loadSeriesIntoViewport(data, templateData) {
|
||||
cornerstoneTools.clearToolState(element, 'stack');
|
||||
cornerstoneTools.addToolState(element, 'stack', stack);
|
||||
|
||||
// Enable mouse, mouseWheel, and touch input on the element
|
||||
// Enable mouse, mouseWheel, touch, and keyboard input on the element
|
||||
cornerstoneTools.mouseInput.enable(element);
|
||||
cornerstoneTools.touchInput.enable(element);
|
||||
cornerstoneTools.mouseWheelInput.enable(element);
|
||||
cornerstoneTools.keyboardInput.enable(element);
|
||||
|
||||
// Use the tool manager to enable the currently active tool for this
|
||||
// newly rendered element
|
||||
@ -210,102 +211,6 @@ function loadSeriesIntoViewport(data, templateData) {
|
||||
$(element).off('CornerstoneImageRendered', onImageRendered);
|
||||
$(element).on('CornerstoneImageRendered', onImageRendered);
|
||||
|
||||
//TODO: ********************************************
|
||||
//TODO: Delete a lesion, if ctrl+d or del is pressed after lesion selected
|
||||
//TODO: getTimepointObject should be global function to use everywhere
|
||||
|
||||
function getTimepointObject(imageId) {
|
||||
var study = cornerstoneTools.metaData.get('study', imageId);
|
||||
return Timepoints.findOne({timepointName: study.studyDate});
|
||||
}
|
||||
|
||||
// ctrl+d is used to detect delete event if del key is not found on keyboard.
|
||||
// Id key is down
|
||||
var keyMap = {17: false, 68: false, 46: false};
|
||||
function keyPressDownHandler(e, lesionData){
|
||||
if (e.keyCode in keyMap) {
|
||||
keyMap[e.keyCode] = true;
|
||||
if (keyMap[46] || keyMap[17] && keyMap[68]) {
|
||||
var toolType = lesionData.isTarget ? 'lesion' : 'nonTarget';
|
||||
var imageId = lesionData.imageId;
|
||||
var toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.toolState;
|
||||
Object.keys(toolState).forEach(function(imageIdKey){
|
||||
if(imageIdKey === imageId) {
|
||||
var toolStateArray = toolState[imageId][toolType].data;
|
||||
toolStateArray.forEach(function(data, index) {
|
||||
if(data.lesionNumber === lesionData.lesionNumber){
|
||||
toolState[imageId][toolType].data.splice(index, 1);
|
||||
|
||||
// Remove from collection
|
||||
var patientId = data.patientId;
|
||||
var enabledElement = cornerstone.getEnabledElement(element);
|
||||
var elementImageId = enabledElement.image.imageId;
|
||||
var timepointData = getTimepointObject(elementImageId);
|
||||
var lesionObject = {
|
||||
patientId: patientId,
|
||||
lesionNumber: lesionData.lesionNumber,
|
||||
isTarget: lesionData.isTarget,
|
||||
timepointId: timepointData.timepointID
|
||||
};
|
||||
|
||||
// Remove patient measurement
|
||||
Meteor.call('removePatientMeasurement', lesionObject);
|
||||
|
||||
//Update element
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// When key is up
|
||||
function keyPressUpHandler(e){
|
||||
if (e.keyCode in keyMap) {
|
||||
keyMap[e.keyCode] = false;
|
||||
}
|
||||
}
|
||||
|
||||
// CornerstoneToolsMouseDown event callback
|
||||
function onMouseDown(e,eventData) {
|
||||
var element = e.currentTarget;
|
||||
var distanceSq = 5;
|
||||
var coords = eventData.startPoints.canvas;
|
||||
var toolTypes = ["lesion", "nonTarget"];
|
||||
toolTypes.forEach(function(toolType){
|
||||
var toolData = cornerstoneTools.getToolState(element, toolType);
|
||||
|
||||
// now check to see if there is a handle we can move
|
||||
if (toolData) {
|
||||
for (var i = 0; i < toolData.data.length; i++) {
|
||||
var data = toolData.data[i];
|
||||
var handle = cornerstoneTools.getHandleNearImagePoint(element, data.handles, coords, distanceSq);
|
||||
if(handle) {
|
||||
$(document).off("keydown");
|
||||
$(document).on('keydown', function(e){
|
||||
keyPressDownHandler(e,data);
|
||||
return;
|
||||
});
|
||||
$(document).off("keyup");
|
||||
$(document).on('keyup',keyPressUpHandler);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(element).on('CornerstoneToolsMouseDown', onMouseDown);
|
||||
$(element).on('CornerstoneToolsMouseDown', onMouseDown);
|
||||
|
||||
//TODO: Delete a lesion ends
|
||||
//TODO: ********************************************
|
||||
|
||||
// Set a random value for the Session variable in order to trigger an overlay update
|
||||
Session.set('CornerstoneImageRendered' + viewportIndex, Random.id());
|
||||
|
||||
@ -365,8 +270,13 @@ function loadSeriesIntoViewport(data, templateData) {
|
||||
// Check if the current active viewport in the Meteor Session
|
||||
// Is the same as the viewport in which the activation event was fired.
|
||||
// If it was, no changes are necessary, so stop here.
|
||||
var element = eventData.element;
|
||||
var activeViewportIndex = Session.get('activeViewport');
|
||||
var viewportIndex = $(".imageViewerViewport").index(eventData.element);
|
||||
var viewportIndex = $(".imageViewerViewport").index(element);
|
||||
|
||||
// Reset the focus, even if we don't need to re-enable reference lines or prefetching
|
||||
$(element).focus();
|
||||
|
||||
if (viewportIndex === activeViewportIndex) {
|
||||
return;
|
||||
}
|
||||
@ -403,11 +313,13 @@ function loadSeriesIntoViewport(data, templateData) {
|
||||
// that is used for updating reference lines, and enable reference lines for this viewport.
|
||||
if (OHIF.viewer.refLinesEnabled && imagePlane && imagePlane.frameOfReferenceUID) {
|
||||
OHIF.viewer.updateImageSynchronizer.add(element);
|
||||
displayReferenceLines(element);
|
||||
}
|
||||
|
||||
// Set the active viewport based on the Session variable
|
||||
// This is done to ensure that the active element has the current
|
||||
// focus, so that keyboard events are triggered.
|
||||
if (viewportIndex === Session.get('activeViewport')) {
|
||||
enablePrefetchOnElement(element);
|
||||
setActiveViewport(element);
|
||||
}
|
||||
|
||||
// Run any renderedCallback that exists in the data context
|
||||
@ -428,7 +340,7 @@ function loadSeriesIntoViewport(data, templateData) {
|
||||
* @param templateData currentData of Template
|
||||
*
|
||||
*/
|
||||
function setSeries(data,seriesInstanceUid, templateData){
|
||||
function setSeries(data, seriesInstanceUid, templateData){
|
||||
var study = data.study;
|
||||
study.seriesList.every(function(series) {
|
||||
if (series.seriesInstanceUid === seriesInstanceUid) {
|
||||
@ -493,24 +405,18 @@ Meteor.startup(function() {
|
||||
});
|
||||
|
||||
Template.imageViewerViewport.onRendered(function() {
|
||||
|
||||
var templateData = Template.currentData();
|
||||
log.info("imageViewerViewport onRendered");
|
||||
|
||||
// When the imageViewerViewport template is rendered
|
||||
var element = this.find(".imageViewerViewport");
|
||||
|
||||
|
||||
// Display the loading indicator for this element
|
||||
$(element).siblings('.imageViewerLoadingIndicator').css('display', 'block');
|
||||
|
||||
// Get the current active viewport index, if this viewport has the same index,
|
||||
// add the CSS 'active' class to highlight this viewport.
|
||||
var activeViewport = Session.get('activeViewport');
|
||||
if (activeViewport === this.data.viewportIndex) {
|
||||
$('#imageViewerViewports .viewportContainer').removeClass('active');
|
||||
$(element).parents('.viewportContainer').addClass('active');
|
||||
}
|
||||
|
||||
// Create a data object to pass to the series loading function (loadSeriesIntoViewport)
|
||||
var data = {
|
||||
@ -550,14 +456,13 @@ Template.imageViewerViewport.onRendered(function() {
|
||||
}
|
||||
sortStudy(study);
|
||||
data.study = study;
|
||||
|
||||
setSeries(data, seriesInstanceUid, templateData);
|
||||
return;
|
||||
});
|
||||
}
|
||||
|
||||
data.study = study;
|
||||
setSeries(data, seriesInstanceUid, templateData);
|
||||
|
||||
});
|
||||
|
||||
Template.imageViewerViewport.onDestroyed(function() {
|
||||
|
||||
@ -16,7 +16,7 @@ createStacks = function(study) {
|
||||
|
||||
// TODO: Split by multi-frame, modality, image size, etc
|
||||
study.seriesList.forEach(function(series) {
|
||||
// If the series has no instanced, skip it
|
||||
// If the series has no instances, skip it
|
||||
if (!series.instances) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -8,6 +8,15 @@
|
||||
displayReferenceLines = function(element) {
|
||||
log.info("imageViewerViewport displayReferenceLines");
|
||||
|
||||
// Check if image plane (orientation / loction) data is present for the current image
|
||||
var enabledElement = cornerstone.getEnabledElement(element);
|
||||
var imageId = enabledElement.image.imageId;
|
||||
var imagePlane = cornerstoneTools.metaData.get('imagePlane', imageId);
|
||||
|
||||
if (!OHIF.viewer.refLinesEnabled || !imagePlane || !imagePlane.frameOfReferenceUID) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Disable reference lines for the current element
|
||||
cornerstoneTools.referenceLines.tool.disable(element);
|
||||
|
||||
|
||||
@ -17,4 +17,7 @@ setActiveViewport = function(element) {
|
||||
// the newly activated viewport
|
||||
enablePrefetchOnElement(element);
|
||||
displayReferenceLines(element);
|
||||
|
||||
// Set the div to focused, so keypress events are handled
|
||||
$(element).focus();
|
||||
};
|
||||
@ -83,6 +83,9 @@ toolManager = {
|
||||
addTool: function(name, base) {
|
||||
tools[name] = base;
|
||||
},
|
||||
getTools: function() {
|
||||
return tools;
|
||||
},
|
||||
setToolDefaultStates: function(states) {
|
||||
toolDefaultStates = states;
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user