LT-115: Removing the old code for calculating Measurement Numbers
This commit is contained in:
parent
c06043483d
commit
b776e5f411
@ -10,7 +10,6 @@ import { OHIF } from 'meteor/ohif:core';
|
|||||||
const shadowConfig = toolManager.getToolDefaultStates().shadowConfig;
|
const shadowConfig = toolManager.getToolDefaultStates().shadowConfig;
|
||||||
|
|
||||||
var configuration = {
|
var configuration = {
|
||||||
setMeasurementNumberCallback: setMeasurementNumberCallback,
|
|
||||||
getMeasurementLocationCallback: getMeasurementLocationCallback,
|
getMeasurementLocationCallback: getMeasurementLocationCallback,
|
||||||
changeMeasurementLocationCallback: changeMeasurementLocationCallback,
|
changeMeasurementLocationCallback: changeMeasurementLocationCallback,
|
||||||
...shadowConfig
|
...shadowConfig
|
||||||
@ -24,13 +23,6 @@ import { OHIF } from 'meteor/ohif:core';
|
|||||||
// The distance between the mouse and the tool to make it active
|
// The distance between the mouse and the tool to make it active
|
||||||
var distanceThreshold = 7;
|
var distanceThreshold = 7;
|
||||||
|
|
||||||
// Set lesion number
|
|
||||||
// Get Target lesions on image
|
|
||||||
function setMeasurementNumberCallback(measurementData, eventData, doneCallback) {
|
|
||||||
var measurementNumber = 1;
|
|
||||||
doneCallback(measurementNumber);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Define a callback to get your text annotation
|
// Define a callback to get your text annotation
|
||||||
// This could be used, e.g. to open a modal
|
// This could be used, e.g. to open a modal
|
||||||
function getMeasurementLocationCallback(measurementData, eventData, doneCallback) {
|
function getMeasurementLocationCallback(measurementData, eventData, doneCallback) {
|
||||||
@ -111,8 +103,7 @@ import { OHIF } from 'meteor/ohif:core';
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function doneCallback(measurementNumber) {
|
function doneCallback() {
|
||||||
measurementData.measurementNumber = measurementNumber;
|
|
||||||
measurementData.active = false;
|
measurementData.active = false;
|
||||||
cornerstone.updateImage(element);
|
cornerstone.updateImage(element);
|
||||||
}
|
}
|
||||||
@ -124,11 +115,7 @@ import { OHIF } from 'meteor/ohif:core';
|
|||||||
mouseButtonMask: mouseEventData.which
|
mouseButtonMask: mouseEventData.which
|
||||||
};
|
};
|
||||||
|
|
||||||
// Set lesion number and lesion name
|
|
||||||
var config = cornerstoneTools.bidirectional.getConfiguration();
|
var config = cornerstoneTools.bidirectional.getConfiguration();
|
||||||
if (measurementData.measurementNumber === undefined) {
|
|
||||||
config.setMeasurementNumberCallback(measurementData, mouseEventData, doneCallback);
|
|
||||||
}
|
|
||||||
|
|
||||||
// associate this data with this imageId so we can render it and manipulate it
|
// associate this data with this imageId so we can render it and manipulate it
|
||||||
cornerstoneTools.addToolState(element, toolType, measurementData);
|
cornerstoneTools.addToolState(element, toolType, measurementData);
|
||||||
@ -190,19 +177,14 @@ import { OHIF } from 'meteor/ohif:core';
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function doneCallback(measurementNumber) {
|
function doneCallback() {
|
||||||
measurementData.measurementNumber = measurementNumber;
|
|
||||||
measurementData.active = false;
|
measurementData.active = false;
|
||||||
cornerstone.updateImage(element);
|
cornerstone.updateImage(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
var measurementData = createNewMeasurement(touchEventData);
|
var measurementData = createNewMeasurement(touchEventData);
|
||||||
|
|
||||||
// Set lesion number and lesion name
|
|
||||||
var config = cornerstoneTools.bidirectional.getConfiguration();
|
var config = cornerstoneTools.bidirectional.getConfiguration();
|
||||||
if (measurementData.measurementNumber === undefined) {
|
|
||||||
config.setMeasurementNumberCallback(measurementData, mouseEventData, doneCallback);
|
|
||||||
}
|
|
||||||
|
|
||||||
// associate this data with this imageId so we can render it and manipulate it
|
// associate this data with this imageId so we can render it and manipulate it
|
||||||
cornerstoneTools.addToolState(element, toolType, measurementData);
|
cornerstoneTools.addToolState(element, toolType, measurementData);
|
||||||
|
|||||||
@ -13,7 +13,6 @@
|
|||||||
}];
|
}];
|
||||||
|
|
||||||
var configuration = {
|
var configuration = {
|
||||||
setMeasurementNumberCallback: setMeasurementNumberCallback,
|
|
||||||
getMeasurementLocationCallback: getMeasurementLocationCallback,
|
getMeasurementLocationCallback: getMeasurementLocationCallback,
|
||||||
changeMeasurementLocationCallback: changeMeasurementLocationCallback,
|
changeMeasurementLocationCallback: changeMeasurementLocationCallback,
|
||||||
drawHandles: false,
|
drawHandles: false,
|
||||||
@ -26,12 +25,6 @@
|
|||||||
ESC: 27
|
ESC: 27
|
||||||
};
|
};
|
||||||
|
|
||||||
// Set lesion number
|
|
||||||
// Get Non-Target lesions on image
|
|
||||||
function setMeasurementNumberCallback(measurementData, eventData, doneCallback) {
|
|
||||||
var measurementNumber = 1;
|
|
||||||
doneCallback(measurementNumber);
|
|
||||||
}
|
|
||||||
// Define a callback to get your text annotation
|
// Define a callback to get your text annotation
|
||||||
// This could be used, e.g. to open a modal
|
// This could be used, e.g. to open a modal
|
||||||
function getMeasurementLocationCallback(measurementData, eventData, doneCallback) {
|
function getMeasurementLocationCallback(measurementData, eventData, doneCallback) {
|
||||||
@ -61,8 +54,7 @@
|
|||||||
function addNewMeasurement(mouseEventData) {
|
function addNewMeasurement(mouseEventData) {
|
||||||
var element = mouseEventData.element;
|
var element = mouseEventData.element;
|
||||||
|
|
||||||
function doneCallback(measurementNumber) {
|
function doneCallback() {
|
||||||
measurementData.measurementNumber = measurementNumber;
|
|
||||||
measurementData.active = true;
|
measurementData.active = true;
|
||||||
cornerstone.updateImage(element);
|
cornerstone.updateImage(element);
|
||||||
}
|
}
|
||||||
@ -75,11 +67,6 @@
|
|||||||
|
|
||||||
var config = cornerstoneTools[toolType].getConfiguration();
|
var config = cornerstoneTools[toolType].getConfiguration();
|
||||||
|
|
||||||
// Set lesion number and lesion name
|
|
||||||
if (measurementData.measurementNumber === undefined) {
|
|
||||||
config.setMeasurementNumberCallback(measurementData, mouseEventData, doneCallback);
|
|
||||||
}
|
|
||||||
|
|
||||||
// associate this data with this imageId so we can render it and manipulate it
|
// associate this data with this imageId so we can render it and manipulate it
|
||||||
cornerstoneTools.addToolState(mouseEventData.element, toolType, measurementData);
|
cornerstoneTools.addToolState(mouseEventData.element, toolType, measurementData);
|
||||||
|
|
||||||
@ -317,8 +304,7 @@
|
|||||||
function addNewMeasurementTouch(touchEventData) {
|
function addNewMeasurementTouch(touchEventData) {
|
||||||
var element = touchEventData.element;
|
var element = touchEventData.element;
|
||||||
|
|
||||||
function doneCallback(measurementNumber) {
|
function doneCallback() {
|
||||||
measurementData.measurementNumber = measurementNumber;
|
|
||||||
measurementData.active = true;
|
measurementData.active = true;
|
||||||
cornerstone.updateImage(element);
|
cornerstone.updateImage(element);
|
||||||
}
|
}
|
||||||
@ -330,11 +316,6 @@
|
|||||||
$(element).off('CornerstoneToolsTap', cornerstoneTools[toolType + "Touch"].tapCallback);
|
$(element).off('CornerstoneToolsTap', cornerstoneTools[toolType + "Touch"].tapCallback);
|
||||||
var config = cornerstoneTools[toolType].getConfiguration();
|
var config = cornerstoneTools[toolType].getConfiguration();
|
||||||
|
|
||||||
// Set lesion number and lesion name
|
|
||||||
if (measurementData.lesionName === undefined) {
|
|
||||||
config.setMeasurementNumberCallback(measurementData, touchEventData, doneCallback);
|
|
||||||
}
|
|
||||||
|
|
||||||
cornerstone.updateImage(element);
|
cornerstone.updateImage(element);
|
||||||
|
|
||||||
cornerstoneTools.moveNewHandleTouch(touchEventData, toolType, measurementData, measurementData.handles.end, function() {
|
cornerstoneTools.moveNewHandleTouch(touchEventData, toolType, measurementData, measurementData.handles.end, function() {
|
||||||
|
|||||||
@ -2,37 +2,6 @@
|
|||||||
// is in the process of being moved into another location
|
// is in the process of being moved into another location
|
||||||
import { OHIF } from 'meteor/ohif:core';
|
import { OHIF } from 'meteor/ohif:core';
|
||||||
|
|
||||||
// This event sets measurement number for new measurement
|
|
||||||
function getSetMeasurementNumberCallbackFunction(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 measurement number for this measurement, depending on whether or not the same measurement previously
|
|
||||||
// exists at a different timepoint
|
|
||||||
const timepointId = timepoint.timepointId;
|
|
||||||
const collection = measurementApi.tools[measurementTypeId];
|
|
||||||
const measurementNumber = OHIF.measurements.MeasurementManager.getNewMeasurementNumber(timepointId, collection, timepointApi);
|
|
||||||
measurementData.measurementNumber = measurementNumber;
|
|
||||||
|
|
||||||
// Set measurement number
|
|
||||||
doneCallback(measurementNumber);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
Template.measurementLocationDialog.onCreated(() => {
|
Template.measurementLocationDialog.onCreated(() => {
|
||||||
const instance = Template.instance();
|
const instance = Template.instance();
|
||||||
const measurementTypeId = 'bidirectional';
|
const measurementTypeId = 'bidirectional';
|
||||||
@ -67,7 +36,6 @@ Template.measurementLocationDialog.onCreated(() => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const callbackConfig = {
|
const callbackConfig = {
|
||||||
setMeasurementNumberCallback: getSetMeasurementNumberCallbackFunction(measurementTypeId, measurementApi, timepointApi),
|
|
||||||
// TODO: Check the position for these, the Add Label button position seems very awkward
|
// TODO: Check the position for these, the Add Label button position seems very awkward
|
||||||
getMeasurementLocationCallback: toggleLabel,
|
getMeasurementLocationCallback: toggleLabel,
|
||||||
changeMeasurementLocationCallback: toggleLabel,
|
changeMeasurementLocationCallback: toggleLabel,
|
||||||
|
|||||||
@ -36,26 +36,26 @@ class MeasurementApi {
|
|||||||
|
|
||||||
collection.find().observe({
|
collection.find().observe({
|
||||||
added: measurement => {
|
added: measurement => {
|
||||||
|
const timepoint = this.timepointApi.timepoints.findOne({
|
||||||
|
studyInstanceUids: measurement.studyInstanceUid
|
||||||
|
});
|
||||||
groupCollection.insert({
|
groupCollection.insert({
|
||||||
toolId: tool.id,
|
toolId: tool.id,
|
||||||
toolItemId: measurement._id,
|
toolItemId: measurement._id,
|
||||||
timepointId: measurement.timepointId,
|
timepointId: timepoint.timepointId,
|
||||||
studyInstanceUid: measurement.studyInstanceUid,
|
studyInstanceUid: measurement.studyInstanceUid,
|
||||||
createdAt: measurement.createdAt
|
createdAt: measurement.createdAt
|
||||||
});
|
});
|
||||||
|
|
||||||
const timepoint = this.timepointApi.timepoints.findOne({
|
const measurementNumber = groupCollection.find({
|
||||||
timepointId: measurement.timepointId
|
|
||||||
});
|
|
||||||
const measurementCount = groupCollection.find({
|
|
||||||
studyInstanceUid: {
|
studyInstanceUid: {
|
||||||
$in: timepoint.studyInstanceUids
|
$in: timepoint.studyInstanceUids
|
||||||
}
|
}
|
||||||
}).count();
|
}).count();
|
||||||
|
measurement.measurementNumber = measurementNumber;
|
||||||
collection.update(measurement._id, {
|
collection.update(measurement._id, {
|
||||||
$set: {
|
$set: {
|
||||||
measurementNumber: measurementCount
|
measurementNumber
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@ -44,21 +44,6 @@ class MeasurementHandlers {
|
|||||||
imageId: imageId // TODO: In the future we should consider removing this
|
imageId: imageId // TODO: In the future we should consider removing this
|
||||||
}, measurementData);
|
}, measurementData);
|
||||||
|
|
||||||
const timepointApi = instance.data.timepointApi;
|
|
||||||
if (timepointApi) {
|
|
||||||
const timepoint = timepointApi.study(studyInstanceUid)[0];
|
|
||||||
if (timepoint) {
|
|
||||||
const timepointId = timepoint.timepointId;
|
|
||||||
measurement.timepointId = timepointId;
|
|
||||||
measurement.measurementNumber = OHIF.measurements.MeasurementManager.getNewMeasurementNumber(timepointId, Collection, timepointApi);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const numCurrentMeasurementsInStudy = Collection.find({
|
|
||||||
studyInstanceUid: study.studyInstanceUid
|
|
||||||
}).count();
|
|
||||||
measurement.measurementNumber = numCurrentMeasurementsInStudy + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the related timepoint by the measurement number and use its location if defined
|
// Get the related timepoint by the measurement number and use its location if defined
|
||||||
const relatedTimepoint = Collection.findOne({
|
const relatedTimepoint = Collection.findOne({
|
||||||
measurementNumber: measurement.measurementNumber,
|
measurementNumber: measurement.measurementNumber,
|
||||||
@ -77,18 +62,14 @@ class MeasurementHandlers {
|
|||||||
// Insert the new measurement into the collection
|
// Insert the new measurement into the collection
|
||||||
measurementData._id = Collection.insert(measurement);
|
measurementData._id = Collection.insert(measurement);
|
||||||
|
|
||||||
|
// Get the update the measurement number after inserting
|
||||||
|
Meteor.defer(() => {
|
||||||
|
measurementData.measurementNumber = Collection.findOne(measurementData._id).measurementNumber;
|
||||||
|
cornerstone.updateImage(getActiveViewportElement());
|
||||||
|
});
|
||||||
|
|
||||||
// Signal unsaved changes
|
// Signal unsaved changes
|
||||||
OHIF.ui.unsavedChanges.set('viewer.studyViewer.measurements.' + eventData.toolType);
|
OHIF.ui.unsavedChanges.set('viewer.studyViewer.measurements.' + eventData.toolType);
|
||||||
|
|
||||||
// Update the Overall Measurement Numbers for all Measurements
|
|
||||||
if (timepointApi) {
|
|
||||||
const baseline = timepointApi.baseline();
|
|
||||||
|
|
||||||
// TODO: Fix this it is a terrible workaround but we have a demo to do
|
|
||||||
if (baseline) {
|
|
||||||
measurementApi.sortMeasurements(baseline.timepointId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static onModified(e, instance, eventData) {
|
static onModified(e, instance, eventData) {
|
||||||
@ -136,17 +117,6 @@ class MeasurementHandlers {
|
|||||||
|
|
||||||
// Signal unsaved changes
|
// Signal unsaved changes
|
||||||
OHIF.ui.unsavedChanges.set('viewer.studyViewer.measurements.' + eventData.toolType);
|
OHIF.ui.unsavedChanges.set('viewer.studyViewer.measurements.' + eventData.toolType);
|
||||||
|
|
||||||
// Update the Overall Measurement Numbers for all Measurements
|
|
||||||
const timepointApi = instance.data.timepointApi;
|
|
||||||
if (timepointApi) {
|
|
||||||
const baseline = timepointApi.baseline();
|
|
||||||
|
|
||||||
// TODO: Fix this it is a terrible workaround but we have a demo to do
|
|
||||||
if (baseline) {
|
|
||||||
measurementApi.sortMeasurements(baseline.timepointId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,31 +2,6 @@ import { OHIF } from 'meteor/ohif:core';
|
|||||||
|
|
||||||
class MeasurementManager {
|
class MeasurementManager {
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns new measurement number given a timepointId
|
|
||||||
*/
|
|
||||||
static getNewMeasurementNumber(timepointId, collection, timepointApi) {
|
|
||||||
// Get all current lesion measurements
|
|
||||||
const numMeasurements = collection.find().count();
|
|
||||||
|
|
||||||
// If no measurements exist yet, start at 1
|
|
||||||
if (!numMeasurements) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const timepoint = timepointApi.timepoints.findOne({
|
|
||||||
timepointId: timepointId
|
|
||||||
});
|
|
||||||
|
|
||||||
const numMeasurementsAtTimepoint = collection.find({
|
|
||||||
studyInstanceUid: {
|
|
||||||
$in: timepoint.studyInstanceUids
|
|
||||||
}
|
|
||||||
}).count();
|
|
||||||
|
|
||||||
return numMeasurementsAtTimepoint + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the current Measurements Number already exists
|
* If the current Measurements Number already exists
|
||||||
* for any other timepoint, returns lesion locationUID
|
* for any other timepoint, returns lesion locationUID
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user