PWV-2: Exposing ohif:measurements package's lib functions on OHIF namespace
This commit is contained in:
parent
60aa1d0982
commit
5c5c2afb42
4
.jscsrc
4
.jscsrc
@ -35,8 +35,10 @@
|
|||||||
"disallowSpaceAfterObjectKeys": true,
|
"disallowSpaceAfterObjectKeys": true,
|
||||||
"disallowQuotedKeysInObjects": true,
|
"disallowQuotedKeysInObjects": true,
|
||||||
"disallowMultipleSpaces": true,
|
"disallowMultipleSpaces": true,
|
||||||
|
"disallowVar": true,
|
||||||
"validateLineBreaks": "LF",
|
"validateLineBreaks": "LF",
|
||||||
"validateIndentation": 4,
|
"validateIndentation": 4,
|
||||||
"validateQuoteMarks": { "mark": "'", "escape": true },
|
"validateQuoteMarks": { "mark": "'", "escape": true },
|
||||||
"validateParameterSeparator": ", "
|
"validateParameterSeparator": ", ",
|
||||||
|
"requireDollarBeforejQueryAssignment": true
|
||||||
}
|
}
|
||||||
19
.jshintrc
19
.jshintrc
@ -24,8 +24,8 @@
|
|||||||
// true : ensure whatever is used is consistent
|
// true : ensure whatever is used is consistent
|
||||||
// "single" : require single quotes
|
// "single" : require single quotes
|
||||||
// "double" : require double quotes
|
// "double" : require double quotes
|
||||||
"undef" : false, // true: Require all non-global variables to be declared (prevents global leaks)
|
"undef" : true, // true: Require all non-global variables to be declared (prevents global leaks)
|
||||||
"unused" : true, // Unused variables:
|
"unused" : "vars", // Unused variables:
|
||||||
// true : all variables, last function parameter
|
// true : all variables, last function parameter
|
||||||
// "vars" : all variables only
|
// "vars" : all variables only
|
||||||
// "strict" : all variables, all function parameters
|
// "strict" : all variables, all function parameters
|
||||||
@ -69,11 +69,11 @@
|
|||||||
"browser" : true, // Web Browser (window, document, etc)
|
"browser" : true, // Web Browser (window, document, etc)
|
||||||
"browserify" : false, // Browserify (node.js code in the browser)
|
"browserify" : false, // Browserify (node.js code in the browser)
|
||||||
"couch" : false, // CouchDB
|
"couch" : false, // CouchDB
|
||||||
"devel" : true, // Development/debugging (alert, confirm, etc)
|
"devel" : false, // Development/debugging (alert, confirm, etc)
|
||||||
"dojo" : false, // Dojo Toolkit
|
"dojo" : false, // Dojo Toolkit
|
||||||
"jasmine" : false, // Jasmine
|
"jasmine" : false, // Jasmine
|
||||||
"jquery" : true, // jQuery
|
"jquery" : true, // jQuery
|
||||||
"mocha" : true, // Mocha
|
"mocha" : false, // Mocha
|
||||||
"mootools" : false, // MooTools
|
"mootools" : false, // MooTools
|
||||||
"node" : false, // Node.js
|
"node" : false, // Node.js
|
||||||
"nonstandard" : false, // Widely adopted globals (escape, unescape, etc)
|
"nonstandard" : false, // Widely adopted globals (escape, unescape, etc)
|
||||||
@ -85,5 +85,14 @@
|
|||||||
"typed" : false, // Globals for typed array constructions
|
"typed" : false, // Globals for typed array constructions
|
||||||
"worker" : false, // Web Workers
|
"worker" : false, // Web Workers
|
||||||
"wsh" : false, // Windows Scripting Host
|
"wsh" : false, // Windows Scripting Host
|
||||||
"yui" : false // Yahoo User Interface
|
"yui" : false, // Yahoo User Interface
|
||||||
|
"globals" : {
|
||||||
|
"Package" : true, // Meteor Package definition
|
||||||
|
|
||||||
|
"cornerstone": true, // This group: cornerstone globals
|
||||||
|
"cornerstoneMath": true,
|
||||||
|
"cornerstoneTools": true,
|
||||||
|
"cornerstoneWADOImageLoader": true,
|
||||||
|
"dicomParser": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -1,5 +1,4 @@
|
|||||||
import { OHIF } from 'meteor/ohif:core';
|
import { OHIF } from 'meteor/ohif:core';
|
||||||
import { MeasurementHandlers } from 'meteor/ohif:measurements/client/lib/MeasurementHandlers';
|
|
||||||
|
|
||||||
Session.set('TimepointsReady', false);
|
Session.set('TimepointsReady', false);
|
||||||
Session.set('MeasurementsReady', false);
|
Session.set('MeasurementsReady', false);
|
||||||
@ -96,12 +95,12 @@ Template.viewer.helpers({
|
|||||||
|
|
||||||
Template.viewer.events({
|
Template.viewer.events({
|
||||||
'CornerstoneToolsMeasurementAdded .imageViewerViewport'(event, instance, eventData) {
|
'CornerstoneToolsMeasurementAdded .imageViewerViewport'(event, instance, eventData) {
|
||||||
MeasurementHandlers.onAdded(event, instance, eventData);
|
OHIF.measurements.MeasurementHandlers.onAdded(event, instance, eventData);
|
||||||
},
|
},
|
||||||
'CornerstoneToolsMeasurementModified .imageViewerViewport'(event, instance, eventData) {
|
'CornerstoneToolsMeasurementModified .imageViewerViewport'(event, instance, eventData) {
|
||||||
MeasurementHandlers.onModified(event, instance, eventData);
|
OHIF.measurements.MeasurementHandlers.onModified(event, instance, eventData);
|
||||||
},
|
},
|
||||||
'CornerstoneToolsMeasurementRemoved .imageViewerViewport'(event, instance, eventData) {
|
'CornerstoneToolsMeasurementRemoved .imageViewerViewport'(event, instance, eventData) {
|
||||||
MeasurementHandlers.onRemoved(event, instance, eventData);
|
OHIF.measurements.MeasurementHandlers.onRemoved(event, instance, eventData);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import { OHIF } from 'meteor/ohif:core';
|
import { OHIF } from 'meteor/ohif:core';
|
||||||
import { MeasurementsConfiguration } from 'meteor/ohif:measurements/both/configuration/measurements';
|
import { MeasurementsConfiguration } from 'meteor/ohif:measurements/both/configuration/measurements';
|
||||||
import { MeasurementHandlers } from 'meteor/ohif:measurements/client/lib/MeasurementHandlers';
|
|
||||||
|
|
||||||
Session.set('MeasurementsReady', false);
|
Session.set('MeasurementsReady', false);
|
||||||
|
|
||||||
@ -43,7 +42,7 @@ Template.viewer.onCreated(() => {
|
|||||||
Session.set('MeasurementsReady', true);
|
Session.set('MeasurementsReady', true);
|
||||||
|
|
||||||
instance.data.measurementApi.syncMeasurementsAndToolData();
|
instance.data.measurementApi.syncMeasurementsAndToolData();
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
Template.viewer.helpers({
|
Template.viewer.helpers({
|
||||||
@ -51,16 +50,16 @@ Template.viewer.helpers({
|
|||||||
// TODO: Find a better way to do this
|
// TODO: Find a better way to do this
|
||||||
return Session.get('MeasurementsReady');
|
return Session.get('MeasurementsReady');
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
Template.viewer.events({
|
Template.viewer.events({
|
||||||
'CornerstoneToolsMeasurementAdded .imageViewerViewport'(event, instance, eventData) {
|
'CornerstoneToolsMeasurementAdded .imageViewerViewport'(event, instance, eventData) {
|
||||||
MeasurementHandlers.onAdded(event, instance, eventData);
|
OHIF.measurements.MeasurementHandlers.onAdded(event, instance, eventData);
|
||||||
},
|
},
|
||||||
'CornerstoneToolsMeasurementModified .imageViewerViewport'(event, instance, eventData) {
|
'CornerstoneToolsMeasurementModified .imageViewerViewport'(event, instance, eventData) {
|
||||||
MeasurementHandlers.onModified(event, instance, eventData);
|
OHIF.measurements.MeasurementHandlers.onModified(event, instance, eventData);
|
||||||
},
|
},
|
||||||
'CornerstoneToolsMeasurementRemoved .imageViewerViewport'(event, instance, eventData) {
|
'CornerstoneToolsMeasurementRemoved .imageViewerViewport'(event, instance, eventData) {
|
||||||
MeasurementHandlers.onRemoved(event, instance, eventData);
|
OHIF.measurements.MeasurementHandlers.onRemoved(event, instance, eventData);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { MeasurementManager } from 'meteor/ohif:measurements/client/lib/MeasurementManager';
|
import { OHIF } from 'meteor/ohif:core';
|
||||||
|
|
||||||
function closeHandler(dialog) {
|
function closeHandler(dialog) {
|
||||||
// Hide the lesion dialog
|
// Hide the lesion dialog
|
||||||
@ -12,7 +12,6 @@ function closeHandler(dialog) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This event sets lesion number for new lesion
|
// This event sets lesion number for new lesion
|
||||||
|
|
||||||
function getSetLesionNumberCallbackFunction(measurementTypeId, measurementApi, timepointApi) {
|
function getSetLesionNumberCallbackFunction(measurementTypeId, measurementApi, timepointApi) {
|
||||||
return (measurementData, eventData, doneCallback) => {
|
return (measurementData, eventData, doneCallback) => {
|
||||||
// Get the current element's timepointId from the study date metadata
|
// Get the current element's timepointId from the study date metadata
|
||||||
@ -35,12 +34,12 @@ function getSetLesionNumberCallbackFunction(measurementTypeId, measurementApi, t
|
|||||||
// exists at a different timepoint
|
// exists at a different timepoint
|
||||||
const timepointId = timepoint.timepointId;
|
const timepointId = timepoint.timepointId;
|
||||||
const collection = measurementApi[measurementTypeId];
|
const collection = measurementApi[measurementTypeId];
|
||||||
const measurementNumber = MeasurementManager.getNewMeasurementNumber(timepointId, collection, timepointApi);
|
const measurementNumber = OHIF.measurements.MeasurementManager.getNewMeasurementNumber(timepointId, collection, timepointApi);
|
||||||
measurementData.measurementNumber = measurementNumber;
|
measurementData.measurementNumber = measurementNumber;
|
||||||
|
|
||||||
// Set lesion number
|
// Set lesion number
|
||||||
doneCallback(measurementNumber);
|
doneCallback(measurementNumber);
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// This event determines whether or not to show the lesion dialog
|
// This event determines whether or not to show the lesion dialog
|
||||||
@ -71,7 +70,7 @@ function getLesionLocationCallback(measurementData, eventData) {
|
|||||||
|
|
||||||
// Find out if this lesion number is already added in the lesion manager for another timepoint
|
// Find out if this lesion number is already added in the lesion manager for another timepoint
|
||||||
// If it is, stop here because we don't need the dialog.
|
// If it is, stop here because we don't need the dialog.
|
||||||
var locationUID = MeasurementManager.getLocationIdIfMeasurementExists(measurementData);
|
var locationUID = OHIF.measurements.MeasurementManager.getLocationIdIfMeasurementExists(measurementData);
|
||||||
if (locationUID) {
|
if (locationUID) {
|
||||||
// Add an ID value to the tool data to link it to the Measurements collection
|
// Add an ID value to the tool data to link it to the Measurements collection
|
||||||
measurementData.id = 'notready';
|
measurementData.id = 'notready';
|
||||||
@ -123,9 +122,9 @@ changeLesionLocationCallback = function(measurementData, eventData, doneCallback
|
|||||||
|
|
||||||
// Show/Hide Convert To NonTarget option in measurementLocationRelabelDialog
|
// Show/Hide Convert To NonTarget option in measurementLocationRelabelDialog
|
||||||
if (measurementData.toolType === 'bidirectional') {
|
if (measurementData.toolType === 'bidirectional') {
|
||||||
dialog.find("#convertToNonTarget").css("visibility", "visible");
|
dialog.find('#convertToNonTarget').css('visibility', 'visible');
|
||||||
} else {
|
} else {
|
||||||
dialog.find("#convertToNonTarget").css("visibility", "hidden");
|
dialog.find('#convertToNonTarget').css('visibility', 'hidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
Template.measurementLocationDialog.dialog = dialog;
|
Template.measurementLocationDialog.dialog = dialog;
|
||||||
@ -189,7 +188,6 @@ changeLesionLocationCallback = function(measurementData, eventData, doneCallback
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Template.measurementLocationDialog.onCreated(() => {
|
Template.measurementLocationDialog.onCreated(() => {
|
||||||
const instance = Template.instance();
|
const instance = Template.instance();
|
||||||
const measurementTypeId = 'targets';
|
const measurementTypeId = 'targets';
|
||||||
@ -268,7 +266,7 @@ Template.measurementLocationDialog.events({
|
|||||||
var measurementData = Template.measurementLocationDialog.measurementData;
|
var measurementData = Template.measurementLocationDialog.measurementData;
|
||||||
var dialog = Template.measurementLocationDialog.dialog;
|
var dialog = Template.measurementLocationDialog.dialog;
|
||||||
|
|
||||||
const instance = Template.instance()
|
const instance = Template.instance();
|
||||||
const measurementApi = instance.data.measurementApi;
|
const measurementApi = instance.data.measurementApi;
|
||||||
convertToNonTarget(measurementApi, measurementData);
|
convertToNonTarget(measurementApi, measurementData);
|
||||||
|
|
||||||
@ -290,7 +288,7 @@ Template.measurementLocationDialog.events({
|
|||||||
});
|
});
|
||||||
|
|
||||||
Template.measurementLocationDialog.helpers({
|
Template.measurementLocationDialog.helpers({
|
||||||
measurementLocations: function() {
|
measurementLocations() {
|
||||||
return LesionLocations.find();
|
return LesionLocations.find();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { MeasurementManager } from 'meteor/ohif:measurements/client/lib/MeasurementManager';
|
import { OHIF } from 'meteor/ohif:core';
|
||||||
|
|
||||||
function closeHandler(dialog) {
|
function closeHandler(dialog) {
|
||||||
// Hide the lesion dialog
|
// Hide the lesion dialog
|
||||||
@ -31,12 +31,12 @@ function getSetLesionNumberCallbackFunction(measurementTypeId, measurementApi, t
|
|||||||
// exists at a different timepoint
|
// exists at a different timepoint
|
||||||
const timepointId = timepoint.timepointId;
|
const timepointId = timepoint.timepointId;
|
||||||
const collection = measurementApi[measurementTypeId];
|
const collection = measurementApi[measurementTypeId];
|
||||||
const measurementNumber = MeasurementManager.getNewMeasurementNumber(timepointId, collection, timepointApi);
|
const measurementNumber = OHIF.measurements.MeasurementManager.getNewMeasurementNumber(timepointId, collection, timepointApi);
|
||||||
measurementData.measurementNumber = measurementNumber;
|
measurementData.measurementNumber = measurementNumber;
|
||||||
|
|
||||||
// Set lesion number
|
// Set lesion number
|
||||||
doneCallback(measurementNumber);
|
doneCallback(measurementNumber);
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectNonTargetResponse(responseCode) {
|
function selectNonTargetResponse(responseCode) {
|
||||||
@ -104,7 +104,7 @@ function getLesionLocationCallback(measurementData, eventData) {
|
|||||||
|
|
||||||
// Find out if this lesion number is already added in the lesion manager for another timepoint
|
// Find out if this lesion number is already added in the lesion manager for another timepoint
|
||||||
// If it is, disable selector location
|
// If it is, disable selector location
|
||||||
var locationId = MeasurementManager.getLocationIdIfMeasurementExists(measurementData);
|
var locationId = OHIF.measurements.MeasurementManager.getLocationIdIfMeasurementExists(measurementData);
|
||||||
if (locationId) {
|
if (locationId) {
|
||||||
// Add an ID value to the tool data to link it to the Measurements collection
|
// Add an ID value to the tool data to link it to the Measurements collection
|
||||||
measurementData.id = 'notready';
|
measurementData.id = 'notready';
|
||||||
@ -238,7 +238,6 @@ changeNonTargetLocationCallback = function(measurementData, eventData, doneCallb
|
|||||||
selectNonTargetResponse(response);
|
selectNonTargetResponse(response);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Template.nonTargetLesionDialog.onCreated(() => {
|
Template.nonTargetLesionDialog.onCreated(() => {
|
||||||
const instance = Template.instance();
|
const instance = Template.instance();
|
||||||
const measurementTypeId = 'nonTargets';
|
const measurementTypeId = 'nonTargets';
|
||||||
@ -297,7 +296,9 @@ Template.nonTargetLesionDialog.events({
|
|||||||
measurementData.isTarget = false;
|
measurementData.isTarget = false;
|
||||||
|
|
||||||
// Response is set from location response list
|
// Response is set from location response list
|
||||||
measurementData.response = LocationResponses.findOne({selected: true}).code;
|
measurementData.response = LocationResponses.findOne({
|
||||||
|
selected: true
|
||||||
|
}).code;
|
||||||
|
|
||||||
// Adds lesion data to timepoints array
|
// Adds lesion data to timepoints array
|
||||||
LesionManager.updateLesionData(measurementData);
|
LesionManager.updateLesionData(measurementData);
|
||||||
|
|||||||
@ -1,18 +0,0 @@
|
|||||||
/**
|
|
||||||
* Returns timepoint object given a specified imageId
|
|
||||||
*
|
|
||||||
* @param imageId
|
|
||||||
* @returns {*|{}} Timepoint object
|
|
||||||
*/
|
|
||||||
getTimepointObject = function(imageId) {
|
|
||||||
var study = cornerstoneTools.metaData.get('study', imageId);
|
|
||||||
if (!study) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Timepoints.findOne({
|
|
||||||
studyInstanceUids: {
|
|
||||||
$in: [study.studyInstanceUid]
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
@ -1,62 +0,0 @@
|
|||||||
import { OHIF } from 'meteor/ohif:core';
|
|
||||||
|
|
||||||
function toolDataExists(toolState, imageId, toolType) {
|
|
||||||
const currentToolState = toolState[imageId][toolType];
|
|
||||||
return (currentToolState && currentToolState.data && currentToolState.data.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
syncMeasurementAndToolData = function(measurement) {
|
|
||||||
OHIF.log.info('syncMeasurementAndToolData');
|
|
||||||
|
|
||||||
const toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.toolState;
|
|
||||||
const imageId = measurement.imageId;
|
|
||||||
const toolType = measurement.toolType;
|
|
||||||
|
|
||||||
// If no tool state exists for this imageId, create an empty object to store it
|
|
||||||
if (!toolState[imageId]) {
|
|
||||||
toolState[imageId] = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if we already have toolData for this imageId and toolType
|
|
||||||
if (toolDataExists(toolState, imageId, toolType)) {
|
|
||||||
// If we have toolData, we should search it for any toolData
|
|
||||||
// related to the current Measurement
|
|
||||||
const toolData = toolState[imageId][toolType].data;
|
|
||||||
|
|
||||||
// Create a flag so we know if we have successfully updated
|
|
||||||
// this Measurement's in the toolData
|
|
||||||
let alreadyExists = false;
|
|
||||||
|
|
||||||
// Loop through the toolData to search for this Measurement
|
|
||||||
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 have found the Measurement, set the flag to True
|
|
||||||
alreadyExists = true;
|
|
||||||
|
|
||||||
// Update the toolData from the Measurement data
|
|
||||||
$.extend(tool, measurement);
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
// If we have 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: []
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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.
|
|
||||||
|
|
||||||
// Add the MeasurementData into the toolData for this imageId
|
|
||||||
toolState[imageId][toolType].data.push(measurement);
|
|
||||||
};
|
|
||||||
@ -94,11 +94,8 @@ Package.onUse(function(api) {
|
|||||||
api.addFiles('lib/convertToNonTarget.js', 'client');
|
api.addFiles('lib/convertToNonTarget.js', 'client');
|
||||||
api.addFiles('lib/convertNonTarget.js', 'client');
|
api.addFiles('lib/convertNonTarget.js', 'client');
|
||||||
|
|
||||||
api.addFiles('lib/syncMeasurementAndToolData.js', 'client');
|
|
||||||
|
|
||||||
// Export global functions
|
// Export global functions
|
||||||
api.export('pixelSpacingAutorunCheck', 'client');
|
api.export('pixelSpacingAutorunCheck', 'client');
|
||||||
api.export('syncMeasurementAndToolData', 'client');
|
|
||||||
api.export('syncImageMeasurementAndToolData', 'client');
|
api.export('syncImageMeasurementAndToolData', 'client');
|
||||||
api.export('openNewTabWithTimepoint', 'client');
|
api.export('openNewTabWithTimepoint', 'client');
|
||||||
api.export('toggleLesionTrackerTools', 'client');
|
api.export('toggleLesionTrackerTools', 'client');
|
||||||
|
|||||||
@ -42,8 +42,8 @@ class MeasurementApi {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
retrievalFn().then(measurementData => {
|
retrievalFn().then(measurementData => {
|
||||||
|
|
||||||
console.log('Measurement data retrieval');
|
OHIF.log.info('Measurement data retrieval');
|
||||||
console.log(measurementData);
|
OHIF.log.info(measurementData);
|
||||||
|
|
||||||
Object.keys(measurementData).forEach(measurementTypeId => {
|
Object.keys(measurementData).forEach(measurementTypeId => {
|
||||||
const measurements = measurementData[measurementTypeId];
|
const measurements = measurementData[measurementTypeId];
|
||||||
@ -72,7 +72,7 @@ class MeasurementApi {
|
|||||||
});
|
});
|
||||||
|
|
||||||
storeFn(measurementData).then(() => {
|
storeFn(measurementData).then(() => {
|
||||||
console.log('Measurement storage completed');
|
OHIF.log.info('Measurement storage completed');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ class MeasurementApi {
|
|||||||
this.config.measurementTools.forEach(tool => {
|
this.config.measurementTools.forEach(tool => {
|
||||||
const measurements = this[tool.id].find().fetch();
|
const measurements = this[tool.id].find().fetch();
|
||||||
measurements.forEach(measurement => {
|
measurements.forEach(measurement => {
|
||||||
syncMeasurementAndToolData(measurement);
|
OHIF.measurements.syncMeasurementAndToolData(measurement);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,8 +36,8 @@ class TimepointApi {
|
|||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
retrievalFn().then(timepointData => {
|
retrievalFn().then(timepointData => {
|
||||||
console.log('Timepoint data retrieval');
|
OHIF.log.info('Timepoint data retrieval');
|
||||||
console.log(timepointData);
|
OHIF.log.info(timepointData);
|
||||||
_.each(timepointData, timepoint => {
|
_.each(timepointData, timepoint => {
|
||||||
delete timepoint._id;
|
delete timepoint._id;
|
||||||
this.timepoints.insert(timepoint);
|
this.timepoints.insert(timepoint);
|
||||||
@ -55,12 +55,10 @@ class TimepointApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const timepointData = this.timepoints.find().fetch();
|
const timepointData = this.timepoints.find().fetch();
|
||||||
console.log('Preparing to store timepoints');
|
OHIF.log.info('Preparing to store timepoints');
|
||||||
console.log(JSON.stringify(timepointData, null, 2));
|
OHIF.log.info(JSON.stringify(timepointData, null, 2));
|
||||||
|
|
||||||
storeFn(timepointData).then(() => {
|
storeFn(timepointData).then(() => OHIF.log.info('Timepoint storage completed'));
|
||||||
console.log('Timepoint storage completed');
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return all timepoints
|
// Return all timepoints
|
||||||
@ -77,6 +75,11 @@ class TimepointApi {
|
|||||||
|
|
||||||
// Return the prior timepoint
|
// Return the prior timepoint
|
||||||
lock() {
|
lock() {
|
||||||
|
const current = this.current();
|
||||||
|
if (!current) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.timepoints.update(current._id, {
|
this.timepoints.update(current._id, {
|
||||||
$set: {
|
$set: {
|
||||||
locked: true
|
locked: true
|
||||||
@ -169,7 +172,7 @@ class TimepointApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve all of the relevant follow-up timepoints for this patient
|
// Retrieve all of the relevant follow-up timepoints for this patient
|
||||||
var followupTimepoints = this.timepoints.find({
|
const followupTimepoints = this.timepoints.find({
|
||||||
patientId: timepoint.patientId,
|
patientId: timepoint.patientId,
|
||||||
timepointType: timepoint.timepointType
|
timepointType: timepoint.timepointType
|
||||||
}, {
|
}, {
|
||||||
@ -180,13 +183,11 @@ class TimepointApi {
|
|||||||
|
|
||||||
// Create an array of just timepointIds, so we can use indexOf
|
// Create an array of just timepointIds, so we can use indexOf
|
||||||
// on it to find the current timepoint's relative position
|
// on it to find the current timepoint's relative position
|
||||||
var followupTimepointIds = followupTimepoints.map(function(timepoint) {
|
const followupTimepointIds = followupTimepoints.map(timepoint => timepoint.timepointId);
|
||||||
return timepoint.timepointId;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Calculate the index of the current timepoint in the array of all
|
// Calculate the index of the current timepoint in the array of all
|
||||||
// relevant follow-up timepoints
|
// relevant follow-up timepoints
|
||||||
var index = followupTimepointIds.indexOf(timepoint.timepointId) + 1;
|
const index = followupTimepointIds.indexOf(timepoint.timepointId) + 1;
|
||||||
|
|
||||||
// If index is 0, it means that the current timepoint was not in the list
|
// If index is 0, it means that the current timepoint was not in the list
|
||||||
// Log a warning and return here
|
// Log a warning and return here
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
import { Template } from 'meteor/templating';
|
||||||
|
|
||||||
import { OHIF } from 'meteor/ohif:core';
|
import { OHIF } from 'meteor/ohif:core';
|
||||||
|
|
||||||
// Get the current measurement API configuration with information about tools, data exchange
|
// Get the current measurement API configuration with information about tools, data exchange
|
||||||
|
|||||||
@ -1,4 +1,2 @@
|
|||||||
import './lib';
|
import './lib';
|
||||||
import './helpers';
|
import './helpers';
|
||||||
// import './components';
|
|
||||||
// import './ui';
|
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
|
import { Meteor } from 'meteor/meteor';
|
||||||
|
import { $ } from 'meteor/jquery';
|
||||||
|
|
||||||
import { OHIF } from 'meteor/ohif:core';
|
import { OHIF } from 'meteor/ohif:core';
|
||||||
import { MeasurementManager } from 'meteor/ohif:measurements/client/lib/MeasurementManager';
|
|
||||||
|
|
||||||
let MeasurementHandlers = {};
|
class MeasurementHandlers {
|
||||||
|
|
||||||
MeasurementHandlers.onAdded = (e, instance, eventData) => {
|
static onAdded(e, instance, eventData) {
|
||||||
const measurementData = eventData.measurementData;
|
const measurementData = eventData.measurementData;
|
||||||
|
|
||||||
const config = OHIF.measurements.MeasurementApi.getConfiguration();
|
const config = OHIF.measurements.MeasurementApi.getConfiguration();
|
||||||
const toolTypes = config.measurementTools.map(tool => {
|
const toolTypes = config.measurementTools.map(tool => tool.cornerstoneToolType);
|
||||||
return tool.cornerstoneToolType;
|
|
||||||
});
|
|
||||||
|
|
||||||
const index = toolTypes.indexOf(eventData.toolType);
|
const index = toolTypes.indexOf(eventData.toolType);
|
||||||
if (index === -1) {
|
if (index === -1) {
|
||||||
@ -55,7 +55,7 @@ MeasurementHandlers.onAdded = (e, instance, eventData) => {
|
|||||||
const timepoint = timepointApi.study(studyInstanceUid)[0];
|
const timepoint = timepointApi.study(studyInstanceUid)[0];
|
||||||
const timepointId = timepoint.timepointId;
|
const timepointId = timepoint.timepointId;
|
||||||
measurement.timepointId = timepointId;
|
measurement.timepointId = timepointId;
|
||||||
measurement.measurementNumber = MeasurementManager.getNewMeasurementNumber(timepointId, Collection, timepointApi);
|
measurement.measurementNumber = OHIF.measurements.MeasurementManager.getNewMeasurementNumber(timepointId, Collection, timepointApi);
|
||||||
|
|
||||||
// TODO: Fix this
|
// TODO: Fix this
|
||||||
measurement.measurementNumberAbsolute = measurement.measurementNumber;
|
measurement.measurementNumberAbsolute = measurement.measurementNumber;
|
||||||
@ -71,15 +71,13 @@ MeasurementHandlers.onAdded = (e, instance, eventData) => {
|
|||||||
|
|
||||||
// Insert the new measurement into the collection
|
// Insert the new measurement into the collection
|
||||||
measurementData.id = Collection.insert(measurement);
|
measurementData.id = Collection.insert(measurement);
|
||||||
};
|
}
|
||||||
|
|
||||||
MeasurementHandlers.onModified = (e, instance, eventData) => {
|
static onModified(e, instance, eventData) {
|
||||||
const measurementData = eventData.measurementData;
|
const measurementData = eventData.measurementData;
|
||||||
|
|
||||||
const config = MeasurementApi.getConfiguration();
|
const config = OHIF.measurements.MeasurementApi.getConfiguration();
|
||||||
const toolTypes = config.measurementTools.map(tool => {
|
const toolTypes = config.measurementTools.map(tool => tool.cornerstoneToolType);
|
||||||
return tool.cornerstoneToolType;
|
|
||||||
});
|
|
||||||
|
|
||||||
const index = toolTypes.indexOf(eventData.toolType);
|
const index = toolTypes.indexOf(eventData.toolType);
|
||||||
if (index === -1) {
|
if (index === -1) {
|
||||||
@ -90,31 +88,13 @@ MeasurementHandlers.onModified = (e, instance, eventData) => {
|
|||||||
const measurementApi = instance.data.measurementApi;
|
const measurementApi = instance.data.measurementApi;
|
||||||
const Collection = measurementApi[measurementToolConfiguration.id];
|
const Collection = measurementApi[measurementToolConfiguration.id];
|
||||||
|
|
||||||
// Get the Cornerstone imageId
|
|
||||||
const enabledElement = cornerstone.getEnabledElement(eventData.element);
|
|
||||||
const imageId = enabledElement.image.imageId;
|
|
||||||
|
|
||||||
// Get studyInstanceUid & patientId
|
|
||||||
const study = cornerstoneTools.metaData.get('study', imageId);
|
|
||||||
const studyInstanceUid = study.studyInstanceUid;
|
|
||||||
const patientId = study.patientId;
|
|
||||||
|
|
||||||
// Get seriesInstanceUid
|
|
||||||
const series = cornerstoneTools.metaData.get('series', imageId);
|
|
||||||
const seriesInstanceUid = series.seriesInstanceUid;
|
|
||||||
|
|
||||||
// Get sopInstanceUid
|
|
||||||
const sopInstance = cornerstoneTools.metaData.get('instance', imageId);
|
|
||||||
const sopInstanceUid = sopInstance.sopInstanceUid;
|
|
||||||
const frameIndex = sopInstance.frame || 0;
|
|
||||||
|
|
||||||
OHIF.log.info('CornerstoneToolsMeasurementModified');
|
OHIF.log.info('CornerstoneToolsMeasurementModified');
|
||||||
|
|
||||||
let measurement = Collection.findOne(measurementData.id);
|
let measurement = Collection.findOne(measurementData.id);
|
||||||
|
|
||||||
Object.keys(measurementData).forEach(key => {
|
Object.keys(measurementData).forEach(key => {
|
||||||
measurement[key] = measurementData[key];
|
measurement[key] = measurementData[key];
|
||||||
})
|
});
|
||||||
|
|
||||||
const measurementId = measurement._id;
|
const measurementId = measurement._id;
|
||||||
delete measurement._id;
|
delete measurement._id;
|
||||||
@ -126,15 +106,13 @@ MeasurementHandlers.onModified = (e, instance, eventData) => {
|
|||||||
Collection.update(measurementId, {
|
Collection.update(measurementId, {
|
||||||
$set: measurement
|
$set: measurement
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
MeasurementHandlers.onRemoved = (e, instance, eventData) => {
|
static onRemoved(e, instance, eventData) {
|
||||||
const measurementData = eventData.measurementData;
|
const measurementData = eventData.measurementData;
|
||||||
|
|
||||||
const config = OHIF.measurements.MeasurementApi.getConfiguration();
|
const config = OHIF.measurements.MeasurementApi.getConfiguration();
|
||||||
const toolTypes = config.measurementTools.map(tool => {
|
const toolTypes = config.measurementTools.map(tool => tool.cornerstoneToolType);
|
||||||
return tool.cornerstoneToolType;
|
|
||||||
});
|
|
||||||
|
|
||||||
const index = toolTypes.indexOf(measurementData.toolType);
|
const index = toolTypes.indexOf(measurementData.toolType);
|
||||||
if (index === -1) {
|
if (index === -1) {
|
||||||
@ -148,6 +126,8 @@ MeasurementHandlers.onRemoved = (e, instance, eventData) => {
|
|||||||
const Collection = measurementApi[measurementToolConfiguration.id];
|
const Collection = measurementApi[measurementToolConfiguration.id];
|
||||||
|
|
||||||
Collection.remove(measurementData.id);
|
Collection.remove(measurementData.id);
|
||||||
};
|
}
|
||||||
|
|
||||||
export { MeasurementHandlers };
|
}
|
||||||
|
|
||||||
|
OHIF.measurements.MeasurementHandlers = MeasurementHandlers;
|
||||||
|
|||||||
@ -1,10 +1,14 @@
|
|||||||
|
import { OHIF } from 'meteor/ohif:core';
|
||||||
|
|
||||||
|
class MeasurementManager {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns new measurement number given a timepointId
|
* Returns new measurement number given a timepointId
|
||||||
* @param timepointId
|
* @param timepointId
|
||||||
* @param isTarget
|
* @param isTarget
|
||||||
* @returns {*}
|
* @returns {number} - Number of measurements in timepoint
|
||||||
*/
|
*/
|
||||||
function getNewMeasurementNumber(timepointId, Collection, timepointApi) {
|
static getNewMeasurementNumber(timepointId, Collection, timepointApi) {
|
||||||
// Get all current lesion measurements
|
// Get all current lesion measurements
|
||||||
const numMeasurements = Collection.find().count();
|
const numMeasurements = Collection.find().count();
|
||||||
|
|
||||||
@ -13,7 +17,10 @@ function getNewMeasurementNumber(timepointId, Collection, timepointApi) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const timepoint = timepointApi.timepoints.findOne({timepointId: timepointId});
|
const timepoint = timepointApi.timepoints.findOne({
|
||||||
|
timepointId: timepointId
|
||||||
|
});
|
||||||
|
|
||||||
const numMeasurementsAtTimepoint = Collection.find({
|
const numMeasurementsAtTimepoint = Collection.find({
|
||||||
studyInstanceUid: {
|
studyInstanceUid: {
|
||||||
$in: timepoint.studyInstanceUids
|
$in: timepoint.studyInstanceUids
|
||||||
@ -27,9 +34,9 @@ function getNewMeasurementNumber(timepointId, Collection, timepointApi) {
|
|||||||
* 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
|
||||||
* @param measurementData
|
* @param measurementData
|
||||||
* @returns {*}
|
* @returns {number} - Measurement location ID
|
||||||
*/
|
*/
|
||||||
function getLocationIdIfMeasurementExists(measurementData, Collection) {
|
static getLocationIdIfMeasurementExists(measurementData, Collection) {
|
||||||
const measurement = Collection.findOne({
|
const measurement = Collection.findOne({
|
||||||
measurementNumber: measurementData.measurementNumber
|
measurementNumber: measurementData.measurementNumber
|
||||||
});
|
});
|
||||||
@ -41,7 +48,6 @@ function getLocationIdIfMeasurementExists(measurementData, Collection) {
|
|||||||
return measurement.locationId;
|
return measurement.locationId;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const MeasurementManager = {
|
}
|
||||||
getNewMeasurementNumber: getNewMeasurementNumber,
|
|
||||||
getLocationIdIfMeasurementExists: getLocationIdIfMeasurementExists
|
OHIF.measurements.MeasurementManager = MeasurementManager;
|
||||||
};
|
|
||||||
|
|||||||
@ -76,7 +76,7 @@ OHIF.measurements.activateLesion = (measurementId, templateData) => {
|
|||||||
const measurementAtTimepoint = orderedTimepointEntries[viewportIndex];
|
const measurementAtTimepoint = orderedTimepointEntries[viewportIndex];
|
||||||
|
|
||||||
// Find the image that is currently in this viewport
|
// Find the image that is currently in this viewport
|
||||||
var enabledElement = cornerstone.getEnabledElement(element);
|
const enabledElement = cornerstone.getEnabledElement(element);
|
||||||
if (!enabledElement || !enabledElement.image) {
|
if (!enabledElement || !enabledElement.image) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -111,7 +111,7 @@ OHIF.measurements.activateLesion = (measurementId, templateData) => {
|
|||||||
|
|
||||||
// Otherwise, re-render the viewport with the required study/series, then
|
// Otherwise, re-render the viewport with the required study/series, then
|
||||||
// add an onRendered callback to activate the measurements
|
// add an onRendered callback to activate the measurements
|
||||||
layoutManager.rerenderViewportWithNewDisplaySet(element, requiredSeriesData, element => {
|
window.layoutManager.rerenderViewportWithNewDisplaySet(element, requiredSeriesData, element => {
|
||||||
activateMeasurements(element, measurementId, templateData, viewportIndex);
|
activateMeasurements(element, measurementId, templateData, viewportIndex);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -11,7 +11,7 @@ OHIF.measurements.activateMeasurements = (element, measurementId, templateData,
|
|||||||
|
|
||||||
const enabledElement = cornerstone.getEnabledElement(element);
|
const enabledElement = cornerstone.getEnabledElement(element);
|
||||||
const imageId = enabledElement.image.imageId;
|
const imageId = enabledElement.image.imageId;
|
||||||
const timepointData = getTimepointObject(imageId);
|
const timepointData = OHIF.measurements.getTimepointObject(imageId);
|
||||||
const measurementData = Measurements.findOne(measurementId);
|
const measurementData = Measurements.findOne(measurementId);
|
||||||
|
|
||||||
if (!timepointData) {
|
if (!timepointData) {
|
||||||
@ -27,7 +27,7 @@ OHIF.measurements.activateMeasurements = (element, measurementId, templateData,
|
|||||||
// If type is inactive, update lesions of enabledElement as inactive
|
// If type is inactive, update lesions of enabledElement as inactive
|
||||||
//TODO: !stackData.currentImageIdIndex returns incorrect value
|
//TODO: !stackData.currentImageIdIndex returns incorrect value
|
||||||
// Get loadedSeriesData currentImageIdIndex from ViewerData
|
// Get loadedSeriesData currentImageIdIndex from ViewerData
|
||||||
const viewerData = ViewerData[templateData.contentId];
|
const viewerData = window.ViewerData[templateData.contentId];
|
||||||
const loadedSeriesData = viewerData.loadedSeriesData[viewportIndex];
|
const loadedSeriesData = viewerData.loadedSeriesData[viewportIndex];
|
||||||
const elementCurrentImageIdIndex = loadedSeriesData.currentImageIdIndex;
|
const elementCurrentImageIdIndex = loadedSeriesData.currentImageIdIndex;
|
||||||
|
|
||||||
|
|||||||
@ -17,23 +17,23 @@ OHIF.measurements.activateTool = (element, measurementData, timepointId) => {
|
|||||||
OHIF.measurements.deactivateAllToolData(element, 'unTool');
|
OHIF.measurements.deactivateAllToolData(element, 'unTool');
|
||||||
OHIF.measurements.deactivateAllToolData(element, 'exTool');
|
OHIF.measurements.deactivateAllToolData(element, 'exTool');
|
||||||
|
|
||||||
var toolType = measurementData.toolType;
|
const toolType = measurementData.toolType;
|
||||||
var toolData = cornerstoneTools.getToolState(element, toolType);
|
const toolData = cornerstoneTools.getToolState(element, toolType);
|
||||||
if (!toolData) {
|
if (!toolData) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var measurementAtTimepoint = measurementData.timepoints[timepointId];
|
const measurementAtTimepoint = measurementData.timepoints[timepointId];
|
||||||
|
|
||||||
for (var i = 0; i < toolData.data.length; i++) {
|
for (let i = 0; i < toolData.data.length; i++) {
|
||||||
data = toolData.data[i];
|
const data = toolData.data[i];
|
||||||
|
|
||||||
// When click a row of table measurements, measurement will be active and color will be green
|
// When click a row of table measurements, measurement will be active and color will be green
|
||||||
// TODO= Remove this with the measurementId once it is in the tool data
|
// TODO= Remove this with the measurementId once it is in the tool data
|
||||||
if (data.seriesInstanceUid === measurementAtTimepoint.seriesInstanceUid &&
|
if (data.seriesInstanceUid === measurementAtTimepoint.seriesInstanceUid &&
|
||||||
data.studyInstanceUid === measurementAtTimepoint.studyInstanceUid &&
|
data.studyInstanceUid === measurementAtTimepoint.studyInstanceUid &&
|
||||||
data.lesionNumber === measurementData.lesionNumber &&
|
data.lesionNumber === measurementData.lesionNumber &&
|
||||||
data.isTarget == measurementData.isTarget) {
|
data.isTarget === measurementData.isTarget) {
|
||||||
|
|
||||||
data.active = true;
|
data.active = true;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -8,13 +8,12 @@ import { OHIF } from 'meteor/ohif:core';
|
|||||||
* @param toolType The tooltype of the tools that will be deactivated
|
* @param toolType The tooltype of the tools that will be deactivated
|
||||||
*/
|
*/
|
||||||
OHIF.measurements.deactivateAllToolData = (element, toolType) => {
|
OHIF.measurements.deactivateAllToolData = (element, toolType) => {
|
||||||
var toolData = cornerstoneTools.getToolState(element, toolType);
|
const toolData = cornerstoneTools.getToolState(element, toolType);
|
||||||
if (!toolData) {
|
if (!toolData) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < toolData.data.length; i++) {
|
for (let i = 0; i < toolData.data.length; i++) {
|
||||||
var data = toolData.data[i];
|
toolData.data[i].active = false;
|
||||||
data.active = false;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -8,14 +8,14 @@ import { OHIF } from 'meteor/ohif:core';
|
|||||||
* @param timepoint
|
* @param timepoint
|
||||||
* @returns {*} The timepoint name
|
* @returns {*} The timepoint name
|
||||||
*/
|
*/
|
||||||
OHIF.measurements.getTimepointName = (timepoint) => {
|
OHIF.measurements.getTimepointName = timepoint => {
|
||||||
// Check if this is a Baseline timepoint, if it is, return 'Baseline'
|
// Check if this is a Baseline timepoint, if it is, return 'Baseline'
|
||||||
if (timepoint.timepointType === 'baseline') {
|
if (timepoint.timepointType === 'baseline') {
|
||||||
return 'Baseline';
|
return 'Baseline';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve all of the relevant follow-up timepoints for this patient
|
// Retrieve all of the relevant follow-up timepoints for this patient
|
||||||
var followupTimepoints = Timepoints.find({
|
const followupTimepoints = Timepoints.find({
|
||||||
patientId: timepoint.patientId,
|
patientId: timepoint.patientId,
|
||||||
timepointType: timepoint.timepointType
|
timepointType: timepoint.timepointType
|
||||||
}, {
|
}, {
|
||||||
@ -26,13 +26,11 @@ OHIF.measurements.getTimepointName = (timepoint) => {
|
|||||||
|
|
||||||
// Create an array of just timepointIds, so we can use indexOf
|
// Create an array of just timepointIds, so we can use indexOf
|
||||||
// on it to find the current timepoint's relative position
|
// on it to find the current timepoint's relative position
|
||||||
var followupTimepointIds = followupTimepoints.map(function(timepoint) {
|
const followupTimepointIds = followupTimepoints.map(timepoint => timepoint.timepointId);
|
||||||
return timepoint.timepointId;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Calculate the index of the current timepoint in the array of all
|
// Calculate the index of the current timepoint in the array of all
|
||||||
// relevant follow-up timepoints
|
// relevant follow-up timepoints
|
||||||
var index = followupTimepointIds.indexOf(timepoint.timepointId) + 1;
|
const index = followupTimepointIds.indexOf(timepoint.timepointId) + 1;
|
||||||
|
|
||||||
// If index is 0, it means that the current timepoint was not in the list
|
// If index is 0, it means that the current timepoint was not in the list
|
||||||
// Log a warning and return here
|
// Log a warning and return here
|
||||||
|
|||||||
@ -1,11 +1,13 @@
|
|||||||
|
import { OHIF } from 'meteor/ohif:core';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns timepoint object given a specified imageId
|
* Returns timepoint object given a specified imageId
|
||||||
*
|
*
|
||||||
* @param imageId
|
* @param imageId
|
||||||
* @returns {*|{}} Timepoint object
|
* @returns {*|{}} Timepoint object
|
||||||
*/
|
*/
|
||||||
getTimepointObject = function(imageId) {
|
OHIF.measurements.getTimepointObject = imageId => {
|
||||||
var study = cornerstoneTools.metaData.get('study', imageId);
|
const study = cornerstoneTools.metaData.get('study', imageId);
|
||||||
if (!study) {
|
if (!study) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
|
import { Template } from 'meteor/templating';
|
||||||
|
|
||||||
// TODO: [LT-refactor] move this to ohif:hanging-protocols package
|
// TODO: [LT-refactor] move this to ohif:hanging-protocols package
|
||||||
|
|
||||||
getTimepointType = function(study) {
|
const getTimepointType = study => {
|
||||||
const timepointApi = Template.instance().timepointApi;
|
const timepointApi = Template.instance().timepointApi;
|
||||||
if (!timepointApi) {
|
if (!timepointApi) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -1,11 +1,8 @@
|
|||||||
|
import { $ } from 'meteor/jquery';
|
||||||
|
|
||||||
import { OHIF } from 'meteor/ohif:core';
|
import { OHIF } from 'meteor/ohif:core';
|
||||||
|
|
||||||
function toolDataExists(toolState, imageId, toolType) {
|
OHIF.measurements.syncMeasurementAndToolData = measurement => {
|
||||||
const currentToolState = toolState[imageId][toolType];
|
|
||||||
return (currentToolState && currentToolState.data && currentToolState.data.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
syncMeasurementAndToolData = function(measurement) {
|
|
||||||
OHIF.log.info('syncMeasurementAndToolData');
|
OHIF.log.info('syncMeasurementAndToolData');
|
||||||
|
|
||||||
const toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.toolState;
|
const toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.toolState;
|
||||||
@ -17,18 +14,19 @@ syncMeasurementAndToolData = function(measurement) {
|
|||||||
toolState[imageId] = {};
|
toolState[imageId] = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const currentToolState = toolState[imageId][toolType];
|
||||||
|
const toolData = currentToolState && currentToolState.data;
|
||||||
|
|
||||||
// Check if we already have toolData for this imageId and toolType
|
// Check if we already have toolData for this imageId and toolType
|
||||||
if (toolDataExists(toolState, imageId, toolType)) {
|
if (toolData && toolData.length) {
|
||||||
// If we have toolData, we should search it for any toolData
|
// If we have toolData, we should search it for any data related to the current Measurement
|
||||||
// related to the current Measurement
|
|
||||||
const toolData = toolState[imageId][toolType].data;
|
const toolData = toolState[imageId][toolType].data;
|
||||||
|
|
||||||
// Create a flag so we know if we have successfully updated
|
// Create a flag so we know if we've successfully updated the Measurement in the toolData
|
||||||
// this Measurement's in the toolData
|
|
||||||
let alreadyExists = false;
|
let alreadyExists = false;
|
||||||
|
|
||||||
// Loop through the toolData to search for this Measurement
|
// Loop through the toolData to search for this Measurement
|
||||||
toolData.forEach(function(tool) {
|
toolData.forEach(tool => {
|
||||||
// Break the loop if this isn't the Measurement we are looking for
|
// Break the loop if this isn't the Measurement we are looking for
|
||||||
if (tool._id !== measurement._id) {
|
if (tool._id !== measurement._id) {
|
||||||
return;
|
return;
|
||||||
@ -42,8 +40,7 @@ syncMeasurementAndToolData = function(measurement) {
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
// If we have found the Measurement we intended to update, we can stop
|
// If we have found the Measurement we intended to update, we can stop this function here
|
||||||
// this function here
|
|
||||||
if (alreadyExists === true) {
|
if (alreadyExists === true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -54,8 +51,8 @@ syncMeasurementAndToolData = function(measurement) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have reached this point, it means we haven't found the Measurement we are
|
// If we have reached this point, it means we haven't found the Measurement we are looking for
|
||||||
// looking for in the current toolData. This means we need to add it.
|
// in the current toolData. This means we need to add it.
|
||||||
|
|
||||||
// Add the MeasurementData into the toolData for this imageId
|
// Add the MeasurementData into the toolData for this imageId
|
||||||
toolState[imageId][toolType].data.push(measurement);
|
toolState[imageId][toolType].data.push(measurement);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user