Removing imageId from Measurement schema
This commit is contained in:
parent
cf9136447e
commit
7bb25ae6aa
@ -223,7 +223,9 @@ function validateSingleMeasurement(measurementData) {
|
||||
}).map(function(criteria) {
|
||||
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 (!currentConstraints) {
|
||||
@ -320,7 +322,8 @@ function validateAll() {
|
||||
currentMeasurement._id = measurement._id;
|
||||
|
||||
// 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) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -318,8 +318,9 @@ class MeasurementApi {
|
||||
const toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.saveToolState();
|
||||
|
||||
_.each(entries, entry => {
|
||||
if (toolState[entry.imageId]) {
|
||||
const toolData = toolState[entry.imageId][entry.toolType];
|
||||
const imageId = OHIF.viewerbase.getImageIdForImagePath(entry.imagePath);
|
||||
if (toolState[imageId]) {
|
||||
const toolData = toolState[imageId][entry.toolType];
|
||||
const measurementsData = toolData && toolData.data;
|
||||
const measurementEntry = _.findWhere(measurementsData, {
|
||||
_id: entry._id
|
||||
|
||||
@ -177,11 +177,9 @@ const FrameLevelMeasurement = new SimpleSchema([
|
||||
min: 0,
|
||||
label: 'Frame index in Instance'
|
||||
},
|
||||
// TODO: In the future we should remove this in favour of searching OHIF.viewer.Studies and display sets when
|
||||
// re-displaying measurements. Otherwise if a study moves servers the measurements will not be displayed correctly
|
||||
imageId: {
|
||||
imagePath: {
|
||||
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);
|
||||
|
||||
measurements.forEach(measurement => {
|
||||
const { studyInstanceUid, imageId } = measurement;
|
||||
const imageId = OHIF.viewerbase.getImageIdForImagePath(measurement.imagePath);
|
||||
const { studyInstanceUid } = measurement;
|
||||
|
||||
const timepointId = measurement.timepointId;
|
||||
const timepoint = timepointId && this.timepointApi.timepoints.findOne({ timepointId });
|
||||
|
||||
@ -35,14 +35,15 @@ class MeasurementHandlers {
|
||||
|
||||
OHIF.log.info('CornerstoneToolsMeasurementAdded');
|
||||
|
||||
const imagePath = [studyInstanceUid, seriesInstanceUid, sopInstanceUid, frameIndex].join('_');
|
||||
let measurement = $.extend({
|
||||
userId: Meteor.userId(),
|
||||
patientId: patientId,
|
||||
studyInstanceUid: studyInstanceUid,
|
||||
seriesInstanceUid: seriesInstanceUid,
|
||||
sopInstanceUid: sopInstanceUid,
|
||||
frameIndex: frameIndex,
|
||||
imageId: imageId // TODO: In the future we should consider removing this
|
||||
patientId,
|
||||
studyInstanceUid,
|
||||
seriesInstanceUid,
|
||||
sopInstanceUid,
|
||||
frameIndex,
|
||||
imagePath
|
||||
}, measurementData);
|
||||
|
||||
// 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) {
|
||||
const toolType = measurementData.toolType;
|
||||
const imageId = measurementData.imageId;
|
||||
const imageId = OHIF.viewerbase.getImageIdForImagePath(measurementData.imagePath);
|
||||
const toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.saveToolState();
|
||||
|
||||
const toolData = toolState[imageId][toolType];
|
||||
@ -25,8 +25,7 @@ function activateTool(measurementData) {
|
||||
}
|
||||
|
||||
cornerstoneTools.globalImageIdSpecificToolStateManager.restoreToolState(toolState);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch to the image of the correct image index
|
||||
@ -68,11 +67,12 @@ OHIF.measurements.activateMeasurements = (element, measurementData) => {
|
||||
const enabledElement = cornerstone.getEnabledElement(element);
|
||||
const currentImageId = enabledElement.image.imageId;
|
||||
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,
|
||||
// scroll to it now.
|
||||
if (currentImageId !== measurementData.imageId) {
|
||||
if (currentImageId !== imageId) {
|
||||
cornerstoneTools.scrollToIndex(element, imageIdIndex);
|
||||
}
|
||||
|
||||
@ -89,7 +89,7 @@ OHIF.measurements.activateMeasurements = (element, measurementData) => {
|
||||
// or maybe just remove the 'error' this throws?
|
||||
let ee;
|
||||
try {
|
||||
ee = cornerstone.getEnabledElement(element)
|
||||
ee = cornerstone.getEnabledElement(element);
|
||||
} catch(error) {
|
||||
OHIF.log.warn(error);
|
||||
return;
|
||||
@ -99,6 +99,6 @@ OHIF.measurements.activateMeasurements = (element, measurementData) => {
|
||||
return;
|
||||
}
|
||||
|
||||
cornerstone.updateImage(element)
|
||||
cornerstone.updateImage(element);
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
@ -18,8 +18,9 @@ OHIF.measurements.exportPdf = (measurementApi, timepointApi) => {
|
||||
|
||||
const printMeasurement = (measurement, callback) => {
|
||||
OHIF.measurements.getImageDataUrl({ measurement }).then(imageDataUrl => {
|
||||
const series = cornerstoneTools.metaData.get('series', measurement.imageId);
|
||||
const instance = cornerstoneTools.metaData.get('instance', measurement.imageId);
|
||||
const imageId = OHIF.viewerbase.getImageIdForImagePath(measurement.imagePath);
|
||||
const series = cornerstoneTools.metaData.get('series', imageId);
|
||||
const instance = cornerstoneTools.metaData.get('instance', imageId);
|
||||
|
||||
let info = measurement.response;
|
||||
if (!info) {
|
||||
|
||||
@ -7,10 +7,11 @@ OHIF.measurements.getImageDataUrl = ({
|
||||
width=512,
|
||||
height=512,
|
||||
cacheImage=true,
|
||||
imageId,
|
||||
imagePath,
|
||||
measurement
|
||||
}) => {
|
||||
imageId = imageId || measurement.imageId;
|
||||
imagePath = imagePath || measurement.imagePath;
|
||||
const imageId = OHIF.viewerbase.getImageIdForImagePath(imagePath);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const loadMethod = cacheImage ? 'loadAndCacheImage' : 'loadImage';
|
||||
|
||||
@ -5,7 +5,7 @@ OHIF.measurements.syncMeasurementAndToolData = measurement => {
|
||||
OHIF.log.info('syncMeasurementAndToolData');
|
||||
|
||||
const toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.saveToolState();
|
||||
const imageId = measurement.imageId;
|
||||
const imageId = OHIF.viewerbase.getImageIdForImagePath(measurement.imagePath);
|
||||
const toolType = measurement.toolType;
|
||||
|
||||
// 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';
|
||||
Viewerbase.getFrameOfReferenceUID = getFrameOfReferenceUID;
|
||||
|
||||
// getImageIdForImagePath
|
||||
import { getImageIdForImagePath } from './lib/getImageIdForImagePath';
|
||||
Viewerbase.getImageIdForImagePath = getImageIdForImagePath;
|
||||
|
||||
// updateCrosshairsSynchronizer
|
||||
import { updateCrosshairsSynchronizer } from './lib/updateCrosshairsSynchronizer';
|
||||
Viewerbase.updateCrosshairsSynchronizer = updateCrosshairsSynchronizer;
|
||||
|
||||
@ -2,13 +2,12 @@ import { getWADORSImageId } from './getWADORSImageId';
|
||||
|
||||
// https://stackoverflow.com/a/6021027/3895126
|
||||
function updateQueryStringParameter(uri, key, value) {
|
||||
var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
|
||||
var separator = uri.indexOf('?') !== -1 ? "&" : "?";
|
||||
if (uri.match(re)) {
|
||||
return uri.replace(re, '$1' + key + "=" + value + '$2');
|
||||
}
|
||||
else {
|
||||
return uri + separator + key + "=" + value;
|
||||
const regex = new RegExp('([?&])' + key + '=.*?(&|$)', 'i');
|
||||
const separator = uri.indexOf('?') !== -1 ? '&' : '?';
|
||||
if (uri.match(regex)) {
|
||||
return uri.replace(regex, '$1' + key + '=' + value + '$2');
|
||||
} else {
|
||||
return uri + separator + key + '=' + value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,6 +24,10 @@ export function getImageId(instance, frame, thumbnail) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof instance.getImageId === 'function') {
|
||||
return instance.getImageId();
|
||||
}
|
||||
|
||||
if (instance.url) {
|
||||
if (frame !== undefined) {
|
||||
instance.url = updateQueryStringParameter(instance.url, 'frame', frame);
|
||||
@ -36,7 +39,7 @@ export function getImageId(instance, frame, thumbnail) {
|
||||
const renderingAttr = thumbnail ? 'thumbnailRendering' : 'imageRendering';
|
||||
|
||||
if (!instance[renderingAttr] || instance[renderingAttr] === 'wadouri' || !instance.wadorsuri) {
|
||||
var imageId = 'dicomweb:' + instance.wadouri;
|
||||
let imageId = 'dicomweb:' + instance.wadouri;
|
||||
if (frame !== undefined) {
|
||||
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