Removing imageId from Measurement schema
This commit is contained in:
parent
cf9136447e
commit
7bb25ae6aa
@ -223,7 +223,9 @@ function validateSingleMeasurement(measurementData) {
|
|||||||
}).map(function(criteria) {
|
}).map(function(criteria) {
|
||||||
return criteria.id;
|
return criteria.id;
|
||||||
});
|
});
|
||||||
var currentConstraints = OHIF.lesiontracker.getTrialCriteriaConstraints(criteriaTypes, measurementData.imageId);
|
|
||||||
|
const imageId = OHIF.viewerbase.getImageIdForImagePath(measurementData.imagePath);
|
||||||
|
var currentConstraints = OHIF.lesiontracker.getTrialCriteriaConstraints(criteriaTypes, imageId);
|
||||||
|
|
||||||
// If we have no relevant constraints, stop here
|
// If we have no relevant constraints, stop here
|
||||||
if (!currentConstraints) {
|
if (!currentConstraints) {
|
||||||
@ -320,7 +322,8 @@ function validateAll() {
|
|||||||
currentMeasurement._id = measurement._id;
|
currentMeasurement._id = measurement._id;
|
||||||
|
|
||||||
// Criteria for the specific image are retrieved from the general set of criteria.
|
// Criteria for the specific image are retrieved from the general set of criteria.
|
||||||
var currentConstraints = OHIF.lesiontracker.getTrialCriteriaConstraints(criteriaTypes, currentMeasurement.imageId);
|
const imageId = OHIF.viewerbase.getImageIdForImagePath(currentMeasurement.imagePath);
|
||||||
|
var currentConstraints = OHIF.lesiontracker.getTrialCriteriaConstraints(criteriaTypes, imageId);
|
||||||
if (!currentConstraints) {
|
if (!currentConstraints) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -318,8 +318,9 @@ class MeasurementApi {
|
|||||||
const toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.saveToolState();
|
const toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.saveToolState();
|
||||||
|
|
||||||
_.each(entries, entry => {
|
_.each(entries, entry => {
|
||||||
if (toolState[entry.imageId]) {
|
const imageId = OHIF.viewerbase.getImageIdForImagePath(entry.imagePath);
|
||||||
const toolData = toolState[entry.imageId][entry.toolType];
|
if (toolState[imageId]) {
|
||||||
|
const toolData = toolState[imageId][entry.toolType];
|
||||||
const measurementsData = toolData && toolData.data;
|
const measurementsData = toolData && toolData.data;
|
||||||
const measurementEntry = _.findWhere(measurementsData, {
|
const measurementEntry = _.findWhere(measurementsData, {
|
||||||
_id: entry._id
|
_id: entry._id
|
||||||
|
|||||||
@ -177,11 +177,9 @@ const FrameLevelMeasurement = new SimpleSchema([
|
|||||||
min: 0,
|
min: 0,
|
||||||
label: 'Frame index in Instance'
|
label: 'Frame index in Instance'
|
||||||
},
|
},
|
||||||
// TODO: In the future we should remove this in favour of searching OHIF.viewer.Studies and display sets when
|
imagePath: {
|
||||||
// re-displaying measurements. Otherwise if a study moves servers the measurements will not be displayed correctly
|
|
||||||
imageId: {
|
|
||||||
type: String,
|
type: String,
|
||||||
label: 'Cornerstone Image Id'
|
label: 'Identifier for the measurement\'s image' // studyInstanceUid_seriesInstanceUid_sopInstanceUid_frameIndex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|||||||
@ -145,7 +145,8 @@ class ConformanceCriteria {
|
|||||||
const measurements = this.measurementApi.fetch(measurementType);
|
const measurements = this.measurementApi.fetch(measurementType);
|
||||||
|
|
||||||
measurements.forEach(measurement => {
|
measurements.forEach(measurement => {
|
||||||
const { studyInstanceUid, imageId } = measurement;
|
const imageId = OHIF.viewerbase.getImageIdForImagePath(measurement.imagePath);
|
||||||
|
const { studyInstanceUid } = measurement;
|
||||||
|
|
||||||
const timepointId = measurement.timepointId;
|
const timepointId = measurement.timepointId;
|
||||||
const timepoint = timepointId && this.timepointApi.timepoints.findOne({ timepointId });
|
const timepoint = timepointId && this.timepointApi.timepoints.findOne({ timepointId });
|
||||||
|
|||||||
@ -35,14 +35,15 @@ class MeasurementHandlers {
|
|||||||
|
|
||||||
OHIF.log.info('CornerstoneToolsMeasurementAdded');
|
OHIF.log.info('CornerstoneToolsMeasurementAdded');
|
||||||
|
|
||||||
|
const imagePath = [studyInstanceUid, seriesInstanceUid, sopInstanceUid, frameIndex].join('_');
|
||||||
let measurement = $.extend({
|
let measurement = $.extend({
|
||||||
userId: Meteor.userId(),
|
userId: Meteor.userId(),
|
||||||
patientId: patientId,
|
patientId,
|
||||||
studyInstanceUid: studyInstanceUid,
|
studyInstanceUid,
|
||||||
seriesInstanceUid: seriesInstanceUid,
|
seriesInstanceUid,
|
||||||
sopInstanceUid: sopInstanceUid,
|
sopInstanceUid,
|
||||||
frameIndex: frameIndex,
|
frameIndex,
|
||||||
imageId: imageId // TODO: In the future we should consider removing this
|
imagePath
|
||||||
}, measurementData);
|
}, measurementData);
|
||||||
|
|
||||||
// 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
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import { OHIF } from 'meteor/ohif:core';
|
|||||||
*/
|
*/
|
||||||
function activateTool(measurementData) {
|
function activateTool(measurementData) {
|
||||||
const toolType = measurementData.toolType;
|
const toolType = measurementData.toolType;
|
||||||
const imageId = measurementData.imageId;
|
const imageId = OHIF.viewerbase.getImageIdForImagePath(measurementData.imagePath);
|
||||||
const toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.saveToolState();
|
const toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.saveToolState();
|
||||||
|
|
||||||
const toolData = toolState[imageId][toolType];
|
const toolData = toolState[imageId][toolType];
|
||||||
@ -25,8 +25,7 @@ function activateTool(measurementData) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cornerstoneTools.globalImageIdSpecificToolStateManager.restoreToolState(toolState);
|
cornerstoneTools.globalImageIdSpecificToolStateManager.restoreToolState(toolState);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Switch to the image of the correct image index
|
* Switch to the image of the correct image index
|
||||||
@ -68,11 +67,12 @@ OHIF.measurements.activateMeasurements = (element, measurementData) => {
|
|||||||
const enabledElement = cornerstone.getEnabledElement(element);
|
const enabledElement = cornerstone.getEnabledElement(element);
|
||||||
const currentImageId = enabledElement.image.imageId;
|
const currentImageId = enabledElement.image.imageId;
|
||||||
const toolData = cornerstoneTools.getToolState(element, 'stack');
|
const toolData = cornerstoneTools.getToolState(element, 'stack');
|
||||||
const imageIdIndex = toolData.data[0].imageIds.indexOf(measurementData.imageId);
|
const imageId = OHIF.viewerbase.getImageIdForImagePath(measurementData.imagePath);
|
||||||
|
const imageIdIndex = toolData.data[0].imageIds.indexOf(imageId);
|
||||||
|
|
||||||
// If we aren't currently displaying the image that this tool is on,
|
// If we aren't currently displaying the image that this tool is on,
|
||||||
// scroll to it now.
|
// scroll to it now.
|
||||||
if (currentImageId !== measurementData.imageId) {
|
if (currentImageId !== imageId) {
|
||||||
cornerstoneTools.scrollToIndex(element, imageIdIndex);
|
cornerstoneTools.scrollToIndex(element, imageIdIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ OHIF.measurements.activateMeasurements = (element, measurementData) => {
|
|||||||
// or maybe just remove the 'error' this throws?
|
// or maybe just remove the 'error' this throws?
|
||||||
let ee;
|
let ee;
|
||||||
try {
|
try {
|
||||||
ee = cornerstone.getEnabledElement(element)
|
ee = cornerstone.getEnabledElement(element);
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
OHIF.log.warn(error);
|
OHIF.log.warn(error);
|
||||||
return;
|
return;
|
||||||
@ -99,6 +99,6 @@ OHIF.measurements.activateMeasurements = (element, measurementData) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cornerstone.updateImage(element)
|
cornerstone.updateImage(element);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@ -18,8 +18,9 @@ OHIF.measurements.exportPdf = (measurementApi, timepointApi) => {
|
|||||||
|
|
||||||
const printMeasurement = (measurement, callback) => {
|
const printMeasurement = (measurement, callback) => {
|
||||||
OHIF.measurements.getImageDataUrl({ measurement }).then(imageDataUrl => {
|
OHIF.measurements.getImageDataUrl({ measurement }).then(imageDataUrl => {
|
||||||
const series = cornerstoneTools.metaData.get('series', measurement.imageId);
|
const imageId = OHIF.viewerbase.getImageIdForImagePath(measurement.imagePath);
|
||||||
const instance = cornerstoneTools.metaData.get('instance', measurement.imageId);
|
const series = cornerstoneTools.metaData.get('series', imageId);
|
||||||
|
const instance = cornerstoneTools.metaData.get('instance', imageId);
|
||||||
|
|
||||||
let info = measurement.response;
|
let info = measurement.response;
|
||||||
if (!info) {
|
if (!info) {
|
||||||
|
|||||||
@ -7,10 +7,11 @@ OHIF.measurements.getImageDataUrl = ({
|
|||||||
width=512,
|
width=512,
|
||||||
height=512,
|
height=512,
|
||||||
cacheImage=true,
|
cacheImage=true,
|
||||||
imageId,
|
imagePath,
|
||||||
measurement
|
measurement
|
||||||
}) => {
|
}) => {
|
||||||
imageId = imageId || measurement.imageId;
|
imagePath = imagePath || measurement.imagePath;
|
||||||
|
const imageId = OHIF.viewerbase.getImageIdForImagePath(imagePath);
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const loadMethod = cacheImage ? 'loadAndCacheImage' : 'loadImage';
|
const loadMethod = cacheImage ? 'loadAndCacheImage' : 'loadImage';
|
||||||
|
|||||||
@ -5,7 +5,7 @@ OHIF.measurements.syncMeasurementAndToolData = measurement => {
|
|||||||
OHIF.log.info('syncMeasurementAndToolData');
|
OHIF.log.info('syncMeasurementAndToolData');
|
||||||
|
|
||||||
const toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.saveToolState();
|
const toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.saveToolState();
|
||||||
const imageId = measurement.imageId;
|
const imageId = OHIF.viewerbase.getImageIdForImagePath(measurement.imagePath);
|
||||||
const toolType = measurement.toolType;
|
const toolType = measurement.toolType;
|
||||||
|
|
||||||
// If no tool state exists for this imageId, create an empty object to store it
|
// If no tool state exists for this imageId, create an empty object to store it
|
||||||
|
|||||||
@ -31,6 +31,10 @@ Viewerbase.switchToImageByIndex = switchToImageByIndex;
|
|||||||
import { getFrameOfReferenceUID } from './lib/getFrameOfReferenceUID';
|
import { getFrameOfReferenceUID } from './lib/getFrameOfReferenceUID';
|
||||||
Viewerbase.getFrameOfReferenceUID = getFrameOfReferenceUID;
|
Viewerbase.getFrameOfReferenceUID = getFrameOfReferenceUID;
|
||||||
|
|
||||||
|
// getImageIdForImagePath
|
||||||
|
import { getImageIdForImagePath } from './lib/getImageIdForImagePath';
|
||||||
|
Viewerbase.getImageIdForImagePath = getImageIdForImagePath;
|
||||||
|
|
||||||
// updateCrosshairsSynchronizer
|
// updateCrosshairsSynchronizer
|
||||||
import { updateCrosshairsSynchronizer } from './lib/updateCrosshairsSynchronizer';
|
import { updateCrosshairsSynchronizer } from './lib/updateCrosshairsSynchronizer';
|
||||||
Viewerbase.updateCrosshairsSynchronizer = updateCrosshairsSynchronizer;
|
Viewerbase.updateCrosshairsSynchronizer = updateCrosshairsSynchronizer;
|
||||||
|
|||||||
@ -2,13 +2,12 @@ import { getWADORSImageId } from './getWADORSImageId';
|
|||||||
|
|
||||||
// https://stackoverflow.com/a/6021027/3895126
|
// https://stackoverflow.com/a/6021027/3895126
|
||||||
function updateQueryStringParameter(uri, key, value) {
|
function updateQueryStringParameter(uri, key, value) {
|
||||||
var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
|
const regex = new RegExp('([?&])' + key + '=.*?(&|$)', 'i');
|
||||||
var separator = uri.indexOf('?') !== -1 ? "&" : "?";
|
const separator = uri.indexOf('?') !== -1 ? '&' : '?';
|
||||||
if (uri.match(re)) {
|
if (uri.match(regex)) {
|
||||||
return uri.replace(re, '$1' + key + "=" + value + '$2');
|
return uri.replace(regex, '$1' + key + '=' + value + '$2');
|
||||||
}
|
} else {
|
||||||
else {
|
return uri + separator + key + '=' + value;
|
||||||
return uri + separator + key + "=" + value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,6 +24,10 @@ export function getImageId(instance, frame, thumbnail) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof instance.getImageId === 'function') {
|
||||||
|
return instance.getImageId();
|
||||||
|
}
|
||||||
|
|
||||||
if (instance.url) {
|
if (instance.url) {
|
||||||
if (frame !== undefined) {
|
if (frame !== undefined) {
|
||||||
instance.url = updateQueryStringParameter(instance.url, 'frame', frame);
|
instance.url = updateQueryStringParameter(instance.url, 'frame', frame);
|
||||||
@ -36,7 +39,7 @@ export function getImageId(instance, frame, thumbnail) {
|
|||||||
const renderingAttr = thumbnail ? 'thumbnailRendering' : 'imageRendering';
|
const renderingAttr = thumbnail ? 'thumbnailRendering' : 'imageRendering';
|
||||||
|
|
||||||
if (!instance[renderingAttr] || instance[renderingAttr] === 'wadouri' || !instance.wadorsuri) {
|
if (!instance[renderingAttr] || instance[renderingAttr] === 'wadouri' || !instance.wadorsuri) {
|
||||||
var imageId = 'dicomweb:' + instance.wadouri;
|
let imageId = 'dicomweb:' + instance.wadouri;
|
||||||
if (frame !== undefined) {
|
if (frame !== undefined) {
|
||||||
imageId += '&frame=' + frame;
|
imageId += '&frame=' + frame;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,17 @@
|
|||||||
|
import { OHIF } from 'meteor/ohif:core';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain an imageId for the given imagePath
|
||||||
|
*
|
||||||
|
* @param {String} imagePath Path containing study, series and instance UIDs and frame index
|
||||||
|
* @returns {String} The resulting imageId for the given imagePath
|
||||||
|
*/
|
||||||
|
|
||||||
|
export const getImageIdForImagePath = (imagePath, thumbnail=false) => {
|
||||||
|
const [studyInstanceUid, seriesInstanceUid, sopInstanceUid, frameIndex] = imagePath.split('_');
|
||||||
|
const study = OHIF.viewer.Studies.findBy({ studyInstanceUid });
|
||||||
|
const series = study.getSeriesByUID(seriesInstanceUid);
|
||||||
|
const instance = series.getInstanceByUID(sopInstanceUid);
|
||||||
|
const imageId = OHIF.viewerbase.getImageId(instance, frameIndex, thumbnail);
|
||||||
|
return imageId;
|
||||||
|
};
|
||||||
Loading…
Reference in New Issue
Block a user