Fix syncing bug LT-177, update Cornerstone package libraries
This commit is contained in:
1 parent
f7e24b8b10
commit
b624d12762
24 files changed
+1240
-708
No files matched your search
@@ -32,7 +32,77 @@
|
||||
//doneCallback(prompt('Change your lesion location:'));
|
||||
}
|
||||
|
||||
///////// BEGIN ACTIVE TOOL ///////
|
||||
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,
|
||||
drawnIndependently: true,
|
||||
index: 0
|
||||
},
|
||||
end: {
|
||||
x: mouseEventData.currentPoints.image.x,
|
||||
y: mouseEventData.currentPoints.image.y,
|
||||
highlight: true,
|
||||
active: true,
|
||||
drawnIndependently: true,
|
||||
index: 1
|
||||
},
|
||||
textBox: {
|
||||
x: mouseEventData.currentPoints.image.x - 50,
|
||||
y: mouseEventData.currentPoints.image.y - 70,
|
||||
active: false,
|
||||
movesIndependently: false,
|
||||
drawnIndependently: true,
|
||||
allowedOutsideImage: true,
|
||||
hasBoundingBox: true
|
||||
},
|
||||
perpendicularStart: {
|
||||
x: mouseEventData.currentPoints.image.x,
|
||||
y: mouseEventData.currentPoints.image.y,
|
||||
highlight: true,
|
||||
active: false,
|
||||
locked: true, // If perpendicular line is connected to long-line
|
||||
drawnIndependently: true,
|
||||
index: 2
|
||||
},
|
||||
perpendicularEnd: {
|
||||
x: mouseEventData.currentPoints.image.x,
|
||||
y: mouseEventData.currentPoints.image.y,
|
||||
highlight: true,
|
||||
active: false,
|
||||
drawnIndependently: true,
|
||||
index: 3
|
||||
}
|
||||
},
|
||||
imageId: imageId,
|
||||
seriesInstanceUid: seriesInstanceUid,
|
||||
studyInstanceUid: studyInstanceUid,
|
||||
patientId: patientId,
|
||||
longestDiameter: 0,
|
||||
shortestDiameter: 0,
|
||||
isDeleted: false,
|
||||
isTarget: true
|
||||
};
|
||||
return measurementData;
|
||||
}
|
||||
|
||||
function addNewMeasurement(mouseEventData) {
|
||||
var element = mouseEventData.element;
|
||||
@@ -53,9 +123,9 @@
|
||||
var eventData = {
|
||||
mouseButtonMask: mouseEventData.which
|
||||
};
|
||||
var config = cornerstoneTools.lesion.getConfiguration();
|
||||
|
||||
// Set lesion number and lesion name
|
||||
var config = cornerstoneTools.lesion.getConfiguration();
|
||||
if (measurementData.lesionNumber === undefined) {
|
||||
config.setLesionNumberCallback(measurementData, mouseEventData, doneCallback);
|
||||
}
|
||||
@@ -128,6 +198,12 @@
|
||||
|
||||
var measurementData = createNewMeasurement(touchEventData);
|
||||
|
||||
// Set lesion number and lesion name
|
||||
var config = cornerstoneTools.lesion.getConfiguration();
|
||||
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(element, toolType, measurementData);
|
||||
|
||||
@@ -139,9 +215,12 @@
|
||||
|
||||
cornerstone.updateImage(element);
|
||||
cornerstoneTools.moveNewHandleTouch(touchEventData, toolType, measurementData, measurementData.handles.end, function() {
|
||||
if (cornerstoneTools.anyHandlesOutsideImage(touchEventData, measurementData.handles)) {
|
||||
if (cancelled || cornerstoneTools.anyHandlesOutsideImage(touchEventData, measurementData.handles)) {
|
||||
// delete the measurement
|
||||
cornerstoneTools.removeToolState(element, toolType, measurementData);
|
||||
} else {
|
||||
// Set lesionMeasurementData Session
|
||||
config.getLesionLocationCallback(measurementData, touchEventData, doneCallback);
|
||||
}
|
||||
|
||||
// perpendicular line is not connected to long-line
|
||||
@@ -154,80 +233,6 @@
|
||||
});
|
||||
}
|
||||
|
||||
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,
|
||||
drawnIndependently: true,
|
||||
index: 0
|
||||
},
|
||||
end: {
|
||||
x: mouseEventData.currentPoints.image.x,
|
||||
y: mouseEventData.currentPoints.image.y,
|
||||
highlight: true,
|
||||
active: true,
|
||||
drawnIndependently: true,
|
||||
index: 1
|
||||
},
|
||||
textBox: {
|
||||
x: mouseEventData.currentPoints.image.x - 50,
|
||||
y: mouseEventData.currentPoints.image.y - 70,
|
||||
pointNearHandle: pointNearTextBox,
|
||||
active: false,
|
||||
movesIndependently: false,
|
||||
drawnIndependently: true,
|
||||
allowedOutsideImage: true
|
||||
},
|
||||
perpendicularStart: {
|
||||
x: mouseEventData.currentPoints.image.x,
|
||||
y: mouseEventData.currentPoints.image.y,
|
||||
highlight: true,
|
||||
active: false,
|
||||
locked: true, // If perpendicular line is connected to long-line
|
||||
drawnIndependently: true,
|
||||
index: 2
|
||||
},
|
||||
perpendicularEnd: {
|
||||
x: mouseEventData.currentPoints.image.x,
|
||||
y: mouseEventData.currentPoints.image.y,
|
||||
highlight: true,
|
||||
active: false,
|
||||
drawnIndependently: true,
|
||||
index: 3
|
||||
}
|
||||
},
|
||||
imageId: imageId,
|
||||
seriesInstanceUid: seriesInstanceUid,
|
||||
studyInstanceUid: studyInstanceUid,
|
||||
patientId: patientId,
|
||||
measurementText: 0,
|
||||
widthMeasurement: 0,
|
||||
perpendicularMeasurement: 0,
|
||||
isDeleted: false,
|
||||
isTarget: true
|
||||
};
|
||||
return measurementData;
|
||||
}
|
||||
///////// END ACTIVE TOOL ///////
|
||||
|
||||
function pointNearTool(element, data, coords) {
|
||||
var lineSegment = {
|
||||
start: cornerstone.pixelToCanvas(element, data.handles.start),
|
||||
@@ -235,7 +240,7 @@
|
||||
};
|
||||
var distanceToPoint = cornerstoneMath.lineSegment.distanceToPoint(lineSegment, coords);
|
||||
|
||||
if (pointNearTextBox(element, data.handles.textBox, coords)) {
|
||||
if (cornerstoneTools.pointInsideBoundingBox(data.handles.textBox, coords)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -246,14 +251,6 @@
|
||||
return (distanceToPoint < 5);
|
||||
}
|
||||
|
||||
function pointNearTextBox(element, handle, coords) {
|
||||
if (!handle.boundingBox) {
|
||||
return;
|
||||
}
|
||||
|
||||
return cornerstoneMath.point.insideRect(coords, handle.boundingBox);
|
||||
}
|
||||
|
||||
function pointNearPerpendicular(element, handles, coords) {
|
||||
var lineSegment = {
|
||||
start: cornerstone.pixelToCanvas(element, handles.perpendicularStart),
|
||||
@@ -265,7 +262,6 @@
|
||||
|
||||
// Move long-axis start point
|
||||
function perpendicularBothFixedLeft(eventData, data) {
|
||||
|
||||
var longLine = {
|
||||
start: {
|
||||
x: data.handles.start.x,
|
||||
@@ -273,7 +269,7 @@
|
||||
},
|
||||
end: {
|
||||
x: data.handles.end.x,
|
||||
y: data.handles. end.y
|
||||
y: data.handles.end.y
|
||||
}
|
||||
};
|
||||
|
||||
@@ -284,7 +280,7 @@
|
||||
},
|
||||
end: {
|
||||
x: data.handles.perpendicularEnd.x,
|
||||
y: data.handles. perpendicularEnd.y
|
||||
y: data.handles.perpendicularEnd.y
|
||||
}
|
||||
};
|
||||
|
||||
@@ -322,7 +318,6 @@
|
||||
|
||||
// Move long-axis end point
|
||||
function perpendicularBothFixedRight(eventData, data) {
|
||||
|
||||
var longLine = {
|
||||
start: {
|
||||
x: data.handles.start.x,
|
||||
@@ -330,7 +325,7 @@
|
||||
},
|
||||
end: {
|
||||
x: data.handles.end.x,
|
||||
y: data.handles. end.y
|
||||
y: data.handles.end.y
|
||||
}
|
||||
};
|
||||
|
||||
@@ -341,7 +336,7 @@
|
||||
},
|
||||
end: {
|
||||
x: data.handles.perpendicularEnd.x,
|
||||
y: data.handles. perpendicularEnd.y
|
||||
y: data.handles.perpendicularEnd.y
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1046,8 +1041,8 @@
|
||||
data.handles.textBox.boundingBox = boundingBox;
|
||||
|
||||
// Set measurement text to show lesion table
|
||||
data.measurementText = length.toFixed(1);
|
||||
data.widthMeasurement = width.toFixed(1);
|
||||
data.longestDiameter = length.toFixed(1);
|
||||
data.shortestDiameter = width.toFixed(1);
|
||||
|
||||
context.restore();
|
||||
}
|
||||
|
||||
@@ -141,18 +141,18 @@
|
||||
textBox: {
|
||||
x: mouseEventData.currentPoints.image.x - 50,
|
||||
y: mouseEventData.currentPoints.image.y - 50,
|
||||
pointNearHandle: pointNearTextBox,
|
||||
active: false,
|
||||
movesIndependently: false,
|
||||
drawnIndependently: true,
|
||||
allowedOutsideImage: true
|
||||
allowedOutsideImage: true,
|
||||
hasBoundingBox: true
|
||||
}
|
||||
},
|
||||
imageId: imageId,
|
||||
seriesInstanceUid: seriesInstanceUid,
|
||||
studyInstanceUid: studyInstanceUid,
|
||||
patientId: patientId,
|
||||
measurementText: '',
|
||||
response: '',
|
||||
isTarget: false
|
||||
};
|
||||
|
||||
@@ -167,21 +167,13 @@
|
||||
};
|
||||
var distanceToPoint = cornerstoneMath.lineSegment.distanceToPoint(lineSegment, coords);
|
||||
|
||||
if (pointNearTextBox(element, data.handles.textBox, coords)) {
|
||||
if (cornerstoneTools.pointInsideBoundingBox(data.handles.textBox, coords)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return distanceToPoint < 25;
|
||||
}
|
||||
|
||||
function pointNearTextBox(element, handle, coords) {
|
||||
if (!handle.boundingBox) {
|
||||
return;
|
||||
}
|
||||
|
||||
return cornerstoneMath.point.insideRect(coords, handle.boundingBox);
|
||||
}
|
||||
|
||||
///////// BEGIN IMAGE RENDERING ///////
|
||||
function onImageRendered(e, eventData) {
|
||||
var element = eventData.element;
|
||||
|
||||
@@ -79,7 +79,7 @@ Template.lesionTable.onRendered(function() {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('ViewerData changed, check for displayed timepoints');
|
||||
log.info('ViewerData changed, check for displayed timepoints');
|
||||
|
||||
// Get study dates of imageViewerViewport elements
|
||||
var loadedStudyDates = {
|
||||
|
||||
+1
-2
@@ -290,8 +290,7 @@ Template.nonTargetLesionDialog.events({
|
||||
/// Set the isTarget value to true, since this is the target-lesion dialog callback
|
||||
measurementData.isTarget = false;
|
||||
|
||||
// measurementText is set from location response list
|
||||
measurementData.measurementText = responseOptionId;
|
||||
// Response is set from location response list
|
||||
measurementData.response = responseOptionId;
|
||||
|
||||
// Adds lesion data to timepoints array
|
||||
|
||||
+1
-2
@@ -109,8 +109,7 @@ Template.nonTargetResponseDialog.events({
|
||||
/// Set the isTarget value to true, since this is the target-lesion dialog callback
|
||||
measurementData.isTarget = false;
|
||||
|
||||
// measurementText is set from location response list
|
||||
measurementData.measurementText = responseOptionId;
|
||||
// Response is set from location response list
|
||||
measurementData.response = responseOptionId;
|
||||
|
||||
// Adds lesion data to timepoints array
|
||||
|
||||
@@ -47,8 +47,8 @@ function updateLesionData(lesionData) {
|
||||
};
|
||||
|
||||
if (lesionData.isTarget === true) {
|
||||
timepointData.shortestDiameter = lesionData.widthMeasurement;
|
||||
timepointData.longestDiameter = lesionData.measurementText;
|
||||
timepointData.shortestDiameter = lesionData.shortestDiameter;
|
||||
timepointData.longestDiameter = lesionData.longestDiameter;
|
||||
} else {
|
||||
timepointData.response = lesionData.response;
|
||||
}
|
||||
@@ -79,27 +79,15 @@ function updateLesionData(lesionData) {
|
||||
measurement.timepoints[timepoint.timepointId] = timepointData;
|
||||
|
||||
// Set a flag to prevent duplication of toolData
|
||||
measurement.toolDataInsertedManually = true;
|
||||
measurement.clientId = ClientId;
|
||||
|
||||
// Increment and store the absolute Lesion Number for this Measurement
|
||||
measurement.lesionNumberAbsolute = Measurements.find().count() + 1;
|
||||
|
||||
// Insert this into the Measurements Collection
|
||||
// Save the ID into the toolData (not sure if this works?)
|
||||
console.log('LesionManager inserting Measurement');
|
||||
log.info('LesionManager inserting Measurement');
|
||||
measurement.id = Measurements.insert(measurement);
|
||||
|
||||
// Update the database entry so it can be re-added next time the study is loaded
|
||||
Measurements.update(measurement.id, {
|
||||
$set: {
|
||||
toolDataInsertedManually: false
|
||||
}
|
||||
}, function(error) {
|
||||
if (error) {
|
||||
log.warn(error);
|
||||
}
|
||||
OHIF.viewer.manuallyModifyingMeasurement = false;
|
||||
});
|
||||
} else {
|
||||
lesionData.id = existingMeasurement._id;
|
||||
lesionData.isNodal = existingMeasurement.isNodal;
|
||||
@@ -111,16 +99,12 @@ function updateLesionData(lesionData) {
|
||||
// Update timepoints from lesion data
|
||||
existingMeasurement.timepoints[timepoint.timepointId] = timepointData;
|
||||
|
||||
console.log('LesionManager updating Measurement');
|
||||
log.info('LesionManager updating Measurement');
|
||||
Measurements.update(existingMeasurement._id, {
|
||||
$set: {
|
||||
timepoints: existingMeasurement.timepoints
|
||||
timepoints: existingMeasurement.timepoints,
|
||||
clientId: ClientId
|
||||
}
|
||||
}, function(error) {
|
||||
if (error) {
|
||||
log.warn(error);
|
||||
}
|
||||
OHIF.viewer.manuallyModifyingMeasurement = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ handleMeasurementAdded = function(e, eventData) {
|
||||
case 'nonTarget':
|
||||
case 'lesion':
|
||||
log.info('CornerstoneToolsMeasurementAdded');
|
||||
OHIF.viewer.manuallyModifyingMeasurement = true;
|
||||
LesionManager.updateLesionData(measurementData);
|
||||
TrialResponseCriteria.validateDelayed(measurementData);
|
||||
break;
|
||||
|
||||
@@ -5,7 +5,6 @@ handleMeasurementModified = function(e, eventData) {
|
||||
case 'nonTarget':
|
||||
case 'lesion':
|
||||
log.info('CornerstoneToolsMeasurementModified');
|
||||
OHIF.viewer.manuallyModifyingMeasurement = true;
|
||||
LesionManager.updateLesionData(measurementData);
|
||||
TrialResponseCriteria.validateDelayed(measurementData);
|
||||
break;
|
||||
|
||||
@@ -21,8 +21,8 @@ removeToolDataWithMeasurementId = function(imageId, toolType, measurementId) {
|
||||
}
|
||||
});
|
||||
|
||||
console.log("Removing Indices: ");
|
||||
console.log(toRemove);
|
||||
log.info("Removing Indices: ");
|
||||
log.info(toRemove);
|
||||
|
||||
// If any toolData entries need to be removed, splice them from
|
||||
// the toolData array
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
syncMeasurementAndToolData = function(measurement) {
|
||||
console.log('syncMeasurementAndToolData');
|
||||
log.info('syncMeasurementAndToolData');
|
||||
|
||||
// Check what toolType we should be adding this to, based on the isTarget value
|
||||
// of the stored Measurement
|
||||
@@ -10,54 +10,48 @@ syncMeasurementAndToolData = function(measurement) {
|
||||
var timepointData = measurement.timepoints[key];
|
||||
var imageId = timepointData.imageId;
|
||||
|
||||
// Sync the Cornerstone ToolData with this Measurement's timepoint-specific data
|
||||
syncTimepointDataWithToolData(measurement, timepointData, imageId, toolType);
|
||||
});
|
||||
};
|
||||
|
||||
function syncTimepointDataWithToolData(measurement, timepointData, imageId, toolType) {
|
||||
// Get the global imageId-specific toolState from Cornerstone Tools
|
||||
var toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.toolState;
|
||||
|
||||
// If no tool state exists for this imageId, create an empty object to store it
|
||||
if (!toolState[imageId]) {
|
||||
toolState[imageId] = {};
|
||||
}
|
||||
|
||||
// This is probably not the best approach to prevent duplicates
|
||||
if (toolState[imageId][toolType] && toolState[imageId][toolType].data) {
|
||||
var measurementHasNoIdYet = false;
|
||||
toolState[imageId][toolType].data.forEach(function(measurement) {
|
||||
if (measurement.id !== 'notready') {
|
||||
return;
|
||||
}
|
||||
// Check if we already have toolData for this imageId and toolType
|
||||
if (toolState[imageId][toolType] &&
|
||||
toolState[imageId][toolType].data &&
|
||||
toolState[imageId][toolType].data.length) {
|
||||
|
||||
measurementHasNoIdYet = true;
|
||||
return false;
|
||||
});
|
||||
|
||||
// Stop here if it appears that we are creating this measurement right now,
|
||||
// and would not like this function to add another copy of it to the toolData
|
||||
if (measurementHasNoIdYet === true) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (toolState[imageId][toolType]) {
|
||||
var alreadyExists = false;
|
||||
// If we have toolData, we should search it for any toolData
|
||||
// related to the current Measurement
|
||||
var toolData = toolState[imageId][toolType].data;
|
||||
if (!toolData.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a flag so we know if we have successfully updated
|
||||
// this Measurement's timepoint data in the toolData
|
||||
var alreadyExists = false;
|
||||
|
||||
// Loop through the toolData to search for this Measurement's
|
||||
// timepoint data
|
||||
toolData.forEach(function(tool) {
|
||||
// Break the loop if this isn't the Measurement we are looking for
|
||||
if (tool.id !== measurement._id) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If we find the Measurement, set the flag to True
|
||||
alreadyExists = true;
|
||||
|
||||
// Update the toolData lesionNumber from the Measurement
|
||||
// Update the toolData from the Measurement data and
|
||||
// timepoint-specific data from this Measurement
|
||||
tool.lesionNumber = measurement.lesionNumber;
|
||||
tool.isTarget = measurement.isTarget;
|
||||
|
||||
tool.active = timepointData.active;
|
||||
tool.visible = timepointData.visible;
|
||||
tool.isDeleted = timepointData.isDeleted;
|
||||
@@ -65,31 +59,30 @@ function syncTimepointDataWithToolData(measurement, timepointData, imageId, tool
|
||||
return false;
|
||||
});
|
||||
|
||||
// If we found the Measurement we intended to update, we can stop
|
||||
// this function here
|
||||
if (alreadyExists === true) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// If no toolData exists for this toolType, create an empty array to hold some
|
||||
toolState[imageId][toolType] = {
|
||||
data: []
|
||||
};
|
||||
}
|
||||
|
||||
// Create measurementData structure based on the lesion data at this timepoint
|
||||
// We will add this into the toolData for this imageId
|
||||
var measurementData = timepointData;
|
||||
measurementData.isTarget = measurement.isTarget;
|
||||
measurementData.lesionNumber = measurement.lesionNumber;
|
||||
measurementData.measurementText = measurement.measurementText;
|
||||
measurementData.isDeleted = measurement.isDeleted;
|
||||
measurementData.location = measurement.location;
|
||||
measurementData.locationUID = measurement.locationUID;
|
||||
measurementData.patientId = measurement.patientId;
|
||||
measurementData.visible = measurement.visible;
|
||||
measurementData.active = measurement.active;
|
||||
measurementData.uid = measurement.uid;
|
||||
measurementData.id = measurement._id;
|
||||
// If we have reached this point, it means we haven't found the Measurement we are
|
||||
// looking for in the current toolData. This means we need to add it.
|
||||
|
||||
toolState[imageId][toolType].data.push(measurementData);
|
||||
// First, create the measurementData structure based on the lesion data at this timepoint.
|
||||
var tool = timepointData;
|
||||
tool.lesionNumber = measurement.lesionNumber;
|
||||
tool.isTarget = measurement.isTarget;
|
||||
tool.location = measurement.location;
|
||||
tool.locationUID = measurement.locationUID;
|
||||
tool.patientId = measurement.patientId;
|
||||
tool.id = measurement._id;
|
||||
|
||||
TrialResponseCriteria.validateSingleMeasurement(measurementData);
|
||||
// Add the measurementData into the toolData for this imageId
|
||||
toolState[imageId][toolType].data.push(tool);
|
||||
}
|
||||
Reference in new issue
Block a user