Making getImagePlane work with IntanceMetadata. This would fix some features that depend on imagePlane such as Link Series

This commit is contained in:
Eloízio Salgado 2017-01-19 11:18:18 -02:00 committed by Emanuel F. Oliveira
parent 6003f67865
commit 47db6bcb05
2 changed files with 16 additions and 9 deletions

View File

@ -130,25 +130,26 @@ const updateMetaData = image => {
}; };
/** /**
* Constructs and returns the imagePlane given the instance * Constructs and returns the imagePlane given the metadata instance
* *
* @param instance The instance containing information to construct imagePlane * @param metadataInstance The metadata instance (InstanceMetadata class) containing information to construct imagePlane
* @returns imagePlane The constructed imagePlane to be used in viewer easily * @returns imagePlane The constructed imagePlane to be used in viewer easily
*/ */
function getImagePlane(instance) { function getImagePlane(metadataInstance) {
const instance = metadataInstance.getData();
if (!instance.rows || !instance.columns || !instance.pixelSpacing || if (!instance.rows || !instance.columns || !instance.pixelSpacing ||
!instance.frameOfReferenceUID || !instance.imageOrientationPatient || !instance.frameOfReferenceUID || !instance.imageOrientationPatient ||
!instance.imagePositionPatient) { !instance.imagePositionPatient) {
return; return;
} }
let imageOrientation = instance.imageOrientationPatient.split('\\'); const imageOrientation = instance.imageOrientationPatient.split('\\');
let imagePosition = instance.imagePositionPatient.split('\\'); const imagePosition = instance.imagePositionPatient.split('\\');
let columnPixelSpacing = 1.0; let columnPixelSpacing = 1.0;
let rowPixelSpacing = 1.0; let rowPixelSpacing = 1.0;
if (instance.pixelSpacing) { if (instance.pixelSpacing) {
let split = instance.pixelSpacing.split('\\'); const split = instance.pixelSpacing.split('\\');
rowPixelSpacing = parseFloat(split[0]); rowPixelSpacing = parseFloat(split[0]);
columnPixelSpacing = parseFloat(split[1]); columnPixelSpacing = parseFloat(split[1]);
} }

View File

@ -1,12 +1,13 @@
import { OHIF } from 'meteor/ohif:core'; import { OHIF } from 'meteor/ohif:core';
import { Session } from 'meteor/session'; import { Session } from 'meteor/session';
import { $ } from 'meteor/jquery'; import { $ } from 'meteor/jquery';
import { toolManager } from './toolManager';
class StackImagePositionOffsetSynchronizer { class StackImagePositionOffsetSynchronizer {
constructor() { constructor() {
this.active = false; this.active = false;
this.syncedViewports = []; this.syncedViewports = [];
this.synchronizer = new cornerstoneTools.Synchronizer("CornerstoneNewImage", cornerstoneTools.stackImagePositionOffsetSynchronizer) this.synchronizer = new cornerstoneTools.Synchronizer('CornerstoneNewImage', cornerstoneTools.stackImagePositionOffsetSynchronizer)
} }
static get ELEMENT_DISABLED_EVENT() { static get ELEMENT_DISABLED_EVENT() {
@ -190,16 +191,21 @@ class StackImagePositionOffsetSynchronizer {
try { try {
const enabledElement = cornerstone.getEnabledElement(element); const enabledElement = cornerstone.getEnabledElement(element);
if(!enabledElement || !enabledElement.image) { if(!enabledElement.image) {
return; return;
} }
const imageId = enabledElement.image.imageId; const imageId = enabledElement.image.imageId;
const imagePlane = cornerstoneTools.metaData.get('imagePlane', imageId); const imagePlane = cornerstoneTools.metaData.get('imagePlane', imageId);
if(!imagePlane || !imagePlane.rowCosines || !imagePlane.columnCosines) {
return;
}
return imagePlane.rowCosines.clone().cross(imagePlane.columnCosines); return imagePlane.rowCosines.clone().cross(imagePlane.columnCosines);
} catch(error) { } catch(error) {
console.log(error.message); const errorMessage = error.message || error;
OHIF.log.info(`StackImagePositionOffsetSynchronizer getViewportImageNormal: ${errorMessage}`);
} }
} }
} }