LT-115: Adapting MeasurementAPI to new tools storage structure
This commit is contained in:
parent
bd748eae32
commit
c9c2cd548e
@ -1,5 +1,6 @@
|
||||
import { Template } from 'meteor/templating';
|
||||
import { Session } from 'meteor/session';
|
||||
import { ReactiveDict } from 'meteor/reactive-dict';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
import { _ } from 'meteor/underscore';
|
||||
|
||||
@ -132,8 +133,6 @@ Template.viewer.onCreated(() => {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Find and activate the first measurement by Lesion Number
|
||||
// NOTE: This is inefficient, we should be using a hanging protocol
|
||||
// to hang the first measurement's imageId immediately, rather
|
||||
@ -143,7 +142,7 @@ Template.viewer.onCreated(() => {
|
||||
const measurementApi = instance.data.measurementApi;
|
||||
const timepointApi = instance.data.timepointApi;
|
||||
|
||||
const collection = measurementApi[measurementTypeId];
|
||||
const collection = measurementApi.tools[measurementTypeId];
|
||||
const sorting = {
|
||||
sort: {
|
||||
measurementNumber: -1
|
||||
@ -155,7 +154,7 @@ Template.viewer.onCreated(() => {
|
||||
const current = timepointApi.current();
|
||||
if (!current) {
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
let timepoints = [current];
|
||||
const prior = timepointApi.prior();
|
||||
@ -181,14 +180,14 @@ Template.viewer.onCreated(() => {
|
||||
}
|
||||
|
||||
firstMeasurementActivated = true;
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
Template.viewer.helpers({
|
||||
dataSourcesReady() {
|
||||
// TODO: Find a better way to do this
|
||||
const ready = Session.get('TimepointsReady') && Session.get('MeasurementsReady');
|
||||
console.log('dataSourcesReady? : ' + ready);
|
||||
OHIF.log.info('dataSourcesReady? : ' + ready);
|
||||
return ready;
|
||||
}
|
||||
});
|
||||
@ -197,9 +196,11 @@ Template.viewer.events({
|
||||
'CornerstoneToolsMeasurementAdded .imageViewerViewport'(event, instance, eventData) {
|
||||
OHIF.measurements.MeasurementHandlers.onAdded(event, instance, eventData);
|
||||
},
|
||||
|
||||
'CornerstoneToolsMeasurementModified .imageViewerViewport'(event, instance, eventData) {
|
||||
OHIF.measurements.MeasurementHandlers.onModified(event, instance, eventData);
|
||||
},
|
||||
|
||||
'CornerstoneToolsMeasurementRemoved .imageViewerViewport'(event, instance, eventData) {
|
||||
OHIF.measurements.MeasurementHandlers.onRemoved(event, instance, eventData);
|
||||
}
|
||||
|
||||
@ -1,8 +1,3 @@
|
||||
import { target } from './target';
|
||||
import { nonTarget } from './nonTarget';
|
||||
import { length } from './length';
|
||||
import { ellipse } from './ellipse';
|
||||
|
||||
export const validateMeasurements = () => {
|
||||
console.log('validateMeasurements');
|
||||
};
|
||||
|
||||
@ -1,6 +1,3 @@
|
||||
import './nonTarget.js';
|
||||
import './ellipse.js';
|
||||
import './length.js';
|
||||
import './measurementTools.js';
|
||||
import './dataExchange.js';
|
||||
import './dataValidation.js';
|
||||
|
||||
@ -86,6 +86,8 @@ const displayFunction = data => {
|
||||
};
|
||||
|
||||
export const bidirectional = {
|
||||
id: 'bidirectional',
|
||||
name: 'Target',
|
||||
toolGroup: 'targets',
|
||||
cornerstoneToolType: 'bidirectional',
|
||||
schema: BidirectionalSchema,
|
||||
|
||||
@ -4,18 +4,18 @@ import { MeasurementSchemaTypes } from 'meteor/ohif:measurements/both/schema/mea
|
||||
const CornerstoneHandleSchema = MeasurementSchemaTypes.CornerstoneHandleSchema;
|
||||
|
||||
const EllipseHandlesSchema = new SimpleSchema({
|
||||
start: {
|
||||
type: CornerstoneHandleSchema,
|
||||
label: 'Start'
|
||||
},
|
||||
end: {
|
||||
type: CornerstoneHandleSchema,
|
||||
label: 'End'
|
||||
},
|
||||
textBox: {
|
||||
type: CornerstoneHandleSchema,
|
||||
label: 'Text Box'
|
||||
},
|
||||
start: {
|
||||
type: CornerstoneHandleSchema,
|
||||
label: 'Start'
|
||||
},
|
||||
end: {
|
||||
type: CornerstoneHandleSchema,
|
||||
label: 'End'
|
||||
},
|
||||
textBox: {
|
||||
type: CornerstoneHandleSchema,
|
||||
label: 'Text Box'
|
||||
},
|
||||
});
|
||||
|
||||
const EllipseSchema = new SimpleSchema([MeasurementSchemaTypes.CornerstoneToolMeasurement, {
|
||||
@ -28,6 +28,7 @@ const EllipseSchema = new SimpleSchema([MeasurementSchemaTypes.CornerstoneToolMe
|
||||
export const ellipse = {
|
||||
id: 'ellipse',
|
||||
name: 'Ellipse',
|
||||
toolGroup: 'temp',
|
||||
cornerstoneToolType: 'ellipticalRoi',
|
||||
schema: EllipseSchema
|
||||
}
|
||||
};
|
||||
|
||||
@ -4,18 +4,18 @@ import { MeasurementSchemaTypes } from 'meteor/ohif:measurements/both/schema/mea
|
||||
const CornerstoneHandleSchema = MeasurementSchemaTypes.CornerstoneHandleSchema;
|
||||
|
||||
const LengthHandlesSchema = new SimpleSchema({
|
||||
start: {
|
||||
type: CornerstoneHandleSchema,
|
||||
label: 'Start'
|
||||
},
|
||||
end: {
|
||||
type: CornerstoneHandleSchema,
|
||||
label: 'End'
|
||||
},
|
||||
textBox: {
|
||||
type: CornerstoneHandleSchema,
|
||||
label: 'Text Box'
|
||||
},
|
||||
start: {
|
||||
type: CornerstoneHandleSchema,
|
||||
label: 'Start'
|
||||
},
|
||||
end: {
|
||||
type: CornerstoneHandleSchema,
|
||||
label: 'End'
|
||||
},
|
||||
textBox: {
|
||||
type: CornerstoneHandleSchema,
|
||||
label: 'Text Box'
|
||||
}
|
||||
});
|
||||
|
||||
const LengthSchema = new SimpleSchema([MeasurementSchemaTypes.CornerstoneToolMeasurement, {
|
||||
@ -28,6 +28,7 @@ const LengthSchema = new SimpleSchema([MeasurementSchemaTypes.CornerstoneToolMea
|
||||
export const length = {
|
||||
id: 'length',
|
||||
name: 'Length',
|
||||
toolGroup: 'temp',
|
||||
cornerstoneToolType: 'length',
|
||||
schema: LengthSchema
|
||||
}
|
||||
};
|
||||
|
||||
@ -45,6 +45,8 @@ const NonTargetSchema = new SimpleSchema([MeasurementSchemaTypes.CornerstoneTool
|
||||
}]);
|
||||
|
||||
export const nonTarget = {
|
||||
id: 'nonTarget',
|
||||
name: 'Non-Target',
|
||||
toolGroup: 'nonTargets',
|
||||
cornerstoneToolType: 'nonTarget',
|
||||
schema: NonTargetSchema,
|
||||
|
||||
@ -50,6 +50,8 @@ const TargetCRSchema = new SimpleSchema([MeasurementSchemaTypes.CornerstoneToolM
|
||||
}]);
|
||||
|
||||
export const targetCR = {
|
||||
id: 'targetCR',
|
||||
name: 'CR Target',
|
||||
toolGroup: 'targets',
|
||||
cornerstoneToolType: 'targetCR',
|
||||
schema: TargetCRSchema,
|
||||
|
||||
@ -50,6 +50,8 @@ const TargetUNSchema = new SimpleSchema([MeasurementSchemaTypes.CornerstoneToolM
|
||||
}]);
|
||||
|
||||
export const targetUN = {
|
||||
id: 'targetUN',
|
||||
name: 'UN Target',
|
||||
toolGroup: 'targets',
|
||||
cornerstoneToolType: 'targetUN',
|
||||
schema: TargetUNSchema,
|
||||
|
||||
@ -7,7 +7,7 @@ import { FieldLesionLocation, FieldLesionLocationResponse } from 'meteor/ohif:le
|
||||
Template.dialogNonTargetMeasurement.onCreated(() => {
|
||||
const instance = Template.instance();
|
||||
|
||||
instance.measurementTypeId = 'nonTargets';
|
||||
instance.measurementTypeId = 'nonTarget';
|
||||
const timepointApi = instance.data.timepointApi;
|
||||
|
||||
instance.schema = new SimpleSchema({
|
||||
@ -63,7 +63,7 @@ Template.dialogNonTargetMeasurement.onRendered(() => {
|
||||
const measurementApi = instance.viewerData.measurementApi;
|
||||
const timepointApi = instance.viewerData.timepointApi;
|
||||
|
||||
const collection = measurementApi[instance.measurementTypeId];
|
||||
const collection = measurementApi.tools[instance.measurementTypeId];
|
||||
|
||||
const measurementData = instance.data.measurementData;
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ function getSetMeasurementNumberCallbackFunction(measurementTypeId, measurementA
|
||||
// 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[measurementTypeId];
|
||||
const collection = measurementApi.tools[measurementTypeId];
|
||||
const measurementNumber = OHIF.measurements.MeasurementManager.getNewMeasurementNumber(timepointId, collection, timepointApi);
|
||||
measurementData.measurementNumber = measurementNumber;
|
||||
|
||||
@ -35,7 +35,7 @@ function getSetMeasurementNumberCallbackFunction(measurementTypeId, measurementA
|
||||
|
||||
Template.measurementLocationDialog.onCreated(() => {
|
||||
const instance = Template.instance();
|
||||
const measurementTypeId = 'targets';
|
||||
const measurementTypeId = 'bidirectional';
|
||||
const measurementApi = instance.data.measurementApi;
|
||||
const timepointApi = instance.data.timepointApi;
|
||||
|
||||
|
||||
@ -19,12 +19,21 @@ class MeasurementApi {
|
||||
this.currentTimepointId = currentTimepointId;
|
||||
}
|
||||
|
||||
configuration.measurementTools.forEach(tool => {
|
||||
const measurementTypeId = tool.id;
|
||||
this.toolGroups = {};
|
||||
this.tools = {};
|
||||
|
||||
this[measurementTypeId] = new Mongo.Collection(null);
|
||||
this[measurementTypeId]._debugName = tool.name;
|
||||
this[measurementTypeId].attachSchema(tool.schema);
|
||||
configuration.measurementTools.forEach(toolGroup => {
|
||||
const collection = new Mongo.Collection(null);
|
||||
collection._debugName = toolGroup.name;
|
||||
collection.attachSchema(toolGroup.schema);
|
||||
this.toolGroups[toolGroup.id] = collection;
|
||||
|
||||
toolGroup.childTools.forEach(tool => {
|
||||
const collection = new Mongo.Collection(null);
|
||||
collection._debugName = tool.name;
|
||||
collection.attachSchema(tool.schema);
|
||||
this.tools[tool.id] = collection;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@ -45,7 +54,7 @@ class MeasurementApi {
|
||||
|
||||
measurements.forEach(measurement => {
|
||||
delete measurement._id;
|
||||
this[measurementTypeId].insert(measurement);
|
||||
this.tools[measurementTypeId].insert(measurement);
|
||||
});
|
||||
});
|
||||
|
||||
@ -63,7 +72,7 @@ class MeasurementApi {
|
||||
let measurementData = {};
|
||||
configuration.measurementTools.forEach(tool => {
|
||||
const measurementTypeId = tool.id;
|
||||
measurementData[measurementTypeId] = this[measurementTypeId].find().fetch();
|
||||
measurementData[measurementTypeId] = this.tools[measurementTypeId].find().fetch();
|
||||
});
|
||||
|
||||
const timepointIds = timepoints.map(t => t.timepointId);
|
||||
@ -89,7 +98,7 @@ class MeasurementApi {
|
||||
|
||||
syncMeasurementsAndToolData() {
|
||||
configuration.measurementTools.forEach(tool => {
|
||||
const measurements = this[tool.id].find().fetch();
|
||||
const measurements = this.tools[tool.id].find().fetch();
|
||||
measurements.forEach(measurement => {
|
||||
OHIF.measurements.syncMeasurementAndToolData(measurement);
|
||||
});
|
||||
@ -199,7 +208,7 @@ class MeasurementApi {
|
||||
|
||||
// First, update Measurement Number and the displayed Measurements
|
||||
includedTools.forEach(tool => {
|
||||
const collection = this[tool.id];
|
||||
const collection = this.tools[tool.id];
|
||||
const toolType = tool.cornerstoneToolType;
|
||||
const measurements = collection.find({toolType}).fetch();
|
||||
const groupObject = _.groupBy(measurements, m => m.measurementNumber);
|
||||
@ -217,7 +226,7 @@ class MeasurementApi {
|
||||
// Next, handle the overall measurement number.
|
||||
// First, handle data that has a measurement at baseline
|
||||
includedTools.forEach(tool => {
|
||||
const collection = this[tool.id];
|
||||
const collection = this.tools[tool.id];
|
||||
const toolType = tool.cornerstoneToolType;
|
||||
const measurements = hasDataAtTimepoint(collection, baselineTimepointId);
|
||||
const groupObject = _.groupBy(measurements, m => m.measurementNumber);
|
||||
@ -228,7 +237,7 @@ class MeasurementApi {
|
||||
// Next, handle New Measurements (i.e. no baseline data)
|
||||
// Note that this cannot be combined with the loop above due to the incrementing of the overallMeasurementNumber
|
||||
includedTools.forEach(tool => {
|
||||
const collection = this[tool.id];
|
||||
const collection = this.tools[tool.id];
|
||||
const toolType = tool.cornerstoneToolType;
|
||||
const measurements = hasNoDataAtTimepoint(collection, baselineTimepointId);
|
||||
const groupObject = _.groupBy(measurements, m => m.measurementNumber);
|
||||
@ -238,7 +247,7 @@ class MeasurementApi {
|
||||
}
|
||||
|
||||
deleteMeasurements(measurementTypeId, filter) {
|
||||
const collection = this[measurementTypeId];
|
||||
const collection = this.tools[measurementTypeId];
|
||||
|
||||
// Get the entries information before removing them
|
||||
const entries = collection.find(filter).fetch();
|
||||
@ -295,13 +304,13 @@ class MeasurementApi {
|
||||
}
|
||||
|
||||
fetch(measurementTypeId, selector, options) {
|
||||
if (!this[measurementTypeId]) {
|
||||
if (!this.tools[measurementTypeId]) {
|
||||
throw 'MeasurementApi: No Collection with the id: ' + measurementTypeId;
|
||||
}
|
||||
|
||||
selector = selector || {};
|
||||
options = options || {};
|
||||
return this[measurementTypeId].find(selector, options).fetch();
|
||||
return this.tools[measurementTypeId].find(selector, options).fetch();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@ class MeasurementHandlers {
|
||||
const measurementData = eventData.measurementData;
|
||||
const measurementToolConfiguration = config.measurementTools[index];
|
||||
const measurementApi = instance.data.measurementApi;
|
||||
const Collection = measurementApi[measurementToolConfiguration.id];
|
||||
const Collection = measurementApi.tools[measurementToolConfiguration.id];
|
||||
|
||||
// Get the Cornerstone imageId
|
||||
const enabledElement = cornerstone.getEnabledElement(eventData.element);
|
||||
@ -90,7 +90,7 @@ class MeasurementHandlers {
|
||||
|
||||
// TODO: Fix this it is a terrible workaround but we have a demo to do
|
||||
if (baseline) {
|
||||
measurementApi.sortMeasurements(baseline.timepointId);
|
||||
measurementApi.sortMeasurements(baseline.timepointId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -108,7 +108,7 @@ class MeasurementHandlers {
|
||||
|
||||
const measurementToolConfiguration = config.measurementTools[index];
|
||||
const measurementApi = instance.data.measurementApi;
|
||||
const Collection = measurementApi[measurementToolConfiguration.id];
|
||||
const Collection = measurementApi.tools[measurementToolConfiguration.id];
|
||||
|
||||
OHIF.log.info('CornerstoneToolsMeasurementModified');
|
||||
|
||||
@ -124,7 +124,7 @@ class MeasurementHandlers {
|
||||
// If the measurement configuration includes a value for Viewport,
|
||||
// we will populate this with the Cornerstone Viewport
|
||||
if (measurementToolConfiguration.schema.schema('viewport')) {
|
||||
measurement.viewport = cornerstone.getViewport(eventData.element);
|
||||
measurement.viewport = cornerstone.getViewport(eventData.element);
|
||||
}
|
||||
|
||||
// Clean the measurement according to the Schema
|
||||
@ -154,7 +154,7 @@ class MeasurementHandlers {
|
||||
|
||||
const measurementToolConfiguration = config.measurementTools[index];
|
||||
const measurementApi = instance.data.measurementApi;
|
||||
const Collection = measurementApi[measurementToolConfiguration.id];
|
||||
const Collection = measurementApi.tools[measurementToolConfiguration.id];
|
||||
|
||||
Collection.remove(measurementData._id);
|
||||
|
||||
|
||||
@ -3,13 +3,6 @@ import { Blaze } from 'meteor/blaze';
|
||||
import { _ } from 'meteor/underscore';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
const toolMap = {
|
||||
bidirectional: 'targets',
|
||||
targetCR: 'targets',
|
||||
targetUN: 'targets',
|
||||
targetEX: 'targets'
|
||||
};
|
||||
|
||||
OHIF.measurements.toggleLabelButton = options => {
|
||||
const removeButtonView = () => {
|
||||
if (!options.instance.buttonView) {
|
||||
@ -24,8 +17,8 @@ OHIF.measurements.toggleLabelButton = options => {
|
||||
removeButtonView();
|
||||
}
|
||||
|
||||
const tool = options.measurementTypeId || toolMap[options.toolType];
|
||||
const toolCollection = options.measurementApi[tool];
|
||||
const tool = options.toolType;
|
||||
const toolCollection = options.measurementApi.tools[tool];
|
||||
const measurement = toolCollection.findOne(options.measurementId);
|
||||
|
||||
const data = {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user