Measurements and Timepoint interaction in Lesion Table and tools
This commit is contained in:
parent
5363880e40
commit
b49c36493e
@ -37,3 +37,4 @@ reactive-var
|
|||||||
reactive-dict
|
reactive-dict
|
||||||
lesiontracker
|
lesiontracker
|
||||||
practicalmeteor:loglevel
|
practicalmeteor:loglevel
|
||||||
|
momentjs:moment
|
||||||
|
|||||||
@ -62,6 +62,7 @@ minifiers@1.1.7
|
|||||||
minimongo@1.0.10
|
minimongo@1.0.10
|
||||||
mobile-experience@1.0.1
|
mobile-experience@1.0.1
|
||||||
mobile-status-bar@1.0.6
|
mobile-status-bar@1.0.6
|
||||||
|
momentjs:moment@2.10.6
|
||||||
mongo@1.1.3
|
mongo@1.1.3
|
||||||
mongo-id@1.0.1
|
mongo-id@1.0.1
|
||||||
npm-bcrypt@0.7.8_2
|
npm-bcrypt@0.7.8_2
|
||||||
|
|||||||
@ -11,13 +11,6 @@ Template.viewerMain.helpers({
|
|||||||
iconClasses: 'fa fa-sun-o'
|
iconClasses: 'fa fa-sun-o'
|
||||||
});
|
});
|
||||||
|
|
||||||
buttonData.push({
|
|
||||||
id: 'invert',
|
|
||||||
title: 'Invert',
|
|
||||||
classes: 'imageViewerCommand',
|
|
||||||
iconClasses: 'fa fa-adjust'
|
|
||||||
});
|
|
||||||
|
|
||||||
buttonData.push({
|
buttonData.push({
|
||||||
id: 'zoom',
|
id: 'zoom',
|
||||||
title: 'Zoom',
|
title: 'Zoom',
|
||||||
@ -46,20 +39,6 @@ Template.viewerMain.helpers({
|
|||||||
iconClasses: 'fa fa-arrows-v'
|
iconClasses: 'fa fa-arrows-v'
|
||||||
});
|
});
|
||||||
|
|
||||||
buttonData.push({
|
|
||||||
id: 'angle',
|
|
||||||
title: 'Angle Measurement',
|
|
||||||
classes: 'imageViewerTool',
|
|
||||||
iconClasses: 'fa fa-angle-left'
|
|
||||||
});
|
|
||||||
|
|
||||||
buttonData.push({
|
|
||||||
id: 'dragProbe',
|
|
||||||
title: 'Pixel Probe',
|
|
||||||
classes: 'imageViewerTool',
|
|
||||||
iconClasses: 'fa fa-dot-circle-o'
|
|
||||||
});
|
|
||||||
|
|
||||||
buttonData.push({
|
buttonData.push({
|
||||||
id: 'lesion',
|
id: 'lesion',
|
||||||
title: 'Lesion Tool',
|
title: 'Lesion Tool',
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
var lineIndex = 0; //This holds drawn line index
|
|
||||||
var activeLesionMeasurementData;
|
var activeLesionMeasurementData;
|
||||||
var timepointID;
|
var timepointID;
|
||||||
var cornerstoneTools = (function($, cornerstone, cornerstoneMath, cornerstoneTools) {
|
var cornerstoneTools = (function($, cornerstone, cornerstoneMath, cornerstoneTools) {
|
||||||
@ -12,11 +11,10 @@ var cornerstoneTools = (function ($, cornerstone, cornerstoneMath, cornerstoneTo
|
|||||||
var toolType = "lesion";
|
var toolType = "lesion";
|
||||||
|
|
||||||
///////// BEGIN ACTIVE TOOL ///////
|
///////// BEGIN ACTIVE TOOL ///////
|
||||||
function createNewMeasurement(mouseEventData)
|
function createNewMeasurement(mouseEventData) {
|
||||||
{
|
|
||||||
var element = mouseEventData.element;
|
var element = mouseEventData.element;
|
||||||
timepointID = getActiveTimepointID(element);
|
timepointID = $(element).data('timepointID');
|
||||||
var lesionNumber = measurementManagerDAL.getLesionNumber(timepointID);
|
var lesionNumber = measurementManagerDAL.getNewLesionNumber(timepointID);
|
||||||
var lesionCounter = "";
|
var lesionCounter = "";
|
||||||
|
|
||||||
// Subscribe CornerstoneMouseup event, when mouse is up, call lesionDialog
|
// Subscribe CornerstoneMouseup event, when mouse is up, call lesionDialog
|
||||||
@ -31,7 +29,6 @@ var cornerstoneTools = (function ($, cornerstone, cornerstoneMath, cornerstoneTo
|
|||||||
|
|
||||||
// Show LesionDialog
|
// Show LesionDialog
|
||||||
$(document).trigger("ShowLesionDialog", [e, activeLesionMeasurementData]);
|
$(document).trigger("ShowLesionDialog", [e, activeLesionMeasurementData]);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Set Lesion Name
|
// Set Lesion Name
|
||||||
@ -61,9 +58,8 @@ var cornerstoneTools = (function ($, cornerstone, cornerstoneMath, cornerstoneTo
|
|||||||
active: true
|
active: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
index: lineIndex,
|
|
||||||
imageId: mouseEventData.image.imageId,
|
imageId: mouseEventData.image.imageId,
|
||||||
measurementText: "",
|
measurementText: 0,
|
||||||
linkedTextCoords: {
|
linkedTextCoords: {
|
||||||
start: {
|
start: {
|
||||||
x: mouseEventData.currentPoints.image.x,
|
x: mouseEventData.currentPoints.image.x,
|
||||||
@ -81,19 +77,17 @@ var cornerstoneTools = (function ($, cornerstone, cornerstoneMath, cornerstoneTo
|
|||||||
},
|
},
|
||||||
lesionName: "Target " + lesionNumber,
|
lesionName: "Target " + lesionNumber,
|
||||||
isDeleted: false,
|
isDeleted: false,
|
||||||
lineNumber:"", //Indicates line number on image
|
|
||||||
lesionNumber: lesionNumber,
|
lesionNumber: lesionNumber,
|
||||||
uid: uuid.v4()
|
uid: uuid.v4()
|
||||||
};
|
};
|
||||||
lineIndex++;
|
|
||||||
return measurementData;
|
return measurementData;
|
||||||
}
|
}
|
||||||
///////// END ACTIVE TOOL ///////
|
///////// END ACTIVE TOOL ///////
|
||||||
|
|
||||||
function pointNearTool(element, data, coords)
|
function pointNearTool(element, data, coords) {
|
||||||
{
|
|
||||||
var lineSegment = {
|
var lineSegment = {
|
||||||
start: cornerstone.pixelToCanvas(element, data.handles.start), end: cornerstone.pixelToCanvas(element, data.handles.end)
|
start: cornerstone.pixelToCanvas(element, data.handles.start),
|
||||||
|
end: cornerstone.pixelToCanvas(element, data.handles.end)
|
||||||
};
|
};
|
||||||
var distanceToPoint = cornerstoneMath.lineSegment.distanceToPoint(lineSegment, coords);
|
var distanceToPoint = cornerstoneMath.lineSegment.distanceToPoint(lineSegment, coords);
|
||||||
return (distanceToPoint < 25);
|
return (distanceToPoint < 25);
|
||||||
@ -101,7 +95,8 @@ var cornerstoneTools = (function ($, cornerstone, cornerstoneMath, cornerstoneTo
|
|||||||
|
|
||||||
function pointNearToolForText(element, data, coords) {
|
function pointNearToolForText(element, data, coords) {
|
||||||
var lineSegment = {
|
var lineSegment = {
|
||||||
start: cornerstone.pixelToCanvas(element, data.linkedTextCoords.start), end: cornerstone.pixelToCanvas(element, data.linkedTextCoords.end)
|
start: cornerstone.pixelToCanvas(element, data.linkedTextCoords.start),
|
||||||
|
end: cornerstone.pixelToCanvas(element, data.linkedTextCoords.end)
|
||||||
};
|
};
|
||||||
|
|
||||||
var distanceToPoint = cornerstoneMath.lineSegment.distanceToPoint(lineSegment, coords);
|
var distanceToPoint = cornerstoneMath.lineSegment.distanceToPoint(lineSegment, coords);
|
||||||
@ -125,7 +120,7 @@ var cornerstoneTools = (function ($, cornerstone, cornerstoneMath, cornerstoneTo
|
|||||||
|
|
||||||
// if we have no toolData for this element, return immediately as there is nothing to do
|
// if we have no toolData for this element, return immediately as there is nothing to do
|
||||||
var toolData = cornerstoneTools.getToolState(e.currentTarget, toolType);
|
var toolData = cornerstoneTools.getToolState(e.currentTarget, toolType);
|
||||||
if (toolData === undefined) {
|
if (!toolData) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,7 +157,7 @@ var cornerstoneTools = (function ($, cornerstone, cornerstoneMath, cornerstoneTo
|
|||||||
var color;
|
var color;
|
||||||
var lineWidth = cornerstoneTools.toolStyle.getToolWidth();
|
var lineWidth = cornerstoneTools.toolStyle.getToolWidth();
|
||||||
var font = cornerstoneTools.textStyle.getFont();
|
var font = cornerstoneTools.textStyle.getFont();
|
||||||
var config = cornerstoneTools.length.getConfiguration();
|
var config = cornerstoneTools.lesion.getConfiguration();
|
||||||
|
|
||||||
// configurable shadow from CornerstoneTools
|
// configurable shadow from CornerstoneTools
|
||||||
if (config && config.shadow) {
|
if (config && config.shadow) {
|
||||||
@ -214,7 +209,8 @@ var cornerstoneTools = (function ($, cornerstone, cornerstoneMath, cornerstoneTo
|
|||||||
context.strokeStyle = color;
|
context.strokeStyle = color;
|
||||||
context.lineWidth = 1 / eventData.viewport.scale;
|
context.lineWidth = 1 / eventData.viewport.scale;
|
||||||
var mid = {
|
var mid = {
|
||||||
x:(handleStartCanvas.x + handleEndCanvas.x) / 2, y:(handleStartCanvas.y + handleEndCanvas.y) / 2
|
x: (handleStartCanvas.x + handleEndCanvas.x) / 2,
|
||||||
|
y: (handleStartCanvas.y + handleEndCanvas.y) / 2
|
||||||
};
|
};
|
||||||
|
|
||||||
context.moveTo(mid.x, mid.y);
|
context.moveTo(mid.x, mid.y);
|
||||||
@ -235,14 +231,15 @@ var cornerstoneTools = (function ($, cornerstone, cornerstoneMath, cornerstoneTo
|
|||||||
|
|
||||||
var text = '' + length.toFixed(2) + suffix;
|
var text = '' + length.toFixed(2) + suffix;
|
||||||
var textCoords = {
|
var textCoords = {
|
||||||
x: linkedTextStartCanvas.x, y: linkedTextStartCanvas.y
|
x: linkedTextStartCanvas.x,
|
||||||
|
y: linkedTextStartCanvas.y
|
||||||
};
|
};
|
||||||
|
|
||||||
cornerstoneTools.drawTextBox(context, lesion.lesionName, textCoords.x, textCoords.y, color);
|
cornerstoneTools.drawTextBox(context, lesion.lesionName, textCoords.x, textCoords.y, color);
|
||||||
cornerstoneTools.drawTextBox(context, text, textCoords.x, textCoords.y + 20, color);
|
cornerstoneTools.drawTextBox(context, text, textCoords.x, textCoords.y + 20, color);
|
||||||
|
|
||||||
// Set measurement text to show lesion table
|
// Set measurement text to show lesion table
|
||||||
lesion.measurementText = length.toFixed(2);
|
lesion.measurementText = length.toFixed(1);
|
||||||
|
|
||||||
// Lesion Measurement is changed
|
// Lesion Measurement is changed
|
||||||
$(eventData.enabledElement.element).trigger("LesionTextChanged", lesion);
|
$(eventData.enabledElement.element).trigger("LesionTextChanged", lesion);
|
||||||
@ -371,4 +368,5 @@ var cornerstoneTools = (function ($, cornerstone, cornerstoneMath, cornerstoneTo
|
|||||||
toolType: toolType
|
toolType: toolType
|
||||||
});
|
});
|
||||||
return cornerstoneTools;
|
return cornerstoneTools;
|
||||||
|
|
||||||
}($, cornerstone, cornerstoneMath, cornerstoneTools));
|
}($, cornerstone, cornerstoneMath, cornerstoneTools));
|
||||||
@ -1,6 +1,5 @@
|
|||||||
var measurementManagerDAL = (function() {
|
var measurementManagerDAL = (function() {
|
||||||
var trialPatientLocations = [];
|
var trialPatientLocations = [];
|
||||||
var timepoints = [];
|
|
||||||
|
|
||||||
// Returns trialPatientLocations array
|
// Returns trialPatientLocations array
|
||||||
function getPatientLocations() {
|
function getPatientLocations() {
|
||||||
@ -14,108 +13,94 @@ var measurementManagerDAL = (function () {
|
|||||||
return locationObject.location.location;
|
return locationObject.location.location;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTimepoints() {
|
|
||||||
return timepoints;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Adds new location to trialPatientLocations array
|
// Adds new location to trialPatientLocations array
|
||||||
function addPatientLocation(location) {
|
function addPatientLocation(location) {
|
||||||
var contentId = getContentId();
|
|
||||||
var locationUID = uuid.v4();
|
var locationUID = uuid.v4();
|
||||||
var locationObject = {contentId: contentId, uid: locationUID, location: location};
|
var locationObject = {
|
||||||
|
uid: locationUID,
|
||||||
|
location: location
|
||||||
|
};
|
||||||
trialPatientLocations.push(locationObject);
|
trialPatientLocations.push(locationObject);
|
||||||
|
|
||||||
return locationUID;
|
return locationUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getContentId () {
|
|
||||||
return Session.get("activeContentId");
|
|
||||||
}
|
|
||||||
|
|
||||||
function getTimepointsOfTab (){
|
|
||||||
var contentId = getContentId();
|
|
||||||
var tabData = TabsTimepoints.find({contentId: contentId}).fetch();
|
|
||||||
return tabData[0].timepoints;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add timepoint data to Measurements collection
|
// Add timepoint data to Measurements collection
|
||||||
function addTimepointData(lesionData) {
|
function addTimepointData(lesionData) {
|
||||||
|
var timepoints = Timepoints.find().fetch();
|
||||||
|
var timepointsObject = {};
|
||||||
|
|
||||||
var contentId = getContentId();
|
for (var i = 0; i < timepoints.length; i++) {
|
||||||
var timepointsOfTab = getTimepointsOfTab();
|
var timepointId = timepoints[i].timepointID;
|
||||||
var timepointsArr = [];
|
|
||||||
for(var i=0; i< timepointsOfTab.length; i++) {
|
|
||||||
var timepointId = timepointsOfTab[i].timepointID;
|
|
||||||
var lesionTimepointId = lesionData.timepointID;
|
var lesionTimepointId = lesionData.timepointID;
|
||||||
|
|
||||||
|
var timepointObject;
|
||||||
if (timepointId === lesionTimepointId) {
|
if (timepointId === lesionTimepointId) {
|
||||||
// Add real mesurement
|
// Add real mesurement
|
||||||
var timepointObject = {};
|
timepointObject = {
|
||||||
timepointObject[timepointId] = {longestDiameter: lesionData.measurementText, imageId: lesionData.imageId};
|
longestDiameter: lesionData.measurementText,
|
||||||
timepointsArr.push(timepointObject);
|
imageId: lesionData.imageId
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
// Add null measurement
|
// Add null measurement
|
||||||
var timepointObject = {};
|
timepointObject = {
|
||||||
timepointObject[timepointId] = {longestDiameter: "", imageId: ""};
|
longestDiameter: "",
|
||||||
timepointsArr.push(timepointObject);
|
imageId: ""
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
timepointsObject[timepointId] = timepointObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
var lesionDataCollectionObject = {
|
var lesionDataObject = {
|
||||||
lesionNumber: lesionData.lesionNumber,
|
lesionNumber: lesionData.lesionNumber,
|
||||||
isTarget: true,
|
isTarget: true,
|
||||||
locationUID: lesionData.locationUID,
|
locationUID: lesionData.locationUID,
|
||||||
location: getLocationName(lesionData.locationUID),
|
location: getLocationName(lesionData.locationUID),
|
||||||
timepoints: timepointsArr
|
timepoints: timepointsObject
|
||||||
};
|
};
|
||||||
|
Measurements.insert(lesionDataObject);
|
||||||
Measurements.insert({contentId: contentId, lesionData: lesionDataCollectionObject});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update timepoint data in Measurements collection
|
// Update timepoint data in Measurements collection
|
||||||
function updateTimepointData(lesionData) {
|
function updateTimepointData(lesionData) {
|
||||||
var contentId = getContentId();
|
// Find the specific lesion to be updated
|
||||||
|
var measurement = Measurements.find({
|
||||||
|
lesionNumber: lesionData.lesionNumber
|
||||||
|
}).fetch()[0];
|
||||||
|
|
||||||
|
// If no such lesion exists, stop here
|
||||||
|
if (!measurement) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update this specific lesion at the given timepoint
|
||||||
var timepointID = lesionData.timepointID;
|
var timepointID = lesionData.timepointID;
|
||||||
var tabMeasurements = Measurements.find({contentId: contentId, "lesionData.lesionNumber": lesionData.lesionNumber}).fetch();
|
|
||||||
var tabMeasurementsData = tabMeasurements[0];
|
|
||||||
if (tabMeasurements != undefined && tabMeasurements.length > 0) {
|
|
||||||
|
|
||||||
// Update timepoint
|
// Update timepoints from lesion data
|
||||||
var timepointArr = tabMeasurementsData.lesionData.timepoints;
|
var timepoints = measurement.timepoints;
|
||||||
for(var i=0; i< timepointArr.length; i++) {
|
timepoints[timepointID].longestDiameter = lesionData.measurementText;
|
||||||
var timepoint = timepointArr[i];
|
timepoints[timepointID].imageId = lesionData.imageId;
|
||||||
if(timepoint[timepointID] != undefined) {
|
|
||||||
timepoint[timepointID].longestDiameter = lesionData.measurementText;
|
|
||||||
timepoint[timepointID].imageId = lesionData.imageId;
|
|
||||||
|
|
||||||
}
|
Measurements.update({
|
||||||
}
|
lesionNumber: lesionData.lesionNumber
|
||||||
Measurements.update(
|
}, {
|
||||||
{ contentId: contentId, "lesionData.lesionNumber": lesionData.lesionNumber},
|
|
||||||
{
|
|
||||||
$set: {
|
$set: {
|
||||||
"lesionData.timepoints": timepointArr
|
timepoints: timepoints
|
||||||
}
|
|
||||||
}, {multi: true}
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check timepointData is found in Measurements collection
|
// Check timepointData is found in Measurements collection
|
||||||
function timepointDataIsFound(lesionNumber) {
|
function timepointDataIsFound(lesionNumber) {
|
||||||
var contentId = getContentId();
|
var timepointData = Measurements.findOne({
|
||||||
var timepointData = Measurements.findOne({contentId: contentId, "lesionData.lesionNumber": lesionNumber});
|
lesionNumber: lesionNumber
|
||||||
if (timepointData != undefined) {
|
});
|
||||||
|
if (timepointData) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adds new timepoint item to tiemepoints array
|
// Adds new timepoint item to tiemepoints array
|
||||||
@ -127,77 +112,54 @@ var measurementManagerDAL = (function () {
|
|||||||
// Insert data
|
// Insert data
|
||||||
addTimepointData(lesionData);
|
addTimepointData(lesionData);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: This code block will be removed
|
|
||||||
// Populate timepoints array
|
|
||||||
var roi = {
|
|
||||||
uid: lesionData.uid,
|
|
||||||
number: lesionData.lesionNumber,
|
|
||||||
measurement: lesionData.measurementText,
|
|
||||||
locationUID: lesionData.locationUID
|
|
||||||
};
|
|
||||||
if (timepoints.length) {
|
|
||||||
timepoints.forEach(function(timepoint) {
|
|
||||||
if(timepoint.timepointID === timepointID) {
|
|
||||||
timepoint.rois.push(roi);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
timepoints.push({timepointID: timepointID, rois: [roi]});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns new lesion number according to timepointID
|
// Returns new lesion number according to timepointID
|
||||||
function getNewLesionNumber(timepointID) {
|
function getNewLesionNumber(timepointID) {
|
||||||
var contentId = getContentId();
|
// Get all current lesion measurements
|
||||||
var lesionNumberCounter = 0;
|
var measurements = Measurements.find().fetch();
|
||||||
var timepointsData = Measurements.find({contentId: contentId}).fetch();
|
|
||||||
if(timepointsData.length > 0) {
|
|
||||||
for(var i=0; i< timepointsData.length; i++) {
|
|
||||||
var timepointData = timepointsData[i];
|
|
||||||
var timepoints = timepointData.lesionData.timepoints;
|
|
||||||
for(var j=0; j< timepoints.length; j++) {
|
|
||||||
var timepoint = timepoints[j];
|
|
||||||
var key = Object.keys(timepoint);
|
|
||||||
if(key == timepointID) {
|
|
||||||
if (timepoint[key].longestDiameter === "") {
|
|
||||||
return timepointData.lesionData.lesionNumber;
|
|
||||||
|
|
||||||
|
// If no measurements exist yet, start at 1
|
||||||
|
if (!measurements.length) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If measurements exist, find the last lesion number
|
||||||
|
// from the given timepoint
|
||||||
|
var lesionNumberCounter = 0;
|
||||||
|
for (var i = 0; i < measurements.length; i++) {
|
||||||
|
var measurement = measurements[i];
|
||||||
|
var timepoints = measurement.timepoints;
|
||||||
|
|
||||||
|
if (timepoints[timepointID].longestDiameter === '') {
|
||||||
|
return measurement.lesionNumber;
|
||||||
} else {
|
} else {
|
||||||
lesionNumberCounter = lesionNumberCounter + 1;
|
lesionNumberCounter = lesionNumberCounter + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
console.log(lesionNumberCounter + 1);
|
console.log(lesionNumberCounter + 1);
|
||||||
|
|
||||||
return lesionNumberCounter + 1;
|
return lesionNumberCounter + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If lesion number is added for any timepoint, returns lesion locationUID
|
// If lesion number is added for any timepoint, returns lesion locationUID
|
||||||
function isLesionNumberAdded(lesionNumber) {
|
function isLesionNumberAdded(lesionNumber) {
|
||||||
if (timepointDataIsFound(lesionNumber)){
|
if (!timepointDataIsFound(lesionNumber)) {
|
||||||
var contentId = getContentId();
|
return;
|
||||||
var timepointData = Measurements.find({contentId: contentId, "lesionData.lesionNumber": lesionNumber}).fetch();
|
|
||||||
return timepointData[0].lesionData.locationUID;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return null
|
|
||||||
|
|
||||||
|
var measurement = Measurements.find({
|
||||||
|
lesionNumber: lesionNumber
|
||||||
|
}).fetch()[0];
|
||||||
|
|
||||||
|
return measurement.locationUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
addNewLocation: addPatientLocation,
|
addNewLocation: addPatientLocation,
|
||||||
getLocations: getPatientLocations,
|
getLocations: getPatientLocations,
|
||||||
addLesionData: addLesionData,
|
addLesionData: addLesionData,
|
||||||
getLesionNumber: getNewLesionNumber,
|
getNewLesionNumber: getNewLesionNumber,
|
||||||
isLesionNumberAdded: isLesionNumberAdded,
|
isLesionNumberAdded: isLesionNumberAdded,
|
||||||
getTimepoints: getTimepoints,
|
|
||||||
updateTimepointData: updateTimepointData
|
updateTimepointData: updateTimepointData
|
||||||
|
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
@ -1,15 +1,15 @@
|
|||||||
Template.lesionDialog.onRendered(function () {
|
Template.lesionDialog.onRendered(function () {
|
||||||
// Show Lesion Dialog
|
// This event determines whether or not to show the lesion dialog
|
||||||
$(document).on("ShowLesionDialog", function (e, eventData, activeLesionMeasurementData) {
|
// If there already exists a lesion with this specific lesion number,
|
||||||
|
// related to the chosen location.
|
||||||
|
|
||||||
var locationUID = measurementManagerDAL.isLesionNumberAdded(activeLesionMeasurementData.lesionNumber);
|
$(document).on("ShowLesionDialog", function (e, eventData, lesionData) {
|
||||||
|
var locationUID = measurementManagerDAL.isLesionNumberAdded(lesionData.lesionNumber);
|
||||||
|
|
||||||
if(locationUID != null) {
|
if (locationUID) {
|
||||||
|
lesionData.locationUID = locationUID;
|
||||||
activeLesionMeasurementData.locationUID = locationUID;
|
measurementManagerDAL.updateTimepointData(lesionData);
|
||||||
measurementManagerDAL.updateTimepointData(activeLesionMeasurementData);
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Show Dialog
|
// Show Dialog
|
||||||
var dialogPointsOnPage = eventData.currentPoints.page;
|
var dialogPointsOnPage = eventData.currentPoints.page;
|
||||||
$("#modal-dialog-container").css({
|
$("#modal-dialog-container").css({
|
||||||
@ -19,7 +19,6 @@ Template.lesionDialog.onRendered(function () {
|
|||||||
|
|
||||||
$("#lesionDialog").modal("show");
|
$("#lesionDialog").modal("show");
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -1,13 +1,27 @@
|
|||||||
var lastAddedLesionData;
|
var lastAddedLesionData;
|
||||||
|
|
||||||
//fill selectLesionLocation element
|
//fill selectLesionLocation element
|
||||||
var lesionLocationsArray = [
|
var lesionLocationsArray = [{
|
||||||
{location:"Brain Brainstem",hasDescription:false, description:""},
|
location: "Brain Brainstem",
|
||||||
{location:"Brain Cerebellum Left",hasDescription:false, description:""},
|
hasDescription: false,
|
||||||
{location:"Brain Cerebrum Left",hasDescription:false, description:""},
|
description: ""
|
||||||
{location:"Brain Cerebrum Right",hasDescription:false, description:""},
|
}, {
|
||||||
{location:"Brain Multiple Sites",hasDescription:false, description:""}
|
location: "Brain Cerebellum Left",
|
||||||
];
|
hasDescription: false,
|
||||||
|
description: ""
|
||||||
|
}, {
|
||||||
|
location: "Brain Cerebrum Left",
|
||||||
|
hasDescription: false,
|
||||||
|
description: ""
|
||||||
|
}, {
|
||||||
|
location: "Brain Cerebrum Right",
|
||||||
|
hasDescription: false,
|
||||||
|
description: ""
|
||||||
|
}, {
|
||||||
|
location: "Brain Multiple Sites",
|
||||||
|
hasDescription: false,
|
||||||
|
description: ""
|
||||||
|
}];
|
||||||
|
|
||||||
Template.lesionLocationDialog.onRendered(function() {
|
Template.lesionLocationDialog.onRendered(function() {
|
||||||
console.log(this.data);
|
console.log(this.data);
|
||||||
@ -39,13 +53,14 @@ Template.lesionLocationDialog.events({
|
|||||||
$("#lesionDialog").modal("hide");
|
$("#lesionDialog").modal("hide");
|
||||||
// TODO: Remove lastAddedLesionData from canvas
|
// TODO: Remove lastAddedLesionData from canvas
|
||||||
// TODO: Remove lastAddedLesionData from collection
|
// TODO: Remove lastAddedLesionData from collection
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
'change select#selectLesionLocation': function(e) {
|
'change select#selectLesionLocation': function(e) {
|
||||||
var el = $(e.target);
|
var el = $(e.target);
|
||||||
var selectedLocationIndex = el.val();
|
var selectedLocationIndex = el.val();
|
||||||
if(selectedLocationIndex !== "-1"){
|
if (selectedLocationIndex < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Get selected location data
|
// Get selected location data
|
||||||
var locationObj = lesionLocationsArray[selectedLocationIndex];
|
var locationObj = lesionLocationsArray[selectedLocationIndex];
|
||||||
@ -74,5 +89,4 @@ Template.lesionLocationDialog.events({
|
|||||||
// Set lesion location selected session to prevent open
|
// Set lesion location selected session to prevent open
|
||||||
Session.set("lesionLocationSelected", true);
|
Session.set("lesionLocationSelected", true);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
@ -7,21 +7,17 @@
|
|||||||
<th id="thLocation">Location</th>
|
<th id="thLocation">Location</th>
|
||||||
<th id="thTarget">Target</th>
|
<th id="thTarget">Target</th>
|
||||||
<!--Each time point name as a column-->
|
<!--Each time point name as a column-->
|
||||||
{{ #each tabTimepoints }}
|
|
||||||
{{ #each timepoints }}
|
{{ #each timepoints }}
|
||||||
{{ >lesionTableTimepointHeader }}
|
{{ >lesionTableTimepointHeader }}
|
||||||
{{ /each }}
|
{{ /each }}
|
||||||
{{ /each }}
|
|
||||||
<th id="thSpacer"> </th>
|
<th id="thSpacer"> </th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<!--Each measurement as row-->
|
||||||
{{ #each measurement }}
|
{{ #each measurement }}
|
||||||
{{ >lesionTableRow }}
|
{{ >lesionTableRow }}
|
||||||
{{ /each }}
|
{{ /each }}
|
||||||
|
|
||||||
<!--Each measurement as row-->
|
|
||||||
<!--Each time point as a column-->
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,103 +1,78 @@
|
|||||||
Measurements = new Meteor.Collection(null);
|
Measurements = new Meteor.Collection(null);
|
||||||
TabsTimepoints = new Meteor.Collection(null);
|
Timepoints = new Meteor.Collection(null);
|
||||||
|
|
||||||
Template.lesionTable.helpers({
|
|
||||||
'measurement': function() {
|
|
||||||
var contentId = this.contentId;
|
|
||||||
return Measurements.find({contentId: contentId});
|
|
||||||
},
|
|
||||||
'tabTimepoints': function() {
|
|
||||||
var contentId = this.contentId;
|
|
||||||
return TabsTimepoints.find({contentId: contentId});
|
|
||||||
},
|
|
||||||
'lesionData': function() {
|
|
||||||
var array = [];
|
|
||||||
var lesions = this.lesionData;
|
|
||||||
Object.keys(lesions).forEach(function(key) {
|
|
||||||
array.push(lesions[key]);
|
|
||||||
});
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Template.lesionTable.onRendered(function() {
|
|
||||||
|
|
||||||
var contentId = this.data.contentId;
|
|
||||||
var viewportColumns = ViewerData[contentId].viewportColumns;
|
|
||||||
var viewportRows = ViewerData[contentId].viewportRows;
|
|
||||||
|
|
||||||
var totalViewports = viewportColumns * viewportRows;
|
|
||||||
|
|
||||||
var timepointsArray = [];
|
|
||||||
for(var i=0; i< totalViewports; i++) {
|
|
||||||
var timepointID = contentId.toString() + i.toString();
|
|
||||||
var timepointName = "Baseline";
|
|
||||||
if (i > 0) {
|
|
||||||
timepointName = "Current"; //"Follow Up "+i;
|
|
||||||
}
|
|
||||||
var timepointObject = {timepointID: timepointID, timepointName: timepointName};
|
|
||||||
timepointsArray.push(timepointObject);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prevent duplicate data when onRendered is called
|
|
||||||
var tabTimepoint = TabsTimepoints.find({contentId: contentId}).fetch();
|
|
||||||
if (tabTimepoint !== undefined && tabTimepoint.length > 0) {
|
|
||||||
// Update timepoints
|
|
||||||
TabsTimepoints.update(
|
|
||||||
{ contentId: contentId},
|
|
||||||
{
|
|
||||||
$set: {
|
|
||||||
timepoints: timepointsArray
|
|
||||||
}
|
|
||||||
}, {multi: true}
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// Insert new timepoints array
|
|
||||||
TabsTimepoints.insert({contentId: contentId, timepoints: timepointsArray});
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
// Activate selected lesions when lesion table row is clicked
|
// Activate selected lesions when lesion table row is clicked
|
||||||
function updateLesions(e) {
|
function updateLesions(e) {
|
||||||
|
|
||||||
// lesionNumber of measurement = id of row
|
// lesionNumber of measurement = id of row
|
||||||
var lesionNumber = parseInt($(e.currentTarget).attr("id"));
|
var lesionNumber = parseInt($(e.currentTarget).attr("id"), 10);
|
||||||
var contentId = Session.get("activeContentId");
|
|
||||||
var measurementData = Measurements.find({contentId:contentId,"lesionData.lesionNumber":lesionNumber}).fetch();
|
|
||||||
var timepoints = measurementData[0].lesionData.timepoints;
|
|
||||||
var imageViewportElements = $("#"+contentId).find(".imageViewerViewport");
|
|
||||||
|
|
||||||
for( var i=0; i< imageViewportElements.length; i++) {
|
// Find data for specific lesion
|
||||||
var timepointObject = timepoints[i];
|
var measurementData = Measurements.find({
|
||||||
var timepointKey = Object.keys(timepointObject);
|
lesionNumber: lesionNumber
|
||||||
var imageId = timepointObject[timepointKey].imageId;
|
}).fetch()[0];
|
||||||
var longestDiameter = timepointObject[timepointKey].longestDiameter;
|
|
||||||
var imageViewportElement = imageViewportElements[i];
|
|
||||||
var eventObject = {};
|
|
||||||
|
|
||||||
if(longestDiameter != "") {
|
var timepoints = measurementData.timepoints;
|
||||||
eventObject = {
|
|
||||||
enabledElement: cornerstone.getEnabledElement(imageViewportElement),
|
$(".imageViewerViewport").each(function(index, element) {
|
||||||
lesionData: {lesionNumber: lesionNumber, imageId: imageId},
|
// Get the timepointID related to the image viewer viewport
|
||||||
|
// from the DOM itself. This will be changed later when a
|
||||||
|
// real association between viewports and timepoints is created.
|
||||||
|
var timepointID = $(element).data('timepointID');
|
||||||
|
var timepointObject = timepoints[timepointID];
|
||||||
|
|
||||||
|
// Defines event data
|
||||||
|
var eventData = {
|
||||||
|
enabledElement: cornerstone.getEnabledElement(element),
|
||||||
|
lesionData: {
|
||||||
|
lesionNumber: lesionNumber,
|
||||||
|
imageId: timepointObject.imageId
|
||||||
|
},
|
||||||
type: "active"
|
type: "active"
|
||||||
};
|
};
|
||||||
} else {
|
|
||||||
eventObject = {
|
if (timepointObject.longestDiameter === "") {
|
||||||
enabledElement: cornerstone.getEnabledElement(imageViewportElement),
|
eventData.type = "inactive";
|
||||||
lesionData: {lesionNumber: lesionNumber, imageId: imageId},
|
|
||||||
type: "inactive"
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
$(imageViewportElement).trigger("LesionToolModified", eventObject);
|
|
||||||
|
$(element).trigger("LesionToolModified", eventData);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Template.lesionTable.onRendered(function() {
|
||||||
|
// For the moment we will associate the timepoint
|
||||||
|
// with the viewport element by storing the timepointID
|
||||||
|
// inside the element's DOM data. This is temporary.
|
||||||
|
$(".imageViewerViewport").each(function(index, element) {
|
||||||
|
var timepointID = uuid.v4();
|
||||||
|
|
||||||
|
var timepointName = "Baseline";
|
||||||
|
if (index > 0) {
|
||||||
|
timepointName = "Current"; //"Follow Up "+i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// FUTURE = On load series data into viewport, create a new timepoint
|
||||||
|
// unless it already exists
|
||||||
|
Timepoints.insert({
|
||||||
|
timepointID: timepointID,
|
||||||
|
timepointName: timepointName
|
||||||
|
});
|
||||||
|
|
||||||
|
$(element).data('timepointID', timepointID);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
Template.lesionTable.helpers({
|
||||||
|
'measurement': function() {
|
||||||
|
return Measurements.find();
|
||||||
|
},
|
||||||
|
'timepoints': function() {
|
||||||
|
return Timepoints.find();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Template.lesionTable.events({
|
Template.lesionTable.events({
|
||||||
'click table#tblLesion tbody tr': function(e) {
|
'click table#tblLesion tbody tr': function(e) {
|
||||||
updateLesions(e);
|
updateLesions(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
<template name="lesionTableRow">
|
<template name="lesionTableRow">
|
||||||
<tr id="{{lesionData.lesionNumber}}" class="lesionTableRow">
|
<tr id="{{lesionNumber}}" class="lesionTableRow">
|
||||||
<td class='lesionNumber'>{{lesionData.lesionNumber}}</td>
|
<td class='lesionNumber'>{{lesionNumber}}</td>
|
||||||
<td class='location'>{{lesionData.location}}</td>
|
<td class='location'>{{location}}</td>
|
||||||
<td class='target'>{{#if lesionData.isTarget}} Y {{else}} N {{/if}}</td>
|
<td class='target'>{{#if isTarget}} Y {{else}} N {{/if}}</td>
|
||||||
<!--Each time point as a column-->
|
<!--Each time point as a column-->
|
||||||
{{# each timepoints }}
|
{{# each timepoints }}
|
||||||
{{> lesionTableTimepointCell}}
|
{{> lesionTableTimepointCell}}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
Template.lesionTableRow.helpers({
|
Template.lesionTableRow.helpers({
|
||||||
'timepoints': function() {
|
'timepoints': function() {
|
||||||
return this.lesionData.timepoints;
|
return Timepoints.find();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
Template.lesionTableTimepointCell.helpers({
|
Template.lesionTableTimepointCell.helpers({
|
||||||
'longestDiameter': function() {
|
'longestDiameter': function() {
|
||||||
var longestDiameter = this[Object.keys(this)[0]].longestDiameter;
|
// Search Measurements by lesion and timepoint
|
||||||
return longestDiameter;
|
var lesionData = Template.parentData(1);
|
||||||
|
return lesionData.timepoints[this.timepointID].longestDiameter;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1,5 +0,0 @@
|
|||||||
Template.lesionTableTimepointHeader.helpers({
|
|
||||||
'timepoints': function (){
|
|
||||||
return this.timepoints;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
getActiveTimepointID = function (viewportElement) {
|
|
||||||
var contentId = Session.get("activeContentId");
|
|
||||||
var imageViewportElements = $("#"+contentId).find(".imageViewerViewport");
|
|
||||||
var index = $(imageViewportElements).index(viewportElement);
|
|
||||||
|
|
||||||
return contentId.toString() + index.toString();
|
|
||||||
};
|
|
||||||
@ -41,4 +41,7 @@ Package.onUse(function (api) {
|
|||||||
api.addFiles('lib/getActiveTimepointID.js', 'client');
|
api.addFiles('lib/getActiveTimepointID.js', 'client');
|
||||||
api.addFiles('lib/uuid.js', 'client');
|
api.addFiles('lib/uuid.js', 'client');
|
||||||
|
|
||||||
|
api.export('Measurements', 'client');
|
||||||
|
api.export('Timepoints', 'client');
|
||||||
|
|
||||||
});
|
});
|
||||||
Loading…
Reference in New Issue
Block a user