Work on refactoring measurements out of Lesion Tracker package
- Removed AssociatedStudies Collection - Measurement API is generated from configuration files - Data exchange methods are defined in configuration
This commit is contained in:
1 parent
c511edd419
commit
ab4d4c9008
537 files changed
+5122
-3545
No files matched your search
@@ -0,0 +1,85 @@
|
||||
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
|
||||
|
||||
const LocationSchema = new SimpleSchema({
|
||||
id: {
|
||||
type: String,
|
||||
label: 'Location ID'
|
||||
},
|
||||
location: {
|
||||
type: String,
|
||||
label: 'Location Name'
|
||||
},
|
||||
selected: {
|
||||
type: Boolean,
|
||||
label: 'Selected',
|
||||
defaultValue: false
|
||||
},
|
||||
isNodal: {
|
||||
type: Boolean,
|
||||
label: 'Nodal Location',
|
||||
defaultValue: false
|
||||
}
|
||||
});
|
||||
|
||||
LesionLocations = new Meteor.Collection(null);
|
||||
LesionLocations.attachSchema(LocationSchema);
|
||||
LesionLocations._debugName = 'LesionLocations';
|
||||
|
||||
var organGroups = [
|
||||
'Abdominal/Chest Wall',
|
||||
'Adrenal',
|
||||
'Bladder',
|
||||
'Bone',
|
||||
'Brain',
|
||||
'Breast',
|
||||
'Colon',
|
||||
'Esophagus',
|
||||
'Extremities',
|
||||
'Gallbladder',
|
||||
'Kidney',
|
||||
'Liver',
|
||||
'Lung',
|
||||
'Lymph Node',
|
||||
'Mediastinum/Hilum',
|
||||
'Muscle',
|
||||
'Neck',
|
||||
'Other: Soft Tissue',
|
||||
'Ovary',
|
||||
'Pancreas',
|
||||
'Pelvis',
|
||||
'Peritoneum/Omentum',
|
||||
'Prostate',
|
||||
'Retroperitoneum',
|
||||
'Small Bowel',
|
||||
'Spleen',
|
||||
'Stomach',
|
||||
'Subcutaneous'];
|
||||
|
||||
function nameToID(name) {
|
||||
// http://stackoverflow.com/questions/29258016/remove-special-symbols-and-extra-spaces-and-make-it-camel-case-javascript
|
||||
return name
|
||||
.trim() //might need polyfill if you need to support older browsers
|
||||
.toLowerCase() //lower case everything
|
||||
.replace(/([^A-Z0-9]+)(.)/ig, //match multiple non-letter/numbers followed by any character
|
||||
function(match) {
|
||||
return arguments[2].toUpperCase(); //3rd index is the character we need to transform uppercase
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
organGroups.forEach(function(organGroup) {
|
||||
const id = nameToID(organGroup);
|
||||
|
||||
// Check if the name has 'node' in it, if so, it is nodal
|
||||
let isNodal = false;
|
||||
if (id.toLowerCase().indexOf('node') > -1) {
|
||||
isNodal = true;
|
||||
}
|
||||
|
||||
LesionLocations.insert({
|
||||
id: id,
|
||||
location: organGroup,
|
||||
selected: false,
|
||||
isNodal: isNodal
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,56 @@
|
||||
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
|
||||
|
||||
const ResponseSchema = new SimpleSchema({
|
||||
text: {
|
||||
type: String,
|
||||
label: 'Text'
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
label: 'Code'
|
||||
},
|
||||
selected: {
|
||||
type: Boolean,
|
||||
label: 'Selected',
|
||||
defaultValue: false
|
||||
}
|
||||
});
|
||||
|
||||
LocationResponses = new Meteor.Collection(null);
|
||||
LocationResponses.attachSchema(ResponseSchema);
|
||||
LocationResponses._debugName = 'LocationResponses';
|
||||
|
||||
LocationResponses.insert({
|
||||
text: 'Complete response',
|
||||
code: 'CR'
|
||||
});
|
||||
|
||||
LocationResponses.insert({
|
||||
text: 'Progressive disease',
|
||||
code: 'PD'
|
||||
});
|
||||
|
||||
LocationResponses.insert({
|
||||
text: 'Stable disease',
|
||||
code: 'SD'
|
||||
});
|
||||
|
||||
LocationResponses.insert({
|
||||
text: 'Present',
|
||||
code: 'Present'
|
||||
});
|
||||
|
||||
LocationResponses.insert({
|
||||
text: 'Not Evaluable',
|
||||
code: 'NE'
|
||||
});
|
||||
|
||||
LocationResponses.insert({
|
||||
text: 'Non-CR/Non-PD',
|
||||
code: 'NN'
|
||||
});
|
||||
|
||||
LocationResponses.insert({
|
||||
text: 'Excluded from Assessment',
|
||||
code: 'EX'
|
||||
});
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,105 @@
|
||||
(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, element) {
|
||||
var imageId = data.imageId;
|
||||
if (!imageId) {
|
||||
var enabledElement = cornerstone.getEnabledElement(element);
|
||||
imageId = enabledElement.image.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);
|
||||
});
|
||||
}
|
||||
|
||||
// TODO = Check if we have the same function already in Cornerstone Tools
|
||||
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.which;
|
||||
if (keyCode === keys.DELETE ||
|
||||
(keyCode === keys.D && eventData.event.ctrlKey === true)) {
|
||||
|
||||
var toolTypes = [ 'bidirectional', 'nonTarget', 'length', 'crTool', 'unTool', 'exTool'];
|
||||
var nearbyToolData = getNearbyToolData(eventData.element, eventData.currentPoints.canvas, toolTypes);
|
||||
|
||||
if (!nearbyToolData) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO= Refactor this so the confirmation dialog is an
|
||||
// optional settable callback in the tool's configuration
|
||||
showConfirmDialog(function() {
|
||||
removeMeasurementTimepoint(nearbyToolData.nearbyTool,
|
||||
nearbyToolData.nearbyToolIndex,
|
||||
nearbyToolData.nearbyToolType,
|
||||
eventData.element
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// module/private exports
|
||||
cornerstoneTools.deleteLesionKeyboardTool = cornerstoneTools.keyboardTool(keyDownCallback);
|
||||
|
||||
})(cornerstoneTools);
|
||||
@@ -0,0 +1,361 @@
|
||||
(function($, cornerstone, cornerstoneMath, cornerstoneTools) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var toolType = 'nonTarget';
|
||||
|
||||
var configuration = {
|
||||
setLesionNumberCallback: setLesionNumberCallback,
|
||||
getLesionLocationCallback: getLesionLocationCallback,
|
||||
changeLesionLocationCallback: changeLesionLocationCallback,
|
||||
drawHandles: false,
|
||||
drawHandlesOnHover: true,
|
||||
arrowFirst: true
|
||||
};
|
||||
|
||||
// Used to cancel tool placement
|
||||
var keys = {
|
||||
ESC: 27
|
||||
};
|
||||
|
||||
// Set lesion number
|
||||
// Get Non-Target lesions on image
|
||||
function setLesionNumberCallback(measurementData, eventData, doneCallback) {
|
||||
var lesionNumber = 1;
|
||||
doneCallback(lesionNumber);
|
||||
}
|
||||
// Define a callback to get your text annotation
|
||||
// This could be used, e.g. to open a modal
|
||||
function getLesionLocationCallback(measurementData, eventData, doneCallback) {
|
||||
doneCallback(prompt('Enter your lesion location:'));
|
||||
}
|
||||
|
||||
function changeLesionLocationCallback(measurementData, eventData, doneCallback) {
|
||||
doneCallback(prompt('Change your lesion location:'));
|
||||
}
|
||||
|
||||
/// --- Mouse Tool --- ///
|
||||
///////// BEGIN ACTIVE TOOL ///////
|
||||
function addNewMeasurement(mouseEventData) {
|
||||
var element = mouseEventData.element;
|
||||
|
||||
function doneCallback(lesionNumber) {
|
||||
measurementData.lesionNumber = lesionNumber;
|
||||
measurementData.active = true;
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
|
||||
var measurementData = createNewMeasurement(mouseEventData);
|
||||
|
||||
var eventData = {
|
||||
mouseButtonMask: mouseEventData.which
|
||||
};
|
||||
|
||||
var config = cornerstoneTools.nonTarget.getConfiguration();
|
||||
|
||||
// Set lesion number and lesion name
|
||||
if (measurementData.lesionNumber === undefined) {
|
||||
config.setLesionNumberCallback(measurementData, mouseEventData, doneCallback);
|
||||
}
|
||||
|
||||
// associate this data with this imageId so we can render it and manipulate it
|
||||
cornerstoneTools.addToolState(mouseEventData.element, toolType, measurementData);
|
||||
|
||||
// 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.
|
||||
$(element).off('CornerstoneToolsMouseMove', cornerstoneTools.nonTarget.mouseMoveCallback);
|
||||
$(element).off('CornerstoneToolsMouseDown', cornerstoneTools.nonTarget.mouseDownCallback);
|
||||
$(element).off('CornerstoneToolsMouseDownActivate', cornerstoneTools.nonTarget.mouseDownActivateCallback);
|
||||
$(element).off('CornerstoneToolsMouseDoubleClick', doubleClickCallback);
|
||||
|
||||
// Add a flag for using Esc to cancel tool placement
|
||||
var cancelled = false;
|
||||
function cancelCallback(e) {
|
||||
// If the Esc key was pressed, set the flag to true
|
||||
if (e.which === keys.ESC) {
|
||||
cancelled = true;
|
||||
cornerstoneTools.removeToolState(mouseEventData.element, toolType, measurementData);
|
||||
}
|
||||
|
||||
// Don't propagate this keydown event so it can't interfere
|
||||
// with anything outside of this tool
|
||||
return false;
|
||||
}
|
||||
|
||||
// Bind a one-time event listener for the Esc key
|
||||
$(element).one('keydown', cancelCallback);
|
||||
|
||||
cornerstone.updateImage(element);
|
||||
|
||||
cornerstoneTools.moveNewHandle(mouseEventData, toolType, measurementData, measurementData.handles.end, function() {
|
||||
if (cancelled || cornerstoneTools.anyHandlesOutsideImage(mouseEventData, measurementData.handles)) {
|
||||
// delete the measurement
|
||||
cornerstoneTools.removeToolState(mouseEventData.element, toolType, measurementData);
|
||||
} else {
|
||||
config.getLesionLocationCallback(measurementData, mouseEventData, doneCallback);
|
||||
}
|
||||
|
||||
// Unbind the Esc keydown hook
|
||||
$(element).off('keydown', cancelCallback);
|
||||
|
||||
$(element).on('CornerstoneToolsMouseMove', eventData, cornerstoneTools.nonTarget.mouseMoveCallback);
|
||||
$(element).on('CornerstoneToolsMouseDown', eventData, cornerstoneTools.nonTarget.mouseDownCallback);
|
||||
$(element).on('CornerstoneToolsMouseDownActivate', eventData, cornerstoneTools.nonTarget.mouseDownActivateCallback);
|
||||
$(element).on('CornerstoneToolsMouseDoubleClick', eventData, doubleClickCallback);
|
||||
|
||||
$(element).off('keydown', cancelCallback);
|
||||
|
||||
cornerstone.updateImage(mouseEventData.element);
|
||||
});
|
||||
}
|
||||
|
||||
function createNewMeasurement(mouseEventData) {
|
||||
var imageId = mouseEventData.image.imageId;
|
||||
|
||||
// Get studyInstanceUid
|
||||
var study = cornerstoneTools.metaData.get('study', imageId);
|
||||
var studyInstanceUid = study.studyInstanceUid;
|
||||
var patientId = study.patientId;
|
||||
|
||||
// Get seriesInstanceUid
|
||||
var series = cornerstoneTools.metaData.get('series', imageId);
|
||||
var seriesInstanceUid = series.seriesInstanceUid;
|
||||
|
||||
// create the measurement data for this tool with the end handle activated
|
||||
var measurementData = {
|
||||
visible: true,
|
||||
active: true,
|
||||
handles: {
|
||||
start: {
|
||||
x: mouseEventData.currentPoints.image.x,
|
||||
y: mouseEventData.currentPoints.image.y,
|
||||
highlight: true,
|
||||
active: false
|
||||
},
|
||||
end: {
|
||||
x: mouseEventData.currentPoints.image.x,
|
||||
y: mouseEventData.currentPoints.image.y,
|
||||
highlight: true,
|
||||
active: false
|
||||
},
|
||||
textBox: {
|
||||
x: mouseEventData.currentPoints.image.x - 50,
|
||||
y: mouseEventData.currentPoints.image.y - 50,
|
||||
active: false,
|
||||
movesIndependently: false,
|
||||
drawnIndependently: true,
|
||||
allowedOutsideImage: true,
|
||||
hasBoundingBox: true
|
||||
}
|
||||
},
|
||||
imageId: imageId,
|
||||
seriesInstanceUid: seriesInstanceUid,
|
||||
studyInstanceUid: studyInstanceUid,
|
||||
patientId: patientId,
|
||||
response: '',
|
||||
isTarget: false,
|
||||
toolType: 'nonTarget'
|
||||
};
|
||||
|
||||
return measurementData;
|
||||
}
|
||||
///////// END ACTIVE TOOL ///////
|
||||
|
||||
function pointNearTool(element, data, coords) {
|
||||
var lineSegment = {
|
||||
start: cornerstone.pixelToCanvas(element, data.handles.start),
|
||||
end: cornerstone.pixelToCanvas(element, data.handles.end)
|
||||
};
|
||||
var distanceToPoint = cornerstoneMath.lineSegment.distanceToPoint(lineSegment, coords);
|
||||
|
||||
if (cornerstoneTools.pointInsideBoundingBox(data.handles.textBox, coords)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return distanceToPoint < 25;
|
||||
}
|
||||
|
||||
///////// BEGIN IMAGE RENDERING ///////
|
||||
function onImageRendered(e, eventData) {
|
||||
var element = eventData.element;
|
||||
|
||||
// if we have no toolData for this element, return immediately as there is nothing to do
|
||||
var toolData = cornerstoneTools.getToolState(element, toolType);
|
||||
if (!toolData) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we have tool data for this element - iterate over each one and draw it
|
||||
var context = eventData.canvasContext.canvas.getContext('2d');
|
||||
context.setTransform(1, 0, 0, 1, 0, 0);
|
||||
|
||||
var color;
|
||||
var lineWidth = cornerstoneTools.toolStyle.getToolWidth();
|
||||
var font = cornerstoneTools.textStyle.getFont();
|
||||
var config = cornerstoneTools.nonTarget.getConfiguration();
|
||||
|
||||
context.font = font;
|
||||
for (var i = 0; i < toolData.data.length; i++) {
|
||||
var data = toolData.data[i];
|
||||
|
||||
context.save();
|
||||
|
||||
// configurable shadow from CornerstoneTools
|
||||
if (config && config.shadow) {
|
||||
context.shadowColor = '#000000';
|
||||
context.shadowOffsetX = 1;
|
||||
context.shadowOffsetY = 1;
|
||||
}
|
||||
|
||||
if (data.active) {
|
||||
color = cornerstoneTools.toolColors.getActiveColor();
|
||||
} else {
|
||||
color = cornerstoneTools.toolColors.getToolColor();
|
||||
}
|
||||
|
||||
// Draw the arrow
|
||||
var handleStartCanvas = cornerstone.pixelToCanvas(element, data.handles.start);
|
||||
var handleEndCanvas = cornerstone.pixelToCanvas(element, data.handles.end);
|
||||
var canvasTextLocation = cornerstone.pixelToCanvas(element, data.handles.textBox);
|
||||
|
||||
cornerstoneTools.drawArrow(context, handleEndCanvas, handleStartCanvas, color, lineWidth);
|
||||
|
||||
if (config.drawHandles) {
|
||||
cornerstoneTools.drawHandles(context, eventData, data.handles, color);
|
||||
} else if (config.drawHandlesOnHover && data.handles.start.active) {
|
||||
cornerstoneTools.drawHandles(context, eventData, [ lesion.handles.start ], color);
|
||||
} else if (config.drawHandlesOnHover && data.handles.end.active) {
|
||||
cornerstoneTools.drawHandles(context, eventData, [ lesion.handles.end ], color);
|
||||
}
|
||||
|
||||
// Draw the text
|
||||
if (data.lesionNumber) {
|
||||
// Draw linked line as dashed
|
||||
var mid = {
|
||||
x: (handleStartCanvas.x + handleEndCanvas.x) / 2,
|
||||
y: (handleStartCanvas.y + handleEndCanvas.y) / 2
|
||||
};
|
||||
|
||||
context.beginPath();
|
||||
context.strokeStyle = color;
|
||||
context.lineWidth = lineWidth;
|
||||
context.setLineDash([ 2, 3 ]);
|
||||
|
||||
context.moveTo(mid.x, mid.y);
|
||||
context.lineTo(canvasTextLocation.x + 20, canvasTextLocation.y + 20);
|
||||
context.stroke();
|
||||
|
||||
var boundingBox = cornerstoneTools.drawTextBox(context, 'Non-Target ' + data.lesionNumber, canvasTextLocation.x, canvasTextLocation.y, color);
|
||||
data.handles.textBox.boundingBox = boundingBox;
|
||||
}
|
||||
|
||||
context.restore();
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Touch tool ----
|
||||
|
||||
///////// BEGIN ACTIVE TOOL ///////
|
||||
function addNewMeasurementTouch(touchEventData) {
|
||||
var element = touchEventData.element;
|
||||
|
||||
function doneCallback(lesionNumber) {
|
||||
measurementData.lesionNumber = lesionNumber;
|
||||
measurementData.active = true;
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
|
||||
var measurementData = createNewMeasurement(touchEventData);
|
||||
cornerstoneTools.addToolState(element, toolType, measurementData);
|
||||
$(element).off('CornerstoneToolsTouchDrag', cornerstoneTools.nonTargetTouch.touchMoveHandle);
|
||||
$(element).off('CornerstoneToolsDragStartActive', cornerstoneTools.nonTargetTouch.touchDownActivateCallback);
|
||||
$(element).off('CornerstoneToolsTap', cornerstoneTools.nonTargetTouch.tapCallback);
|
||||
var config = cornerstoneTools.nonTarget.getConfiguration();
|
||||
|
||||
// Set lesion number and lesion name
|
||||
if (measurementData.lesionName === undefined) {
|
||||
config.setLesionNumberCallback(measurementData, touchEventData, doneCallback);
|
||||
}
|
||||
|
||||
cornerstone.updateImage(element);
|
||||
|
||||
cornerstoneTools.moveNewHandleTouch(touchEventData, toolType, measurementData, measurementData.handles.end, function() {
|
||||
cornerstone.updateImage(element);
|
||||
|
||||
if (cornerstoneTools.anyHandlesOutsideImage(touchEventData, measurementData.handles)) {
|
||||
// delete the measurement
|
||||
cornerstoneTools.removeToolState(element, toolType, measurementData);
|
||||
}
|
||||
|
||||
config.getLesionLocationCallback(measurementData, touchEventData, doneCallback);
|
||||
|
||||
$(element).on('CornerstoneToolsTouchDrag', cornerstoneTools.nonTargetTouch.touchMoveHandle);
|
||||
$(element).on('CornerstoneToolsDragStartActive', cornerstoneTools.nonTargetTouch.touchDownActivateCallback);
|
||||
$(element).on('CornerstoneToolsTap', cornerstoneTools.nonTargetTouch.tapCallback);
|
||||
});
|
||||
}
|
||||
|
||||
function doubleClickCallback(e, eventData) {
|
||||
var element = eventData.element;
|
||||
var data;
|
||||
|
||||
function doneCallback(data, deleteTool) {
|
||||
if (deleteTool === true) {
|
||||
cornerstoneTools.removeToolState(element, toolType, data);
|
||||
cornerstone.updateImage(element);
|
||||
return;
|
||||
}
|
||||
|
||||
data.active = false;
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
|
||||
if (e.data && e.data.mouseButtonMask && !cornerstoneTools.isMouseButtonEnabled(eventData.which, e.data.mouseButtonMask)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var config = cornerstoneTools.nonTarget.getConfiguration();
|
||||
|
||||
var coords = eventData.currentPoints.canvas;
|
||||
var toolData = cornerstoneTools.getToolState(element, toolType);
|
||||
|
||||
// now check to see if there is a handle we can move
|
||||
if (!toolData) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < toolData.data.length; i++) {
|
||||
data = toolData.data[i];
|
||||
if (pointNearTool(element, data, coords)) {
|
||||
data.active = true;
|
||||
cornerstone.updateImage(element);
|
||||
// Allow relabelling via a callback
|
||||
config.changeLesionLocationCallback(data, eventData, doneCallback);
|
||||
|
||||
e.stopImmediatePropagation();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cornerstoneTools.nonTarget = cornerstoneTools.mouseButtonTool({
|
||||
addNewMeasurement: addNewMeasurement,
|
||||
createNewMeasurement: createNewMeasurement,
|
||||
onImageRendered: onImageRendered,
|
||||
pointNearTool: pointNearTool,
|
||||
toolType: toolType,
|
||||
mouseDoubleClickCallback: doubleClickCallback
|
||||
});
|
||||
|
||||
cornerstoneTools.nonTarget.setConfiguration(configuration);
|
||||
|
||||
cornerstoneTools.nonTargetTouch = cornerstoneTools.touchTool({
|
||||
addNewMeasurement: addNewMeasurementTouch,
|
||||
createNewMeasurement: createNewMeasurement,
|
||||
onImageRendered: onImageRendered,
|
||||
pointNearTool: pointNearTool,
|
||||
toolType: toolType
|
||||
// pressCallback: doubleClickCallback
|
||||
});
|
||||
|
||||
})($, cornerstone, cornerstoneMath, cornerstoneTools);
|
||||
@@ -0,0 +1,436 @@
|
||||
(function($, cornerstone, cornerstoneMath, cornerstoneTools) {
|
||||
|
||||
'use strict';
|
||||
var responseByToolType = [{
|
||||
"toolType": "crTool",
|
||||
"toolResponse": "CR"
|
||||
}, {
|
||||
"toolType": "unTool",
|
||||
"toolResponse": "UN"
|
||||
}, {
|
||||
"toolType": "exTool",
|
||||
"toolResponse": "EX"
|
||||
}];
|
||||
|
||||
var configuration = {
|
||||
setLesionNumberCallback: setLesionNumberCallback,
|
||||
getLesionLocationCallback: getLesionLocationCallback,
|
||||
changeLesionLocationCallback: changeLesionLocationCallback,
|
||||
drawHandles: false,
|
||||
drawHandlesOnHover: false,
|
||||
arrowFirst: true
|
||||
};
|
||||
|
||||
// Used to cancel tool placement
|
||||
var keys = {
|
||||
ESC: 27
|
||||
};
|
||||
|
||||
// Set lesion number
|
||||
// Get Non-Target lesions on image
|
||||
function setLesionNumberCallback(measurementData, eventData, doneCallback) {
|
||||
var lesionNumber = 1;
|
||||
doneCallback(lesionNumber);
|
||||
}
|
||||
// Define a callback to get your text annotation
|
||||
// This could be used, e.g. to open a modal
|
||||
function getLesionLocationCallback(measurementData, eventData, doneCallback) {
|
||||
doneCallback(prompt('Enter your lesion location:'));
|
||||
}
|
||||
|
||||
function changeLesionLocationCallback(measurementData, eventData, doneCallback) {
|
||||
doneCallback(prompt('Change your lesion location:'));
|
||||
}
|
||||
|
||||
|
||||
function createQualitativeTargetTool(toolType) {
|
||||
var toolInterface = {
|
||||
toolType: toolType
|
||||
};
|
||||
|
||||
var response;
|
||||
|
||||
responseByToolType.forEach(function(tool) {
|
||||
if (tool.toolType === toolInterface.toolType) {
|
||||
response = tool.toolResponse;
|
||||
}
|
||||
});
|
||||
|
||||
/// --- Mouse Tool --- ///
|
||||
///////// BEGIN ACTIVE TOOL ///////
|
||||
function addNewMeasurement(mouseEventData) {
|
||||
var element = mouseEventData.element;
|
||||
|
||||
function doneCallback(lesionNumber) {
|
||||
measurementData.lesionNumber = lesionNumber;
|
||||
measurementData.active = true;
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
|
||||
var measurementData = createNewMeasurement(mouseEventData);
|
||||
|
||||
var eventData = {
|
||||
mouseButtonMask: mouseEventData.which
|
||||
};
|
||||
|
||||
var config = cornerstoneTools[toolType].getConfiguration();
|
||||
|
||||
// Set lesion number and lesion name
|
||||
if (measurementData.lesionNumber === undefined) {
|
||||
config.setLesionNumberCallback(measurementData, mouseEventData, doneCallback);
|
||||
}
|
||||
|
||||
// associate this data with this imageId so we can render it and manipulate it
|
||||
cornerstoneTools.addToolState(mouseEventData.element, toolType, measurementData);
|
||||
|
||||
// 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.
|
||||
$(element).off('CornerstoneToolsMouseMove', cornerstoneTools[toolType].mouseMoveCallback);
|
||||
$(element).off('CornerstoneToolsMouseDown', cornerstoneTools[toolType].mouseDownCallback);
|
||||
$(element).off('CornerstoneToolsMouseDownActivate', cornerstoneTools[toolType].mouseDownActivateCallback);
|
||||
$(element).off('CornerstoneToolsMouseDoubleClick', doubleClickCallback);
|
||||
|
||||
// Add a flag for using Esc to cancel tool placement
|
||||
var cancelled = false;
|
||||
|
||||
function cancelCallback(e) {
|
||||
// If the Esc key was pressed, set the flag to true
|
||||
if (e.which === keys.ESC) {
|
||||
cancelled = true;
|
||||
cornerstoneTools.removeToolState(mouseEventData.element, toolType, measurementData);
|
||||
}
|
||||
|
||||
// Don't propagate this keydown event so it can't interfere
|
||||
// with anything outside of this tool
|
||||
return false;
|
||||
}
|
||||
|
||||
// Bind a one-time event listener for the Esc key
|
||||
$(element).one('keydown', cancelCallback);
|
||||
|
||||
cornerstone.updateImage(element);
|
||||
|
||||
cornerstoneTools.moveNewHandle(mouseEventData, toolType, measurementData, measurementData.handles.end, function() {
|
||||
if (cancelled || cornerstoneTools.anyHandlesOutsideImage(mouseEventData, measurementData.handles)) {
|
||||
// delete the measurement
|
||||
cornerstoneTools.removeToolState(mouseEventData.element, toolType, measurementData);
|
||||
} else {
|
||||
config.getLesionLocationCallback(measurementData, mouseEventData, doneCallback);
|
||||
}
|
||||
|
||||
// Unbind the Esc keydown hook
|
||||
$(element).off('keydown', cancelCallback);
|
||||
|
||||
$(element).on('CornerstoneToolsMouseMove', eventData, cornerstoneTools[toolType].mouseMoveCallback);
|
||||
$(element).on('CornerstoneToolsMouseDown', eventData, cornerstoneTools[toolType].mouseDownCallback);
|
||||
$(element).on('CornerstoneToolsMouseDownActivate', eventData, cornerstoneTools[toolType].mouseDownActivateCallback);
|
||||
$(element).on('CornerstoneToolsMouseDoubleClick', eventData, doubleClickCallback);
|
||||
|
||||
$(element).off('keydown', cancelCallback);
|
||||
|
||||
cornerstone.updateImage(mouseEventData.element);
|
||||
});
|
||||
}
|
||||
|
||||
function createNewMeasurement(mouseEventData) {
|
||||
var imageId = mouseEventData.image.imageId;
|
||||
|
||||
// Get studyInstanceUid
|
||||
var study = cornerstoneTools.metaData.get('study', imageId);
|
||||
var studyInstanceUid = study.studyInstanceUid;
|
||||
var patientId = study.patientId;
|
||||
|
||||
// Get seriesInstanceUid
|
||||
var series = cornerstoneTools.metaData.get('series', imageId);
|
||||
var seriesInstanceUid = series.seriesInstanceUid;
|
||||
|
||||
// create the measurement data for this tool with the end handle activated
|
||||
var measurementData = {
|
||||
visible: true,
|
||||
active: true,
|
||||
handles: {
|
||||
start: {
|
||||
x: mouseEventData.currentPoints.image.x,
|
||||
y: mouseEventData.currentPoints.image.y,
|
||||
highlight: true,
|
||||
active: false
|
||||
},
|
||||
end: {
|
||||
x: mouseEventData.currentPoints.image.x,
|
||||
y: mouseEventData.currentPoints.image.y,
|
||||
highlight: true,
|
||||
active: false
|
||||
},
|
||||
textBox: {
|
||||
x: mouseEventData.currentPoints.image.x - 50,
|
||||
y: mouseEventData.currentPoints.image.y - 50,
|
||||
active: false,
|
||||
movesIndependently: false,
|
||||
drawnIndependently: true,
|
||||
allowedOutsideImage: true,
|
||||
hasBoundingBox: true
|
||||
}
|
||||
},
|
||||
imageId: imageId,
|
||||
seriesInstanceUid: seriesInstanceUid,
|
||||
studyInstanceUid: studyInstanceUid,
|
||||
patientId: patientId,
|
||||
response: response,
|
||||
isTarget: true,
|
||||
toolType: toolType
|
||||
};
|
||||
|
||||
return measurementData;
|
||||
}
|
||||
///////// END ACTIVE TOOL ///////
|
||||
|
||||
function pointNearTool(element, data, coords) {
|
||||
var lineSegment = {
|
||||
start: cornerstone.pixelToCanvas(element, data.handles.start),
|
||||
end: cornerstone.pixelToCanvas(element, data.handles.end)
|
||||
};
|
||||
var distanceToPoint = cornerstoneMath.lineSegment.distanceToPoint(lineSegment, coords);
|
||||
|
||||
if (cornerstoneTools.pointInsideBoundingBox(data.handles.textBox, coords)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return distanceToPoint < 25;
|
||||
}
|
||||
|
||||
function drawDottedArrow(context, start, end, color, lineWidth) {
|
||||
//variables to be used when creating the arrow
|
||||
var headLength = 10;
|
||||
|
||||
var angle = Math.atan2(end.y - start.y, end.x - start.x);
|
||||
|
||||
//starting path of the arrow from the start square to the end square and drawing the stroke
|
||||
context.beginPath();
|
||||
context.moveTo(start.x, start.y);
|
||||
context.lineTo(end.x, end.y);
|
||||
context.strokeStyle = color;
|
||||
context.lineWidth = lineWidth;
|
||||
//context.setLineDash([ 2, 3 ]);
|
||||
context.stroke();
|
||||
|
||||
//starting a new path from the head of the arrow to one of the sides of the point
|
||||
context.beginPath();
|
||||
context.moveTo(end.x, end.y);
|
||||
context.lineTo(end.x - headLength * Math.cos(angle - Math.PI / 7), end.y - headLength * Math.sin(angle - Math.PI / 7));
|
||||
|
||||
//path from the side point of the arrow, to the other side point
|
||||
context.lineTo(end.x - headLength * Math.cos(angle + Math.PI / 7), end.y - headLength * Math.sin(angle + Math.PI / 7));
|
||||
|
||||
//path from the side point back to the tip of the arrow, and then again to the opposite side point
|
||||
context.lineTo(end.x, end.y);
|
||||
context.lineTo(end.x - headLength * Math.cos(angle - Math.PI / 7), end.y - headLength * Math.sin(angle - Math.PI / 7));
|
||||
|
||||
//draws the paths created above
|
||||
context.strokeStyle = color;
|
||||
context.lineWidth = lineWidth;
|
||||
context.stroke();
|
||||
context.fillStyle = color;
|
||||
context.fill();
|
||||
}
|
||||
|
||||
///////// BEGIN IMAGE RENDERING ///////
|
||||
function onImageRendered(e, eventData) {
|
||||
var element = eventData.element;
|
||||
|
||||
// if we have no toolData for this element, return immediately as there is nothing to do
|
||||
var toolData = cornerstoneTools.getToolState(element, toolType);
|
||||
if (!toolData) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we have tool data for this element - iterate over each one and draw it
|
||||
var context = eventData.canvasContext.canvas.getContext('2d');
|
||||
context.setTransform(1, 0, 0, 1, 0, 0);
|
||||
|
||||
var color;
|
||||
var lineWidth = cornerstoneTools.toolStyle.getToolWidth();
|
||||
var font = cornerstoneTools.textStyle.getFont();
|
||||
var config = cornerstoneTools[toolType].getConfiguration();
|
||||
|
||||
context.font = font;
|
||||
for (var i = 0; i < toolData.data.length; i++) {
|
||||
var data = toolData.data[i];
|
||||
|
||||
context.save();
|
||||
|
||||
// configurable shadow from CornerstoneTools
|
||||
if (config && config.shadow) {
|
||||
context.shadowColor = '#000000';
|
||||
context.shadowOffsetX = 1;
|
||||
context.shadowOffsetY = 1;
|
||||
}
|
||||
|
||||
if (data.active) {
|
||||
color = cornerstoneTools.toolColors.getActiveColor();
|
||||
} else {
|
||||
color = cornerstoneTools.toolColors.getToolColor();
|
||||
}
|
||||
|
||||
// Draw the arrow
|
||||
var handleStartCanvas = cornerstone.pixelToCanvas(element, data.handles.start);
|
||||
var handleEndCanvas = cornerstone.pixelToCanvas(element, data.handles.end);
|
||||
var canvasTextLocation = cornerstone.pixelToCanvas(element, data.handles.textBox);
|
||||
|
||||
drawDottedArrow(context, handleEndCanvas, handleStartCanvas, color, lineWidth);
|
||||
|
||||
if (config.drawHandles) {
|
||||
cornerstoneTools.drawHandles(context, eventData, data.handles, color);
|
||||
} else if (config.drawHandlesOnHover && data.handles.start.active) {
|
||||
cornerstoneTools.drawHandles(context, eventData, [data.handles.start], color);
|
||||
} else if (config.drawHandlesOnHover && data.handles.end.active) {
|
||||
cornerstoneTools.drawHandles(context, eventData, [data.handles.end], color);
|
||||
}
|
||||
|
||||
// Draw the text
|
||||
if (data.lesionNumber) {
|
||||
// Draw linked line as dashed
|
||||
var mid = {
|
||||
x: (handleStartCanvas.x + handleEndCanvas.x) / 2,
|
||||
y: (handleStartCanvas.y + handleEndCanvas.y) / 2
|
||||
};
|
||||
|
||||
context.beginPath();
|
||||
context.strokeStyle = color;
|
||||
context.lineWidth = lineWidth;
|
||||
context.setLineDash([2, 3]);
|
||||
|
||||
context.moveTo(mid.x, mid.y);
|
||||
context.lineTo(canvasTextLocation.x + 20, canvasTextLocation.y + 20);
|
||||
context.stroke();
|
||||
|
||||
var boundingBox = cornerstoneTools.drawTextBox(context, "Target " + +data.lesionNumber, canvasTextLocation.x, canvasTextLocation.y, color);
|
||||
data.handles.textBox.boundingBox = boundingBox;
|
||||
}
|
||||
|
||||
context.restore();
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Touch tool ----
|
||||
|
||||
///////// BEGIN ACTIVE TOOL ///////
|
||||
function addNewMeasurementTouch(touchEventData) {
|
||||
var element = touchEventData.element;
|
||||
|
||||
function doneCallback(lesionNumber) {
|
||||
measurementData.lesionNumber = lesionNumber;
|
||||
measurementData.active = true;
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
|
||||
var measurementData = createNewMeasurement(touchEventData);
|
||||
cornerstoneTools.addToolState(element, toolType, measurementData);
|
||||
$(element).off('CornerstoneToolsTouchDrag', cornerstoneTools[toolType + "Touch"].touchMoveHandle);
|
||||
$(element).off('CornerstoneToolsDragStartActive', cornerstoneTools[toolType + "Touch"].touchDownActivateCallback);
|
||||
$(element).off('CornerstoneToolsTap', cornerstoneTools[toolType + "Touch"].tapCallback);
|
||||
var config = cornerstoneTools[toolType].getConfiguration();
|
||||
|
||||
// Set lesion number and lesion name
|
||||
if (measurementData.lesionName === undefined) {
|
||||
config.setLesionNumberCallback(measurementData, touchEventData, doneCallback);
|
||||
}
|
||||
|
||||
cornerstone.updateImage(element);
|
||||
|
||||
cornerstoneTools.moveNewHandleTouch(touchEventData, toolType, measurementData, measurementData.handles.end, function() {
|
||||
cornerstone.updateImage(element);
|
||||
|
||||
if (cornerstoneTools.anyHandlesOutsideImage(touchEventData, measurementData.handles)) {
|
||||
// delete the measurement
|
||||
cornerstoneTools.removeToolState(element, toolType, measurementData);
|
||||
}
|
||||
|
||||
config.getLesionLocationCallback(measurementData, touchEventData, doneCallback);
|
||||
|
||||
$(element).on('CornerstoneToolsTouchDrag', cornerstoneTools[toolType + "Touch"].touchMoveHandle);
|
||||
$(element).on('CornerstoneToolsDragStartActive', cornerstoneTools[toolType + "Touch"].touchDownActivateCallback);
|
||||
$(element).on('CornerstoneToolsTap', cornerstoneTools[toolType + "Touch"].tapCallback);
|
||||
});
|
||||
}
|
||||
|
||||
function doubleClickCallback(e, eventData) {
|
||||
var element = eventData.element;
|
||||
var data;
|
||||
|
||||
function doneCallback(data, deleteTool) {
|
||||
if (deleteTool === true) {
|
||||
cornerstoneTools.removeToolState(element, toolType, data);
|
||||
cornerstone.updateImage(element);
|
||||
return;
|
||||
}
|
||||
|
||||
data.active = false;
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
|
||||
if (e.data && e.data.mouseButtonMask && !cornerstoneTools.isMouseButtonEnabled(eventData.which, e.data.mouseButtonMask)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var config = cornerstoneTools[toolType].getConfiguration();
|
||||
|
||||
var coords = eventData.currentPoints.canvas;
|
||||
var toolData = cornerstoneTools.getToolState(element, toolType);
|
||||
|
||||
// now check to see if there is a handle we can move
|
||||
if (!toolData) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < toolData.data.length; i++) {
|
||||
data = toolData.data[i];
|
||||
if (pointNearTool(element, data, coords)) {
|
||||
data.active = true;
|
||||
cornerstone.updateImage(element);
|
||||
// Allow relabelling via a callback
|
||||
config.changeLesionLocationCallback(data, eventData, doneCallback);
|
||||
|
||||
e.stopImmediatePropagation();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
toolInterface.mouse = cornerstoneTools.mouseButtonTool({
|
||||
addNewMeasurement: addNewMeasurement,
|
||||
createNewMeasurement: createNewMeasurement,
|
||||
onImageRendered: onImageRendered,
|
||||
pointNearTool: pointNearTool,
|
||||
toolType: toolType,
|
||||
mouseDoubleClickCallback: doubleClickCallback
|
||||
});
|
||||
|
||||
toolInterface.touch = cornerstoneTools.touchTool({
|
||||
addNewMeasurement: addNewMeasurementTouch,
|
||||
createNewMeasurement: createNewMeasurement,
|
||||
onImageRendered: onImageRendered,
|
||||
pointNearTool: pointNearTool,
|
||||
toolType: toolType
|
||||
// pressCallback: doubleClickCallback
|
||||
});
|
||||
|
||||
return toolInterface;
|
||||
}
|
||||
|
||||
var crToolInterface = createQualitativeTargetTool('crTool');
|
||||
cornerstoneTools.crTool = crToolInterface.mouse;
|
||||
cornerstoneTools.crTool.setConfiguration(configuration);
|
||||
cornerstoneTools.crToolTouch = crToolInterface.touch;
|
||||
|
||||
var unToolInterface = createQualitativeTargetTool('unTool');
|
||||
cornerstoneTools.unTool = unToolInterface.mouse;
|
||||
cornerstoneTools.unTool.setConfiguration(configuration);
|
||||
cornerstoneTools.unToolTouch = unToolInterface.touch;
|
||||
|
||||
var exToolInterface = createQualitativeTargetTool('exTool');
|
||||
cornerstoneTools.exTool = exToolInterface.mouse;
|
||||
cornerstoneTools.exTool.setConfiguration(configuration);
|
||||
cornerstoneTools.exToolTouch = exToolInterface.touch;
|
||||
|
||||
})($, cornerstone, cornerstoneMath, cornerstoneTools);
|
||||
@@ -0,0 +1,254 @@
|
||||
|
||||
(function($, cornerstone, cornerstoneTools) {
|
||||
|
||||
'use strict';
|
||||
|
||||
// Draw Intervals
|
||||
function drawIntervals (context, config) {
|
||||
|
||||
var i = 0;
|
||||
|
||||
while (config.verticalLine.start.y + i * config.verticalMinorTick <= config.vscaleBounds.bottomRight.y) {
|
||||
|
||||
var startPoint = {
|
||||
x: config.verticalLine.start.x,
|
||||
y: config.verticalLine.start.y + i * config.verticalMinorTick
|
||||
};
|
||||
|
||||
var endPoint = {
|
||||
x: 0,
|
||||
y: config.verticalLine.start.y + i * config.verticalMinorTick
|
||||
};
|
||||
if (i% 5 === 0) {
|
||||
|
||||
endPoint.x = config.verticalLine.start.x - config.majorTickLength;
|
||||
} else {
|
||||
|
||||
endPoint.x = config.verticalLine.start.x - config.minorTickLength;
|
||||
}
|
||||
|
||||
context.beginPath();
|
||||
context.strokeStyle = config.color;
|
||||
context.lineWidth = config.lineWidth;
|
||||
context.moveTo(startPoint.x, startPoint.y);
|
||||
context.lineTo(endPoint.x, endPoint.y);
|
||||
context.stroke();
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
|
||||
while (config.horizontalLine.start.x + i * config.horizontalMinorTick <= config.hscaleBounds.bottomRight.x) {
|
||||
|
||||
startPoint = {
|
||||
x: config.horizontalLine.start.x + i * config.horizontalMinorTick,
|
||||
y: config.horizontalLine.start.y
|
||||
};
|
||||
|
||||
endPoint = {
|
||||
x: config.horizontalLine.start.x + i * config.horizontalMinorTick,
|
||||
y: 0
|
||||
};
|
||||
|
||||
if (i% 5 === 0) {
|
||||
endPoint.y = config.horizontalLine.start.y - config.majorTickLength;
|
||||
} else {
|
||||
endPoint.y = config.horizontalLine.start.y - config.minorTickLength;
|
||||
}
|
||||
|
||||
context.beginPath();
|
||||
context.strokeStyle = config.color;
|
||||
context.lineWidth = config.lineWidth;
|
||||
context.moveTo(startPoint.x, startPoint.y);
|
||||
context.lineTo(endPoint.x, endPoint.y);
|
||||
context.stroke();
|
||||
|
||||
i++;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Draws long horizontal and vertical lines
|
||||
function drawFrameLines(context, config){
|
||||
|
||||
// Vertical Line
|
||||
var startPoint = {
|
||||
x: config.verticalLine.start.x,
|
||||
y: config.verticalLine.start.y
|
||||
};
|
||||
var endPoint = {
|
||||
x: config.verticalLine.end.x,
|
||||
y: config.verticalLine.end.y
|
||||
};
|
||||
|
||||
context.beginPath();
|
||||
context.strokeStyle = config.color;
|
||||
context.lineWidth = config.lineWidth;
|
||||
context.moveTo(startPoint.x, startPoint.y);
|
||||
context.lineTo(endPoint.x, endPoint.y);
|
||||
context.stroke();
|
||||
|
||||
// Horizontal line
|
||||
startPoint = {
|
||||
x: config.horizontalLine.start.x ,
|
||||
y: config.horizontalLine.start.y
|
||||
};
|
||||
endPoint = {
|
||||
x: config.horizontalLine.end.x,
|
||||
y: config.horizontalLine.end.y
|
||||
};
|
||||
|
||||
context.beginPath();
|
||||
context.strokeStyle = config.color;
|
||||
context.lineWidth = config.lineWidth;
|
||||
context.moveTo(startPoint.x, startPoint.y);
|
||||
context.lineTo(endPoint.x, endPoint.y);
|
||||
context.stroke();
|
||||
|
||||
// Draw intervals
|
||||
drawIntervals(context, config);
|
||||
|
||||
}
|
||||
|
||||
// Computes the max bound for scales on the image
|
||||
function computeScaleBounds(eventData, canvasSize, imageSize, horizontalReduction, verticalReduction) {
|
||||
|
||||
var canvasBounds = {
|
||||
left: 0,
|
||||
top: 0,
|
||||
width: canvasSize.width,
|
||||
height: canvasSize.height
|
||||
};
|
||||
|
||||
var hReduction = horizontalReduction * Math.min(1000, canvasSize.width);
|
||||
var vReduction = verticalReduction * Math.min(1000, canvasSize.height);
|
||||
canvasBounds = {
|
||||
left: canvasBounds.left + hReduction,
|
||||
top: canvasBounds.top + vReduction,
|
||||
width: canvasBounds.width - 2 * hReduction,
|
||||
height: canvasBounds.height - 2 * vReduction
|
||||
};
|
||||
|
||||
var startPoint = {
|
||||
x: 0,
|
||||
y: 0
|
||||
};
|
||||
var startPointImageBounds = {
|
||||
x: startPoint.x,
|
||||
y: startPoint.y
|
||||
};
|
||||
var endPointImageBounds = {
|
||||
x: startPoint.x + imageSize.width,
|
||||
y: startPoint.y + imageSize.height
|
||||
};
|
||||
|
||||
var startPointCanvasImageBounds = cornerstone.pixelToCanvas(eventData.element, startPointImageBounds);
|
||||
var endPointCanvasImageBounds = cornerstone.pixelToCanvas(eventData.element, endPointImageBounds);
|
||||
|
||||
var imageBoundsWidth = Math.abs(startPointCanvasImageBounds.x - endPointCanvasImageBounds.x);
|
||||
var imageBoundsHeight = Math.abs(startPointCanvasImageBounds.y - endPointCanvasImageBounds.y);
|
||||
|
||||
hReduction = horizontalReduction * imageBoundsWidth;
|
||||
vReduction = verticalReduction * imageBoundsHeight;
|
||||
|
||||
var imageBounds = {
|
||||
left: startPointCanvasImageBounds.x + hReduction,
|
||||
top: startPointCanvasImageBounds.y + vReduction,
|
||||
width: imageBoundsWidth - 2 * hReduction,
|
||||
height: imageBoundsHeight - 2 * vReduction
|
||||
};
|
||||
|
||||
return cornerstoneMath.rect.getIntersectionRect(canvasBounds, imageBounds);
|
||||
|
||||
}
|
||||
|
||||
function onImageRendered(e, eventData) {
|
||||
|
||||
// Check whether pixel spacing is defined
|
||||
if (!eventData.image.rowPixelSpacing || !eventData.image.columnPixelSpacing) {
|
||||
return;
|
||||
}
|
||||
|
||||
var viewport = cornerstone.getViewport(eventData.enabledElement.element);
|
||||
if (!viewport) {
|
||||
return;
|
||||
}
|
||||
|
||||
var canvasSize = {
|
||||
width: eventData.enabledElement.canvas.width,
|
||||
height: eventData.enabledElement.canvas.height
|
||||
};
|
||||
var imageSize = {
|
||||
width: eventData.enabledElement.image.width ,
|
||||
height: eventData.enabledElement.image.height
|
||||
};
|
||||
|
||||
// Distance between intervals is 10mm
|
||||
var verticalIntervalScale = (10.0 / eventData.enabledElement.image.rowPixelSpacing) * eventData.viewport.scale;
|
||||
var horizontalIntervalScale = (10.0 / eventData.enabledElement.image.rowPixelSpacing) * eventData.viewport.scale;
|
||||
|
||||
// 0.1 and 0.05 gives margin to horizontal and vertical lines
|
||||
var hscaleBounds = computeScaleBounds(eventData, canvasSize, imageSize, 0.1, 0.05);
|
||||
var vscaleBounds = computeScaleBounds(eventData, canvasSize, imageSize, 0.05, 0.1);
|
||||
|
||||
if (!canvasSize.width || !canvasSize.height || !imageSize.width || !imageSize.height || !hscaleBounds || !vscaleBounds) {
|
||||
return;
|
||||
}
|
||||
|
||||
var config = {
|
||||
hscaleBounds: hscaleBounds,
|
||||
vscaleBounds: vscaleBounds,
|
||||
verticalMinorTick: verticalIntervalScale,
|
||||
horizontalMinorTick: horizontalIntervalScale,
|
||||
minorTickLength: 12.5,
|
||||
majorTickLength: 25,
|
||||
verticalLine: {
|
||||
start: {
|
||||
x: vscaleBounds.bottomRight.x,
|
||||
y: vscaleBounds.topLeft.y
|
||||
},
|
||||
end: {
|
||||
x: vscaleBounds.bottomRight.x,
|
||||
y: vscaleBounds.bottomRight.y
|
||||
}
|
||||
},
|
||||
horizontalLine: {
|
||||
start: {
|
||||
x: hscaleBounds.topLeft.x,
|
||||
y: hscaleBounds.bottomRight.y
|
||||
},
|
||||
end: {
|
||||
x: hscaleBounds.bottomRight.x,
|
||||
y: hscaleBounds.bottomRight.y
|
||||
}
|
||||
},
|
||||
color: 'white', // TODO: fix this later
|
||||
lineWidth: cornerstoneTools.toolStyle.getToolWidth()
|
||||
};
|
||||
|
||||
var context = eventData.enabledElement.canvas.getContext('2d');
|
||||
context.setTransform(1, 0, 0, 1, 0, 0);
|
||||
context.save();
|
||||
|
||||
// Draw frame lines
|
||||
drawFrameLines(context, config);
|
||||
|
||||
context.restore();
|
||||
|
||||
}
|
||||
|
||||
///////// END IMAGE RENDERING ///////
|
||||
|
||||
function disable(element) {
|
||||
// TODO: displayTool does not have cornerstone.updateImage(element) method to hide tool
|
||||
$(element).off('CornerstoneImageRendered', onImageRendered);
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
|
||||
// module exports
|
||||
cornerstoneTools.scaleOverlayTool = cornerstoneTools.displayTool(onImageRendered);
|
||||
cornerstoneTools.scaleOverlayTool.disable = disable;
|
||||
|
||||
})($, cornerstone, cornerstoneTools);
|
||||
@@ -0,0 +1,28 @@
|
||||
<template name="measureFlow">
|
||||
<div class="measure-flow {{#if this.treeColumns}}tree-columns{{/if}} {{instance.state.get}}" style="position:fixed; top:200px; left:400px">
|
||||
<button class="btn-add">Add label</button>
|
||||
{{#if eq instance.state.get 'selected'}}
|
||||
<div class="tree-leaf">
|
||||
<i class="icon-check"></i>
|
||||
<span>{{instance.value.label}}</span>
|
||||
{{#if instance.descriptionEdit.get}}
|
||||
<div class="description clearfix">
|
||||
<textarea
|
||||
class="pull-left"
|
||||
rows="1"
|
||||
style="{{#unless instance.description.get}}height:0{{/unless}}"
|
||||
>{{instance.description.get}}</textarea>
|
||||
</div>
|
||||
{{else}}
|
||||
{{#if instance.description.get}}
|
||||
<div class="descriptionText">{{instance.description.get}}</div>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
<div class="actions clearfix">
|
||||
<button class="pull-left btn-rename">Rename</button>
|
||||
<button class="pull-right btn-description">{{valueIf instance.description.get 'Edit' 'Add'}} description</button>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,254 @@
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
import { Template } from 'meteor/templating';
|
||||
import { Blaze } from 'meteor/blaze';
|
||||
import { ReactiveVar } from 'meteor/reactive-var';
|
||||
import { _ } from 'meteor/underscore';
|
||||
import { $ } from 'meteor/jquery';
|
||||
|
||||
Template.measureFlow.onCreated(() => {
|
||||
const instance = Template.instance();
|
||||
|
||||
instance.state = new ReactiveVar('closed');
|
||||
instance.description = new ReactiveVar('');
|
||||
instance.descriptionEdit = new ReactiveVar(false);
|
||||
|
||||
instance.items = [{
|
||||
label: 'Category 1',
|
||||
value: 'Category 1',
|
||||
items: [{
|
||||
label: 'Subcategory 1.1',
|
||||
value: 'Subcategory 1.1'
|
||||
}, {
|
||||
label: 'Subcategory 1.2',
|
||||
value: 'Subcategory 1.2',
|
||||
items: [{
|
||||
label: 'Subcategory 1.2.1',
|
||||
value: 'Subcategory 1.2.1'
|
||||
}, {
|
||||
label: 'Subcategory 1.2.2',
|
||||
value: 'Subcategory 1.2.2',
|
||||
items: [{
|
||||
label: 'Subcategory 1.2.2.1',
|
||||
value: 'Subcategory 1.2.2.1'
|
||||
}, {
|
||||
label: 'Subcategory 1.2.2.2',
|
||||
value: 'Subcategory 1.2.2.2'
|
||||
}]
|
||||
}]
|
||||
}]
|
||||
}, {
|
||||
label: 'Category 2',
|
||||
value: 'Category 2',
|
||||
items: [{
|
||||
label: 'Subcategory 2.1',
|
||||
value: 'Subcategory 2.1'
|
||||
}, {
|
||||
label: 'Subcategory 2.2',
|
||||
value: 'Subcategory 2.2'
|
||||
}, {
|
||||
label: 'Subcategory 2.3',
|
||||
value: 'Subcategory 2.3'
|
||||
}]
|
||||
}, {
|
||||
label: 'Category 3',
|
||||
value: 'Category 3'
|
||||
}];
|
||||
|
||||
const items = [
|
||||
'Abdomen/Chest Wall',
|
||||
'Adrenal',
|
||||
'Bladder',
|
||||
'Bone',
|
||||
'Brain',
|
||||
'Breast',
|
||||
'Colon',
|
||||
'Esophagus',
|
||||
'Extremities',
|
||||
'Gallbladder',
|
||||
'Kidney',
|
||||
'Liver',
|
||||
'Lung',
|
||||
'Lymph Node',
|
||||
'Mediastinum/Hilum',
|
||||
'Muscle',
|
||||
'Neck',
|
||||
'Other Soft Tissue',
|
||||
'Ovary',
|
||||
'Pancreas',
|
||||
'Pelvis',
|
||||
'Peritoneum/Omentum',
|
||||
'Prostate',
|
||||
'Retroperitoneum',
|
||||
'Small Bowel',
|
||||
'Spleen',
|
||||
'Stomach',
|
||||
'Subcutaneous'
|
||||
];
|
||||
|
||||
instance.items = [];
|
||||
_.each(items, item => {
|
||||
instance.items.push({
|
||||
label: item,
|
||||
value: item
|
||||
});
|
||||
});
|
||||
|
||||
const commonItems = [
|
||||
'Abdomen/Chest Wall',
|
||||
'Lung',
|
||||
'Lymph Node',
|
||||
'Liver',
|
||||
'Mediastinum/Hilum',
|
||||
'Pelvis',
|
||||
'Peritoneum/Omentum',
|
||||
'Retroperitoneum'
|
||||
];
|
||||
|
||||
instance.commonItems = [];
|
||||
_.each(commonItems, item => {
|
||||
instance.commonItems.push({
|
||||
label: item,
|
||||
value: item
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Template.measureFlow.onRendered(() => {
|
||||
const instance = Template.instance();
|
||||
|
||||
// Make the measure flow bounded by the window borders
|
||||
instance.$('.measure-flow').bounded();
|
||||
});
|
||||
|
||||
Template.measureFlow.events({
|
||||
'click .measure-flow .btn-add, click .measure-flow .btn-rename'(event, instance) {
|
||||
// Set the open state for the component
|
||||
instance.state.set('open');
|
||||
|
||||
// Wait template rerender before rendering the selectTree
|
||||
Tracker.afterFlush(() => {
|
||||
// Get the click position
|
||||
const position = {
|
||||
left: event.clientX,
|
||||
top: event.clientY,
|
||||
};
|
||||
|
||||
// Define the data for selectTreeComponent
|
||||
const data = {
|
||||
key: 'label',
|
||||
items: instance.items,
|
||||
commonItems: instance.commonItems,
|
||||
hideCommon: instance.data.hideCommon,
|
||||
label: 'Assign label',
|
||||
searchPlaceholder: 'Search labels',
|
||||
storageKey: 'measureLabelCommon',
|
||||
treeColumns: instance.data.treeColumns,
|
||||
position
|
||||
};
|
||||
|
||||
// Define in which element the selectTree will be rendered in
|
||||
const parentElement = instance.$('.measure-flow')[0];
|
||||
|
||||
// Render the selectTree element
|
||||
instance.selectTreeView = Blaze.renderWithData(Template.selectTree, data, parentElement);
|
||||
});
|
||||
},
|
||||
|
||||
'click .measure-flow .btn-description'(event, instance) {
|
||||
// Fade out the action buttons
|
||||
instance.$('.measure-flow .actions').addClass('fadeOut');
|
||||
|
||||
// Set the description edit mode
|
||||
instance.descriptionEdit.set(true);
|
||||
|
||||
// Wait for DOM re-rendering, resize and focus the description textarea
|
||||
Tracker.afterFlush(() => {
|
||||
const $textarea = instance.$('textarea');
|
||||
$textarea.trigger('input').focus();
|
||||
});
|
||||
},
|
||||
|
||||
'input textarea, change textarea'(event, instance) {
|
||||
const element = event.currentTarget;
|
||||
const $element = $(element);
|
||||
|
||||
// Resize the textarea based on its content length
|
||||
$element.css('max-height', 0);
|
||||
$element.height(element.scrollHeight);
|
||||
$element.css('max-height', '');
|
||||
|
||||
// Reposition the measure flow if needed
|
||||
const $measureFlow = instance.$('.measure-flow');
|
||||
$element.one('transitionend', () => $measureFlow.trigger('spatialChanged'));
|
||||
},
|
||||
|
||||
'keydown textarea'(event, instance) {
|
||||
// Unset the description edit mode if ENTER or ESC was pressed
|
||||
if (event.which === 13 || event.which === 27) {
|
||||
instance.$('.measure-flow .actions').removeClass('fadeOut');
|
||||
instance.descriptionEdit.set(false);
|
||||
}
|
||||
|
||||
// Keep the current description if ENTER was pressed
|
||||
if (event.which === 13) {
|
||||
instance.description.set($(event.currentTarget).val());
|
||||
}
|
||||
},
|
||||
|
||||
'click .select-tree-common label'(event, instance) {
|
||||
// Set the common section clicked flag
|
||||
instance.commonClicked = true;
|
||||
},
|
||||
|
||||
'change .select-tree-root'(event, instance) {
|
||||
// Stop here if it's an inner input event
|
||||
if (event.target !== event.currentTarget) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Store the selectTree component value before it's removed from DOM
|
||||
const $treeRoot = $(event.currentTarget);
|
||||
instance.value = $treeRoot.data('component').value();
|
||||
},
|
||||
|
||||
'click .tree-leaf input'(event, instance) {
|
||||
const $target = $(event.currentTarget);
|
||||
const $label = $target.closest('label');
|
||||
const $treeRoot = $label.closest('.select-tree-root');
|
||||
const $container = $treeRoot.find('.tree-options:first');
|
||||
|
||||
// Check if the targe click was a label inside common section
|
||||
if (instance.commonClicked) {
|
||||
const labelTop = $label.position().top;
|
||||
const containerCenter = Math.round($container.height() / 2);
|
||||
const labelCenter = Math.round($label.height() / 2);
|
||||
|
||||
// Scroll the options container to make the target input visible
|
||||
$container.scrollTop(labelTop - containerCenter + labelCenter);
|
||||
}
|
||||
|
||||
// Change the measure flow state to selected
|
||||
instance.state.set('selected');
|
||||
|
||||
// Get the clicked label window offset
|
||||
const labelOffset = $label.offset();
|
||||
|
||||
// Wait for the DOM re-rendering
|
||||
Tracker.afterFlush(() => {
|
||||
// Get the measure flow div
|
||||
const $measureFlow = instance.$('.measure-flow');
|
||||
|
||||
// Subtract the label box shadow height from the label's position
|
||||
labelOffset.top -= 10;
|
||||
|
||||
// Reposition the measure flow based on the clicked label position
|
||||
$measureFlow.css(labelOffset);
|
||||
|
||||
// Resize the copied label with same width of the clicked one
|
||||
$measureFlow.children('.tree-leaf').width($label.outerWidth());
|
||||
});
|
||||
|
||||
// Wait the fade-out transition and remove the selectTree component
|
||||
$container.one('transitionend', event => Blaze.remove(instance.selectTreeView));
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,187 @@
|
||||
@import "{design}/app"
|
||||
|
||||
.measure-flow
|
||||
position: relative
|
||||
|
||||
&.open,
|
||||
&.selected
|
||||
|
||||
.btn-add
|
||||
opacity: 0
|
||||
|
||||
.btn-add
|
||||
theme('color', '$textColorActive')
|
||||
theme('background-color', '$activeColor')
|
||||
theme('border', '2px solid $uiBorderColor')
|
||||
border-radius: 14px
|
||||
cursor: pointer
|
||||
font-weight: bold
|
||||
height: 24px
|
||||
left: 0
|
||||
line-height: 24px
|
||||
opacity: 1
|
||||
position: absolute
|
||||
padding: 0 14px
|
||||
top: 0
|
||||
transition(opacity 0.3s ease)
|
||||
white-space: nowrap
|
||||
|
||||
// / {selector()}
|
||||
// color: $themes['tide']['uiYellow'] !important
|
||||
|
||||
.select-tree-root>.tree-content
|
||||
width: 213px
|
||||
|
||||
&>.tree-options
|
||||
position: relative
|
||||
z-index: 2
|
||||
|
||||
.tree-inputs
|
||||
position: relative
|
||||
|
||||
&>.tree-leaf
|
||||
position: relative
|
||||
|
||||
.icon-check
|
||||
theme('background-color', '$activeColor')
|
||||
left: -46px
|
||||
position: absolute
|
||||
top: 3px
|
||||
|
||||
span
|
||||
background: white
|
||||
font-weight: normal
|
||||
height: 46px
|
||||
line-height: 46px
|
||||
padding: 0 12px
|
||||
|
||||
input, span
|
||||
display: none
|
||||
|
||||
.actions
|
||||
margin-top: 16px
|
||||
opacity: 0
|
||||
|
||||
&:not(.fadeOut)
|
||||
animateFadeIn()
|
||||
animation-delay: 0.3s
|
||||
|
||||
&.fadeOut
|
||||
animateFadeOut()
|
||||
|
||||
button
|
||||
theme('border', '1px solid $uiBorderColor')
|
||||
theme('color', '$textPrimaryColor')
|
||||
background-color: transparent
|
||||
border-radius: 16px
|
||||
font-weight: normal
|
||||
height: 31px
|
||||
line-height: 31px
|
||||
padding: 0 12px
|
||||
text-align: center
|
||||
|
||||
.description
|
||||
margin-top: -10px
|
||||
margin-bottom: 26px
|
||||
|
||||
textarea
|
||||
background-color: white
|
||||
box-shadow: 0 10px white
|
||||
border: 0
|
||||
line-height: 20px
|
||||
outline: none
|
||||
overflow: hidden
|
||||
padding: 0 12px
|
||||
resize: none
|
||||
transition(height 0.3s ease)
|
||||
width: 100%
|
||||
|
||||
.descriptionText
|
||||
background-color: white
|
||||
box-shadow: 0 10px white
|
||||
line-height: 20px
|
||||
margin-bottom: 26px
|
||||
margin-top: -10px
|
||||
padding: 0 12px
|
||||
|
||||
&.selected>.tree-leaf
|
||||
|
||||
span
|
||||
display: block
|
||||
|
||||
&.tree-columns
|
||||
|
||||
.select-tree-root
|
||||
|
||||
&.interacted .select-tree-common .content
|
||||
animation-name: none
|
||||
|
||||
&.selected .select-tree-common .content
|
||||
animation-name: selectTreeCommonCloseLeft
|
||||
|
||||
.tree-search
|
||||
input, i
|
||||
display: none
|
||||
|
||||
.select-tree-common
|
||||
padding-left: 0
|
||||
padding-right: 6px
|
||||
right: auto
|
||||
left: 0
|
||||
width: 33.333333333333%
|
||||
|
||||
&>.tree-content
|
||||
transform-origin(0% 50%)
|
||||
width: 426px
|
||||
|
||||
.select-tree-common .content
|
||||
right: -100%
|
||||
|
||||
&.started .select-tree-common .content
|
||||
right: 6px
|
||||
|
||||
&.interacted .select-tree-common .content
|
||||
animation-name: selectTreeCommonCloseRight
|
||||
|
||||
.tree-inputs>label
|
||||
float: left
|
||||
width: 50%
|
||||
|
||||
@keyframes selectTreeCommonCloseRight {
|
||||
from {
|
||||
height: 37px
|
||||
display: table
|
||||
right: 6px
|
||||
opacity: 1
|
||||
visibility: visible
|
||||
}
|
||||
to {
|
||||
height: 100%
|
||||
right: -100%
|
||||
opacity: 0
|
||||
visibility: hidden
|
||||
width: calc(100% - 6px)
|
||||
}
|
||||
}
|
||||
|
||||
.icon-check
|
||||
background-color: white
|
||||
border-radius: 20px
|
||||
display: block
|
||||
height: 40px
|
||||
overflow: hidden
|
||||
position: relative
|
||||
width: 40px
|
||||
|
||||
&:before
|
||||
border: 2px solid black
|
||||
border-left-width: 0
|
||||
border-top-width: 0
|
||||
content: ''
|
||||
display: block
|
||||
height: 18px
|
||||
left: 15px
|
||||
position: absolute
|
||||
top: 9px
|
||||
transform(rotate(45deg))
|
||||
width: 9px
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
<template name="measurementLocationDialog">
|
||||
<div id="measurementLocationDialog" class="dialog-animated" tabindex="0">
|
||||
<div class="dialogHeader">
|
||||
<h4>Select Location</h4>
|
||||
</div>
|
||||
<div class="dialogContent">
|
||||
<div class="measurementLocation">
|
||||
<label>Location</label>
|
||||
<select class="selectMeasurementLocation">
|
||||
<option value="-1"></option>
|
||||
{{ #each measurementLocations}}
|
||||
<option value='{{_id}}'>{{location}}</option>
|
||||
{{ /each}}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="measurementLocationRelabelDialog" class="dialog-animated" tabindex="0">
|
||||
<div class="dialogHeader">
|
||||
<h4>Change Location</h4>
|
||||
</div>
|
||||
<a></a>
|
||||
<div class="dialogContent">
|
||||
<div class="measurementLocation">
|
||||
<label>Location</label>
|
||||
<select class="selectMeasurementLocation">
|
||||
<option value="-1"></option>
|
||||
{{ #each measurementLocations}}
|
||||
<option value='{{_id}}' selected={{selected}}>{{location}}</option>
|
||||
{{ /each}}
|
||||
</select>
|
||||
</div>
|
||||
<button id="removeLesion" class="btn btn-link">Remove</button>
|
||||
<button id="convertToNonTarget" class="btn btn-link">Convert to Non-Target</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
+296
@@ -0,0 +1,296 @@
|
||||
import { MeasurementManager } from 'meteor/ohif:measurements/client/lib/MeasurementManager';
|
||||
|
||||
function closeHandler(dialog) {
|
||||
// Hide the lesion dialog
|
||||
$(dialog).css('display', 'none');
|
||||
|
||||
// Remove the backdrop
|
||||
$('.removableBackdrop').remove();
|
||||
|
||||
// Restore the focus to the active viewport
|
||||
setFocusToActiveViewport();
|
||||
}
|
||||
|
||||
// This event sets lesion number for new lesion
|
||||
|
||||
function getSetLesionNumberCallbackFunction(measurementTypeId, measurementApi, timepointApi) {
|
||||
return (measurementData, eventData, doneCallback) => {
|
||||
// Get the current element's timepointId from the study date metadata
|
||||
var element = eventData.element;
|
||||
var enabledElement = cornerstone.getEnabledElement(element);
|
||||
var imageId = enabledElement.image.imageId;
|
||||
|
||||
var study = cornerstoneTools.metaData.get('study', imageId);
|
||||
if (!timepointApi) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Find the relevant timepoint given the current study
|
||||
var timepoint = timepointApi.study(study.studyInstanceUid)[0];
|
||||
if (!timepoint) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get a lesion number for this lesion, depending on whether or not the same lesion previously
|
||||
// exists at a different timepoint
|
||||
const timepointId = timepoint.timepointId;
|
||||
const collection = measurementApi[measurementTypeId];
|
||||
const measurementNumber = MeasurementManager.getNewMeasurementNumber(timepointId, collection, timepointApi);
|
||||
measurementData.measurementNumber = measurementNumber;
|
||||
|
||||
// Set lesion number
|
||||
doneCallback(measurementNumber);
|
||||
}
|
||||
}
|
||||
|
||||
// This event determines whether or not to show the lesion dialog
|
||||
// If there already exists a lesion with this specific lesion number,
|
||||
// related to the chosen location.
|
||||
function getLesionLocationCallback(measurementData, eventData) {
|
||||
return;
|
||||
Template.measurementLocationDialog.measurementData = measurementData;
|
||||
|
||||
// Reset the doneCallback saved in the template so we don't call the change event's done callback
|
||||
Template.measurementLocationDialog.doneCallback = undefined;
|
||||
|
||||
// Get the lesion location dialog
|
||||
var dialog = $('#measurementLocationDialog');
|
||||
Template.measurementLocationDialog.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);
|
||||
});
|
||||
|
||||
// Select the first option for now
|
||||
var selector = dialog.find('select.selectMeasurementLocation');
|
||||
selector.find('option:first').prop('selected', true);
|
||||
|
||||
// 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 = MeasurementManager.getLocationIdIfMeasurementExists(measurementData);
|
||||
if (locationUID) {
|
||||
// Add an ID value to the tool data to link it to the Measurements collection
|
||||
measurementData.id = 'notready';
|
||||
|
||||
measurementData.locationUID = locationUID;
|
||||
LesionManager.updateLesionData(measurementData);
|
||||
closeHandler();
|
||||
return;
|
||||
}
|
||||
// If it isn't, continue to open the dialog and have the user choose a lesion location
|
||||
|
||||
// Show the lesion location dialog above
|
||||
var dialogProperty = {
|
||||
top: eventData.currentPoints.page.y - dialog.outerHeight() - 40,
|
||||
left: eventData.currentPoints.page.x - dialog.outerWidth() / 2,
|
||||
display: 'block'
|
||||
};
|
||||
|
||||
var pageHeight = $(window).height();
|
||||
dialogProperty.top = Math.max(dialogProperty.top, 0);
|
||||
dialogProperty.top = Math.min(dialogProperty.top, pageHeight - dialog.outerHeight());
|
||||
|
||||
var pageWidth = $(window).width();
|
||||
dialogProperty.left = Math.max(dialogProperty.left, 0);
|
||||
dialogProperty.left = Math.min(dialogProperty.left, pageWidth - dialog.outerWidth());
|
||||
|
||||
// Device is touch device or not
|
||||
// If device is touch device, set position center of screen vertically and horizontally
|
||||
if (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;
|
||||
}
|
||||
|
||||
dialog.css(dialogProperty);
|
||||
dialog.focus();
|
||||
}
|
||||
|
||||
changeLesionLocationCallback = function(measurementData, eventData, doneCallback) {
|
||||
return;
|
||||
Template.measurementLocationDialog.measurementData = measurementData;
|
||||
Template.measurementLocationDialog.doneCallback = doneCallback;
|
||||
|
||||
// Get the lesion location dialog
|
||||
var dialog = $('#measurementLocationRelabelDialog');
|
||||
|
||||
// Show/Hide Convert To NonTarget option in measurementLocationRelabelDialog
|
||||
if (measurementData.toolType === 'bidirectional') {
|
||||
dialog.find("#convertToNonTarget").css("visibility", "visible");
|
||||
} else {
|
||||
dialog.find("#convertToNonTarget").css("visibility", "hidden");
|
||||
}
|
||||
|
||||
Template.measurementLocationDialog.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);
|
||||
});
|
||||
|
||||
// Show the lesion location 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);
|
||||
dialog.focus();
|
||||
|
||||
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
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Template.measurementLocationDialog.onCreated(() => {
|
||||
const instance = Template.instance();
|
||||
const measurementTypeId = 'targets';
|
||||
const measurementApi = instance.data.measurementApi;
|
||||
const timepointApi = instance.data.timepointApi;
|
||||
|
||||
const config = {
|
||||
setLesionNumberCallback: getSetLesionNumberCallbackFunction(measurementTypeId, measurementApi, timepointApi),
|
||||
getLesionLocationCallback: getLesionLocationCallback,
|
||||
changeLesionLocationCallback: changeLesionLocationCallback
|
||||
};
|
||||
|
||||
cornerstoneTools.bidirectional.setConfiguration(config);
|
||||
|
||||
// Set CR-Tool, UN-Tool, EX-Tool configurations
|
||||
cornerstoneTools.crTool.setConfiguration(config);
|
||||
cornerstoneTools.exTool.setConfiguration(config);
|
||||
cornerstoneTools.unTool.setConfiguration(config);
|
||||
|
||||
});
|
||||
|
||||
Template.measurementLocationDialog.events({
|
||||
'change .selectMeasurementLocation': function(e) {
|
||||
var measurementData = Template.measurementLocationDialog.measurementData;
|
||||
var doneCallback = Template.measurementLocationDialog.doneCallback;
|
||||
var dialog = Template.measurementLocationDialog.dialog;
|
||||
|
||||
// Get the current value of the selector
|
||||
var selectedOptionId = e.currentTarget.value;
|
||||
|
||||
// If the selected option is still the default (-1)
|
||||
// then stop here
|
||||
if (selectedOptionId < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get selected location data
|
||||
var locationObj = LesionLocations.findOne({
|
||||
_id: selectedOptionId
|
||||
});
|
||||
|
||||
Measurements.update(measurementData.id, {
|
||||
$set: {
|
||||
locationId: locationObj.id,
|
||||
}
|
||||
});
|
||||
|
||||
// Close the dialog
|
||||
closeHandler(dialog);
|
||||
|
||||
if (doneCallback && typeof doneCallback === 'function') {
|
||||
doneCallback(measurementData);
|
||||
}
|
||||
},
|
||||
'click #removeLesion': function() {
|
||||
var measurementData = Template.measurementLocationDialog.measurementData;
|
||||
var doneCallback = Template.measurementLocationDialog.doneCallback;
|
||||
var dialog = Template.measurementLocationDialog.dialog;
|
||||
|
||||
var options = {
|
||||
keyPressAllowed: false,
|
||||
title: 'Remove measurement?',
|
||||
text: 'Are you sure you would like to remove the entire measurement?'
|
||||
};
|
||||
|
||||
showConfirmDialog(function() {
|
||||
if (doneCallback && typeof doneCallback === 'function') {
|
||||
var deleteTool = true;
|
||||
doneCallback(measurementData, deleteTool);
|
||||
}
|
||||
}, options);
|
||||
|
||||
closeHandler(dialog);
|
||||
},
|
||||
'click #convertToNonTarget': function() {
|
||||
var measurementData = Template.measurementLocationDialog.measurementData;
|
||||
var dialog = Template.measurementLocationDialog.dialog;
|
||||
|
||||
const instance = Template.instance()
|
||||
const measurementApi = instance.data.measurementApi;
|
||||
convertToNonTarget(measurementApi, measurementData);
|
||||
|
||||
closeHandler(dialog);
|
||||
},
|
||||
'click #btnCloseLesionPopup': function() {
|
||||
var dialog = Template.measurementLocationDialog.dialog;
|
||||
closeHandler(dialog);
|
||||
},
|
||||
'keydown #measurementLocationDialog, keydown #measurementLocationRelabelDialog': function(e) {
|
||||
var dialog = Template.measurementLocationDialog.dialog;
|
||||
|
||||
// If Esc or Enter are pressed, close the dialog
|
||||
if (e.which === keys.ESC || e.which === keys.ENTER) {
|
||||
closeHandler(dialog);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Template.measurementLocationDialog.helpers({
|
||||
measurementLocations: function() {
|
||||
return LesionLocations.find();
|
||||
}
|
||||
});
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
#measurementLocationDialog, #measurementLocationRelabelDialog
|
||||
display: none
|
||||
position: absolute
|
||||
top: 0
|
||||
bottom: 0
|
||||
left: 0
|
||||
right: 0
|
||||
z-index: 100
|
||||
width: 300px
|
||||
height: 130px
|
||||
border-radius: 5px
|
||||
padding: 10px 20px 10px 20px
|
||||
background-color: rgba(255,255,255,1)
|
||||
outline: none
|
||||
|
||||
#closeLesionPopup
|
||||
outline: none
|
||||
border: none
|
||||
background-color: transparent
|
||||
|
||||
#selectMeasurementLocation
|
||||
margin-top: 5px
|
||||
|
||||
.dialogContent
|
||||
margin-bottom: 10px
|
||||
|
||||
#removeLesion
|
||||
outline: none
|
||||
text-decoration: none
|
||||
|
||||
#measurementLocationDialog
|
||||
height: 110px
|
||||
|
||||
#measurementLocationRelabelDialog
|
||||
height: 125px
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
<template name="nonTargetLesionDialog">
|
||||
<div id="nonTargetLesionLocationDialog" class="dialog-animated" tabindex="0">
|
||||
<div class="dialogHeader">
|
||||
<h4>Select Lesion Location</h4>
|
||||
</div>
|
||||
<div class="dialogContent">
|
||||
<div class="lesionLocation">
|
||||
<label>Lesion Location</label>
|
||||
<select id="selectNonTargetLesionLocation">
|
||||
<option value="-1"></option>
|
||||
{{ #each lesionLocations}}
|
||||
<option value={{_id}}>{{location}}</option>
|
||||
{{ /each}}
|
||||
</select>
|
||||
</div>
|
||||
<div class="locationResponse">
|
||||
<label>Response</label>
|
||||
<select id="selectNonTargetLesionLocationResponse">
|
||||
<option value="-1" selected="true"></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-primary" id="nonTargetLesionOK">OK</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="nonTargetLesionRelabelDialog" class="dialog-animated" tabindex="0">
|
||||
<div class="dialogHeader">
|
||||
<h4>Select Lesion Location</h4>
|
||||
</div>
|
||||
<div class="dialogContent">
|
||||
<div class="lesionLocation">
|
||||
<label>Lesion Location</label>
|
||||
<select id="selectNonTargetLesionLocation">
|
||||
<option value="-1"></option>
|
||||
{{ #each lesionLocations}}
|
||||
<option value='{{_id}}' selected={{selected}}>{{location}}</option>
|
||||
{{ /each}}
|
||||
</select>
|
||||
</div>
|
||||
<div class="locationResponse">
|
||||
<label>Response</label>
|
||||
<select id="selectNonTargetLesionLocationResponse">
|
||||
<option value="-1" selected="true"></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>
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-link dropdown-toggle"
|
||||
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
Convert
|
||||
</button>
|
||||
<div class="dropdown-menu">
|
||||
{{ #each conversionOptions }}
|
||||
<a class="btn btn-link dropdown-item convertNonTarget" data-type="{{id}}">{{name}}</a>
|
||||
{{ /each }}
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn btn-primary" id="nonTargetLesionOK">OK</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
+372
@@ -0,0 +1,372 @@
|
||||
import { MeasurementManager } from 'meteor/ohif:measurements/client/lib/MeasurementManager';
|
||||
|
||||
function closeHandler(dialog) {
|
||||
// Hide the lesion dialog
|
||||
$(dialog).css('display', 'none');
|
||||
|
||||
// Remove the backdrop
|
||||
$('.removableBackdrop').remove();
|
||||
|
||||
// Restore the focus to the active viewport
|
||||
setFocusToActiveViewport();
|
||||
}
|
||||
|
||||
// This event sets lesion number for new lesion
|
||||
function getSetLesionNumberCallbackFunction(measurementTypeId, measurementApi, timepointApi) {
|
||||
return (measurementData, eventData, doneCallback) => {
|
||||
// Get the current element's timepointId from the study date metadata
|
||||
var element = eventData.element;
|
||||
var enabledElement = cornerstone.getEnabledElement(element);
|
||||
var imageId = enabledElement.image.imageId;
|
||||
|
||||
var study = cornerstoneTools.metaData.get('study', imageId);
|
||||
|
||||
// Find the relevant timepoint given the current study
|
||||
var timepoint = timepointApi.study(study.studyInstanceUid)[0];
|
||||
if (!timepoint) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get a lesion number for this lesion, depending on whether or not the same lesion previously
|
||||
// exists at a different timepoint
|
||||
const timepointId = timepoint.timepointId;
|
||||
const collection = measurementApi[measurementTypeId];
|
||||
const measurementNumber = MeasurementManager.getNewMeasurementNumber(timepointId, collection, timepointApi);
|
||||
measurementData.measurementNumber = measurementNumber;
|
||||
|
||||
// Set lesion number
|
||||
doneCallback(measurementNumber);
|
||||
}
|
||||
}
|
||||
|
||||
function selectNonTargetResponse(responseCode) {
|
||||
// First, disable all other responses
|
||||
LocationResponses.update({}, {
|
||||
$set: {
|
||||
selected: false
|
||||
}
|
||||
}, {
|
||||
multi: true
|
||||
});
|
||||
|
||||
// If no response code is specified, leave them all disabled
|
||||
if (!responseCode) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Find the specified response by code and set it as selected
|
||||
LocationResponses.update({
|
||||
code: responseCode
|
||||
}, {
|
||||
$set: {
|
||||
selected: true
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// This event determines whether or not to show the Non-Target lesion dialog
|
||||
// If there already exists a lesion with this specific lesion number,
|
||||
// related to the chosen location.
|
||||
function getLesionLocationCallback(measurementData, eventData) {
|
||||
return 'Test Location';
|
||||
Template.nonTargetLesionDialog.measurementData = measurementData;
|
||||
|
||||
// Get the non-target lesion location dialog
|
||||
var dialog = $('#nonTargetLesionLocationDialog');
|
||||
Template.nonTargetLesionDialog.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);
|
||||
});
|
||||
|
||||
// Find the select option box
|
||||
var selectorLocation = dialog.find('select#selectNonTargetLesionLocation');
|
||||
|
||||
selectorLocation.find('option:first').prop('selected', 'selected');
|
||||
|
||||
// LT-112 "Non-target response shall default to non-measurable on baseline, present on follow-up"
|
||||
var timepoint = Timepoints.findOne({
|
||||
timepointId: measurementData.timepointId
|
||||
});
|
||||
|
||||
if (timepoint && timepoint.timepointType === 'baseline') {
|
||||
selectNonTargetResponse('Present');
|
||||
} else {
|
||||
selectNonTargetResponse();
|
||||
}
|
||||
|
||||
// Allow location selection
|
||||
selectorLocation.removeAttr('disabled');
|
||||
|
||||
// Find out if this lesion number is already added in the lesion manager for another timepoint
|
||||
// If it is, disable selector location
|
||||
var locationId = MeasurementManager.getLocationIdIfMeasurementExists(measurementData);
|
||||
if (locationId) {
|
||||
// Add an ID value to the tool data to link it to the Measurements collection
|
||||
measurementData.id = 'notready';
|
||||
|
||||
measurementData.locationId = locationId;
|
||||
|
||||
// Disable the selection of a new location
|
||||
disableLocationSelection(measurementData.locationId);
|
||||
}
|
||||
|
||||
// Disable selector location to prevent selecting a new location
|
||||
function disableLocationSelection(locationId) {
|
||||
var locationObject = LesionLocations.findOne({
|
||||
id: locationId
|
||||
});
|
||||
|
||||
if (!locationObject) {
|
||||
return;
|
||||
}
|
||||
|
||||
selectorLocation.find('option[value="' + locationObject._id + '"]').prop('selected', true);
|
||||
selectorLocation.prop('disabled', true);
|
||||
}
|
||||
|
||||
// Show the nonTargetLesion dialog above
|
||||
var dialogProperty = {
|
||||
top: eventData.currentPoints.page.y - dialog.outerHeight() - 40,
|
||||
left: eventData.currentPoints.page.x - dialog.outerWidth() / 2,
|
||||
display: 'block'
|
||||
};
|
||||
|
||||
var pageHeight = $(window).height();
|
||||
dialogProperty.top = Math.max(dialogProperty.top, 0);
|
||||
dialogProperty.top = Math.min(dialogProperty.top, pageHeight - dialog.outerHeight());
|
||||
|
||||
var pageWidth = $(window).width();
|
||||
dialogProperty.left = Math.max(dialogProperty.left, 0);
|
||||
dialogProperty.left = Math.min(dialogProperty.left, pageWidth - dialog.outerWidth());
|
||||
|
||||
// Device is touch device or not
|
||||
// If device is touch device, set position center of screen vertically and horizontally
|
||||
if (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;
|
||||
dialogProperty.margin = 'auto';
|
||||
}
|
||||
|
||||
dialog.css(dialogProperty);
|
||||
}
|
||||
|
||||
changeNonTargetLocationCallback = function(measurementData, eventData, doneCallback) {
|
||||
Template.nonTargetLesionDialog.measurementData = measurementData;
|
||||
Template.nonTargetLesionDialog.doneCallback = doneCallback;
|
||||
|
||||
// Get the non-target lesion location dialog
|
||||
var dialog = $('#nonTargetLesionRelabelDialog');
|
||||
Template.nonTargetLesionDialog.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);
|
||||
});
|
||||
|
||||
// Find the select option box
|
||||
var selectorLocation = dialog.find('select#selectNonTargetLesionLocation');
|
||||
var selectorResponse = dialog.find('select#selectNonTargetLesionLocationResponse');
|
||||
|
||||
selectorLocation.find('option:first').prop('selected', 'selected');
|
||||
selectorResponse.find('option:first').prop('selected', 'selected');
|
||||
|
||||
// Allow location selection
|
||||
selectorLocation.removeAttr('disabled');
|
||||
|
||||
// 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);
|
||||
dialog.focus();
|
||||
|
||||
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
|
||||
}
|
||||
});
|
||||
|
||||
var response = measurement.timepoints[measurementData.timepointId].response;
|
||||
selectNonTargetResponse(response);
|
||||
};
|
||||
|
||||
|
||||
Template.nonTargetLesionDialog.onCreated(() => {
|
||||
const instance = Template.instance();
|
||||
const measurementTypeId = 'nonTargets';
|
||||
const measurementApi = instance.data.measurementApi;
|
||||
const timepointApi = instance.data.timepointApi;
|
||||
|
||||
const config = {
|
||||
setLesionNumberCallback: getSetLesionNumberCallbackFunction(measurementTypeId, measurementApi, timepointApi),
|
||||
getLesionLocationCallback: getLesionLocationCallback,
|
||||
changeLesionLocationCallback: changeLesionLocationCallback
|
||||
};
|
||||
|
||||
cornerstoneTools.nonTarget.setConfiguration(config);
|
||||
});
|
||||
|
||||
Template.nonTargetLesionDialog.events({
|
||||
'change #selectNonTargetLesionLocationResponse': function(e) {
|
||||
var responseCode = $(e.currentTarget).val();
|
||||
selectNonTargetResponse(responseCode);
|
||||
},
|
||||
'click #nonTargetLesionOK': function() {
|
||||
var dialog = Template.nonTargetLesionDialog.dialog;
|
||||
var measurementData = Template.nonTargetLesionDialog.measurementData;
|
||||
|
||||
// Find the select option box
|
||||
var selectorLocation = dialog.find('select#selectNonTargetLesionLocation');
|
||||
|
||||
// Get the current value of the selector
|
||||
var selectedOptionId = selectorLocation.find('option:selected').val();
|
||||
|
||||
// If the selected option is still the default (-1)
|
||||
// then stop here
|
||||
if (selectedOptionId < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get selected location data
|
||||
var locationObj = LesionLocations.findOne({
|
||||
_id: selectedOptionId
|
||||
});
|
||||
|
||||
if (measurementData.id) {
|
||||
// Update the location data
|
||||
Measurements.update(measurementData.id, {
|
||||
$set: {
|
||||
location: locationObj.location,
|
||||
locationId: locationObj.id
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 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;
|
||||
|
||||
// Response is set from location response list
|
||||
measurementData.response = LocationResponses.findOne({selected: true}).code;
|
||||
|
||||
// Adds lesion data to timepoints array
|
||||
LesionManager.updateLesionData(measurementData);
|
||||
|
||||
// Close the dialog
|
||||
closeHandler(dialog);
|
||||
},
|
||||
'click #removeLesion': function() {
|
||||
var measurementData = Template.nonTargetLesionDialog.measurementData;
|
||||
var doneCallback = Template.nonTargetLesionDialog.doneCallback;
|
||||
var dialog = Template.nonTargetLesionDialog.dialog;
|
||||
|
||||
showConfirmDialog(function() {
|
||||
if (doneCallback && typeof doneCallback === 'function') {
|
||||
var deleteTool = true;
|
||||
doneCallback(measurementData, deleteTool);
|
||||
}
|
||||
});
|
||||
|
||||
closeHandler(dialog);
|
||||
},
|
||||
'click #btnCloseLesionPopup': function() {
|
||||
var dialog = Template.nonTargetLesionDialog.dialog;
|
||||
closeHandler(dialog);
|
||||
},
|
||||
'click a.convertNonTarget': function(evt) {
|
||||
var measurementData = Template.nonTargetLesionDialog.measurementData;
|
||||
var dialog = Template.nonTargetLesionDialog.dialog;
|
||||
|
||||
var button = $(evt.currentTarget);
|
||||
var toolType = button.data('type');
|
||||
|
||||
convertNonTarget(measurementData, toolType);
|
||||
|
||||
closeHandler(dialog);
|
||||
},
|
||||
'keydown #lesionLocationDialog, keydown #lesionLocationRelabelDialog': function(e) {
|
||||
var dialog = Template.nonTargetLesionDialog.dialog;
|
||||
|
||||
// If Esc or Enter are pressed, close the dialog
|
||||
if (e.which === keys.ESC || e.which === keys.ENTER) {
|
||||
closeHandler(dialog);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var conversionOptions = [{
|
||||
id: 'bidirectional',
|
||||
name: 'Measurable Target'
|
||||
}, {
|
||||
id: 'crTool',
|
||||
name: 'Complete Response (CR)'
|
||||
}, {
|
||||
id: 'unTool',
|
||||
name: 'Not Evaluable (NE)'
|
||||
}, {
|
||||
id: 'exTool',
|
||||
name: 'Excluded (EX)'
|
||||
}];
|
||||
|
||||
Template.nonTargetLesionDialog.helpers({
|
||||
lesionLocations: function() {
|
||||
return LesionLocations.find();
|
||||
},
|
||||
locationResponses: function() {
|
||||
return LocationResponses.find();
|
||||
},
|
||||
conversionOptions: function() {
|
||||
return conversionOptions;
|
||||
}
|
||||
});
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
#nonTargetLesionLocationDialog, #nonTargetLesionRelabelDialog
|
||||
position: absolute
|
||||
top: 0
|
||||
bottom: 0
|
||||
left: 0
|
||||
right: 0
|
||||
z-index: 100
|
||||
width: 300px
|
||||
height: 230px
|
||||
border-radius: 5px
|
||||
padding: 10px 20px 10px 20px
|
||||
background-color: white
|
||||
outline: none
|
||||
|
||||
#selectNonTargetLesionLocation, #selectNonTargetLesionLocationResponse
|
||||
width: 100%
|
||||
|
||||
.dialogContent, .lesionLocation, .locationResponse
|
||||
margin-bottom: 20px
|
||||
|
||||
.locationOK
|
||||
text-align: center
|
||||
|
||||
/* dialogMobile is added to #nonTargetLesionLocationDialog when touchDevices is detected */
|
||||
.dialogMobile
|
||||
margin: auto
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
<template name="nonTargetResponseDialog">
|
||||
<div id="nonTargetResponseDialog" class="dialog-animated" tabindex="0">
|
||||
<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>
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
function closeHandler(dialog) {
|
||||
// Hide the lesion dialog
|
||||
$(dialog).css('display', 'none');
|
||||
|
||||
// Remove the backdrop
|
||||
$('.removableBackdrop').remove();
|
||||
|
||||
// Restore the focus to the active viewport
|
||||
setFocusToActiveViewport();
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
var pageHeight = $(window).height();
|
||||
dialogProperty.top = Math.max(dialogProperty.top, 0);
|
||||
dialogProperty.top = Math.min(dialogProperty.top, pageHeight - dialog.outerHeight());
|
||||
|
||||
var pageWidth = $(window).width();
|
||||
dialogProperty.left = Math.max(dialogProperty.left, 0);
|
||||
dialogProperty.left = Math.min(dialogProperty.left, pageWidth - dialog.outerWidth());
|
||||
}
|
||||
|
||||
dialog.css(dialogProperty);
|
||||
dialog.focus();
|
||||
|
||||
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;
|
||||
|
||||
// Response is set from location response list
|
||||
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);
|
||||
},
|
||||
'keydown #nonTargetResponseDialog': function(e) {
|
||||
var dialog = Template.nonTargetResponseDialog.dialog;
|
||||
|
||||
// If Esc or Enter are pressed, close the dialog
|
||||
if (e.which === keys.ESC || e.which === keys.ENTER) {
|
||||
closeHandler(dialog);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Template.nonTargetResponseDialog.helpers({
|
||||
locationResponses: function() {
|
||||
return LocationResponses.find();
|
||||
}
|
||||
});
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
#nonTargetResponseDialog
|
||||
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)
|
||||
outline: none
|
||||
|
||||
#selectNonTargetLesionLocationResponse
|
||||
width: 100%
|
||||
|
||||
.dialogContent, .locationResponse
|
||||
margin-bottom: 20px
|
||||
|
||||
.locationOK
|
||||
text-align: center
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
<template name="irRCDescription">
|
||||
<h4>irRC</h4>
|
||||
<h5>Baseline Checks</h5>
|
||||
<ul>
|
||||
<li>Target lesions must be >= 10 X 10 mm AND >= double the acquisition slice thickness by CT and MR</li>
|
||||
<li>Up to a max of 5 target lesions per organ</li>
|
||||
<li>Up to a max of 10 target lesions total</li>
|
||||
<li>Non-targets can only be assessed as 'present'</li>
|
||||
<li>Target lesions must have measurements (cannot be assessed as CR, UN/NE, EX)</li>
|
||||
</ul>
|
||||
<h5>New Lesion Checks for Follow-ups</h5>
|
||||
<ul>
|
||||
<li>New target lesions must be >= 5 X 5 mm AND >= double the acquisition slice thickness by CT and MR</li>
|
||||
<li>Up to a max of 5 target lesions per organ</li>
|
||||
<li>Up to a max of 10 target lesions total</li>
|
||||
</ul>
|
||||
<!--Time Point Measurement Total = SPD target lesions + SPD new lesions (SPD = sum of product of long axis and short axis diameters)-->
|
||||
</template>
|
||||
@@ -0,0 +1,48 @@
|
||||
<template name="optionsModal">
|
||||
<div class="modal fade" id="optionsModal" tabindex="-1" role="dialog" aria-labelledby="optionsModalLabel">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title" id="optionsModalLabel">Clinical Trial Options</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h3>Select one or more Trial Criteria types:</h3>
|
||||
{{ #each trialCriteriaTypes}}
|
||||
<label for="{{id}}Criteria" class="trialCriteriaLabel">
|
||||
<!-- TODO: Change to checkbox for multiple criteria !-->
|
||||
<input type="radio" name="trialCriteria" id="{{id}}Criteria" value='{{id}}' class="trialCriteria" checked={{selected}}>
|
||||
{{name}}
|
||||
</label>
|
||||
{{ /each }}
|
||||
<div>
|
||||
<h3>Selected Trial Criteria:</h3>
|
||||
{{ #each trialCriteriaTypes}}
|
||||
{{ #if selected }}
|
||||
<div class="trialCriteriaPanel panel fade in" id="{{id}}Description">
|
||||
{{> Template.dynamic template=descriptionTemplate }}
|
||||
</div>
|
||||
{{ /if }}
|
||||
{{ /each }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h4>Additional Options</h4>
|
||||
<a type="button" class="btn btn-danger clearAllStudyTimepointAssociations">
|
||||
<i class="fa fa-trash"></i> Clear All Study/Timepoint Associations
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,61 @@
|
||||
TrialCriteriaTypes = new Meteor.Collection(null);
|
||||
|
||||
TrialCriteriaTypes.insert({
|
||||
id: 'RECIST',
|
||||
name: 'RECIST 1.1',
|
||||
descriptionTemplate: 'recistDescription',
|
||||
selected: true
|
||||
});
|
||||
|
||||
TrialCriteriaTypes.insert({
|
||||
id: 'irRC',
|
||||
name: 'irRC',
|
||||
descriptionTemplate: 'irRCDescription',
|
||||
selected: false
|
||||
});
|
||||
|
||||
Template.optionsModal.helpers({
|
||||
trialCriteriaTypes: function() {
|
||||
return TrialCriteriaTypes.find();
|
||||
}
|
||||
});
|
||||
|
||||
Template.optionsModal.events({
|
||||
/**
|
||||
* When the trial criteria radio buttons are changed, change the
|
||||
* trial assessment criteria for the Lesion Tracker
|
||||
*
|
||||
* @param e The 'change' event on the selected radio button
|
||||
*/
|
||||
'change input.trialCriteria': function(e) {
|
||||
var isChecked = e.currentTarget.checked;
|
||||
|
||||
// Set "Selected" to false for the entire collection
|
||||
// TODO: Remove this when we allow multiple criteria
|
||||
TrialCriteriaTypes.update({}, {
|
||||
$set: {
|
||||
selected: false
|
||||
}
|
||||
}, {
|
||||
multi: true
|
||||
});
|
||||
|
||||
// Set the current Criteria in the collection to selected
|
||||
TrialCriteriaTypes.update(this._id, {
|
||||
$set: {
|
||||
selected: isChecked
|
||||
}
|
||||
});
|
||||
},
|
||||
/**
|
||||
* When the Clear Study/Timepoint Associations button is clicked, we
|
||||
* send a call to the server to erase all entries in the Timepoints Collection.
|
||||
*/
|
||||
'click a.clearAllStudyTimepointAssociations': function() {
|
||||
Meteor.call('clearAllTimepoints', function(error) {
|
||||
if (error) {
|
||||
log.warn(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,2 @@
|
||||
.trialCriteriaLabel
|
||||
margin: 0 5px
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
<template name="recistDescription">
|
||||
<h4>RECIST 1.1</h4>
|
||||
<h5>Baseline Checks</h5>
|
||||
<ul>
|
||||
<li>Extranodal lesions must be >= 10 mm long axis AND >= double the acquisition slice thickness by CT and MR</li>
|
||||
<li>Extranodal lesions must be >= 20 mm on chest x-ray (although x-rays rarely used for clinical trial assessment)</li>
|
||||
<li>Nodal lesions must be >= 15 mm short axis AND >= double the acquisition slice thickness by CT and MR</li>
|
||||
<li>Up to a max of 2 target lesions per organ</li>
|
||||
<li>Up to a max of 5 target lesions total</li>
|
||||
<li>Non-targets can only be assessed as 'present'</li>
|
||||
<li>Target lesions must have measurements (cannot be assessed as CR, UN/NE, EX)</li>
|
||||
</ul>
|
||||
<!-- Time Point Measurement Total = Sum of long axis measurements for extranodal target lesion + short axis measurements for nodal lesions</li>-->
|
||||
</template>
|
||||
@@ -0,0 +1,47 @@
|
||||
Meteor.startup(function() {
|
||||
toolManager.addTool('bidirectional', {
|
||||
mouse: cornerstoneTools.bidirectional,
|
||||
touch: cornerstoneTools.bidirectionalTouch
|
||||
});
|
||||
|
||||
toolManager.addTool('nonTarget', {
|
||||
mouse: cornerstoneTools.nonTarget,
|
||||
touch: cornerstoneTools.nonTargetTouch
|
||||
});
|
||||
|
||||
toolManager.addTool('scaleOverlayTool', {
|
||||
mouse: cornerstoneTools.scaleOverlayTool,
|
||||
touch: cornerstoneTools.scaleOverlayTool
|
||||
});
|
||||
|
||||
toolManager.addTool('deleteLesionKeyboardTool', {
|
||||
mouse: cornerstoneTools.deleteLesionKeyboardTool,
|
||||
touch: cornerstoneTools.deleteLesionKeyboardTool
|
||||
});
|
||||
|
||||
toolManager.addTool('crTool', {
|
||||
mouse: cornerstoneTools.crTool,
|
||||
touch: cornerstoneTools.crToolTouch
|
||||
});
|
||||
|
||||
toolManager.addTool('unTool', {
|
||||
mouse: cornerstoneTools.unTool,
|
||||
touch: cornerstoneTools.unToolTouch
|
||||
});
|
||||
|
||||
toolManager.addTool('exTool', {
|
||||
mouse: cornerstoneTools.exTool,
|
||||
touch: cornerstoneTools.exToolTouch
|
||||
});
|
||||
|
||||
let states = toolManager.getToolDefaultStates();
|
||||
states.deactivate.push('bidirectional');
|
||||
states.deactivate.push('nonTarget');
|
||||
states.deactivate.push('length');
|
||||
states.deactivate.push('crTool');
|
||||
states.deactivate.push('unTool');
|
||||
states.deactivate.push('exTool');
|
||||
|
||||
states.activate.push('deleteLesionKeyboardTool');
|
||||
toolManager.setToolDefaultStates(states);
|
||||
});
|
||||
Reference in new issue
Block a user