Fix syncing bug LT-177, update Cornerstone package libraries

This commit is contained in:
Erik Ziegler committed 2016-02-13 17:42:10 +01:00
1 parent f7e24b8b10
commit b624d12762
24 files changed
+1240 -708

No files matched your search

+7 -23
View File
@@ -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);
}