Changing getWADORSImageId to work with latest cornerstoneWADOImageLoader
This commit is contained in:
parent
4867f72df4
commit
d1aa77dd76
@ -174,17 +174,22 @@ function resultDataToStudyMetadata(server, studyInstanceUid, resultData) {
|
|||||||
sliceLocation: DICOMWeb.getNumber(instance['00201041']),
|
sliceLocation: DICOMWeb.getNumber(instance['00201041']),
|
||||||
samplesPerPixel: DICOMWeb.getNumber(instance['00280002']),
|
samplesPerPixel: DICOMWeb.getNumber(instance['00280002']),
|
||||||
photometricInterpretation: DICOMWeb.getString(instance['00280004']),
|
photometricInterpretation: DICOMWeb.getString(instance['00280004']),
|
||||||
|
planarConfiguration: DICOMWeb.getNumber(instance['00280006']),
|
||||||
rows: DICOMWeb.getNumber(instance['00280010']),
|
rows: DICOMWeb.getNumber(instance['00280010']),
|
||||||
columns: DICOMWeb.getNumber(instance['00280011']),
|
columns: DICOMWeb.getNumber(instance['00280011']),
|
||||||
pixelSpacing: DICOMWeb.getString(instance['00280030']),
|
pixelSpacing: DICOMWeb.getString(instance['00280030']),
|
||||||
|
pixelAspectRatio: DICOMWeb.getString(instance['00280034']),
|
||||||
bitsAllocated: DICOMWeb.getNumber(instance['00280100']),
|
bitsAllocated: DICOMWeb.getNumber(instance['00280100']),
|
||||||
bitsStored: DICOMWeb.getNumber(instance['00280101']),
|
bitsStored: DICOMWeb.getNumber(instance['00280101']),
|
||||||
highBit: DICOMWeb.getNumber(instance['00280102']),
|
highBit: DICOMWeb.getNumber(instance['00280102']),
|
||||||
pixelRepresentation: DICOMWeb.getNumber(instance['00280103']),
|
pixelRepresentation: DICOMWeb.getNumber(instance['00280103']),
|
||||||
|
smallestPixelValue: DICOMWeb.getNumber(instance['00280106']),
|
||||||
|
largestPixelValue: DICOMWeb.getNumber(instance['00280107']),
|
||||||
windowCenter: DICOMWeb.getString(instance['00281050']),
|
windowCenter: DICOMWeb.getString(instance['00281050']),
|
||||||
windowWidth: DICOMWeb.getString(instance['00281051']),
|
windowWidth: DICOMWeb.getString(instance['00281051']),
|
||||||
rescaleIntercept: DICOMWeb.getNumber(instance['00281052']),
|
rescaleIntercept: DICOMWeb.getNumber(instance['00281052']),
|
||||||
rescaleSlope: DICOMWeb.getNumber(instance['00281053']),
|
rescaleSlope: DICOMWeb.getNumber(instance['00281053']),
|
||||||
|
rescaleType: DICOMWeb.getNumber(instance['00281054']),
|
||||||
sourceImageInstanceUid: getSourceImageInstanceUid(instance),
|
sourceImageInstanceUid: getSourceImageInstanceUid(instance),
|
||||||
laterality: DICOMWeb.getString(instance['00200062']),
|
laterality: DICOMWeb.getString(instance['00200062']),
|
||||||
viewPosition: DICOMWeb.getString(instance['00185101']),
|
viewPosition: DICOMWeb.getString(instance['00185101']),
|
||||||
|
|||||||
@ -1,4 +1,46 @@
|
|||||||
import { OHIF } from 'meteor/ohif:core';
|
import { OHIF } from 'meteor/ohif:core';
|
||||||
|
import { _ } from 'meteor/underscore';
|
||||||
|
|
||||||
|
class ImageMetadataBuilder {
|
||||||
|
constructor() {
|
||||||
|
this.tags = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
addTag(tag, value, multi) {
|
||||||
|
this.tags[tag] = {
|
||||||
|
tag,
|
||||||
|
value,
|
||||||
|
multi
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
toJSON() {
|
||||||
|
const json = {};
|
||||||
|
const keys = Object.keys(this.tags);
|
||||||
|
|
||||||
|
keys.forEach(key => {
|
||||||
|
if(!this.tags.hasOwnProperty(key)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const tag = this.tags[key];
|
||||||
|
const multi = !!tag.multi;
|
||||||
|
const value = tag.value && multi ? tag.value.split('\\') : [tag.value];
|
||||||
|
|
||||||
|
if((value.length === 1) && (value[0] == null)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
json[key] = {
|
||||||
|
Value: value
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain an imageId for Cornerstone based on the WADO-RS scheme
|
* Obtain an imageId for Cornerstone based on the WADO-RS scheme
|
||||||
@ -6,60 +48,46 @@ import { OHIF } from 'meteor/ohif:core';
|
|||||||
* @param {object} instanceMetada metadata object (InstanceMetadata)
|
* @param {object} instanceMetada metadata object (InstanceMetadata)
|
||||||
* @returns {string} The imageId to be used by Cornerstone
|
* @returns {string} The imageId to be used by Cornerstone
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export function getWADORSImageId(instance) {
|
export function getWADORSImageId(instance) {
|
||||||
const uri = Meteor.absoluteUrl(instance.wadorsuri);
|
const uri = Meteor.absoluteUrl(instance.wadorsuri);
|
||||||
const imageId = `wadors:${uri}`;
|
const imageId = `wadors:${uri}`;
|
||||||
|
|
||||||
let columnPixelSpacing = 1.0;
|
const imageMetadata = new ImageMetadataBuilder()
|
||||||
let rowPixelSpacing = 1.0;
|
.addTag('00080016', instance.sopClassUid)
|
||||||
|
.addTag('00080018', instance.sopInstanceUid)
|
||||||
|
.addTag('00180050', instance.sliceThickness)
|
||||||
|
.addTag('00200013', instance.instanceNumber)
|
||||||
|
.addTag('00200032', instance.imagePositionPatient, true)
|
||||||
|
.addTag('00200037', instance.imageOrientationPatient, true)
|
||||||
|
.addTag('00200052', instance.frameOfReferenceUID)
|
||||||
|
.addTag('00201041', instance.sliceLocation)
|
||||||
|
.addTag('00280002', instance.samplesPerPixel)
|
||||||
|
.addTag('00280004', instance.photometricInterpretation)
|
||||||
|
.addTag('00280006', instance.planarConfiguration)
|
||||||
|
.addTag('00280010', instance.rows)
|
||||||
|
.addTag('00280011', instance.columns)
|
||||||
|
.addTag('00280030', instance.pixelSpacing, true)
|
||||||
|
.addTag('00280034', instance.pixelAspectRatio, true)
|
||||||
|
.addTag('00280100', instance.bitsAllocated)
|
||||||
|
.addTag('00280101', instance.bitsStored)
|
||||||
|
.addTag('00280102', instance.highBit)
|
||||||
|
.addTag('00280103', instance.pixelRepresentation)
|
||||||
|
.addTag('00280106', instance.smallestPixelValue)
|
||||||
|
.addTag('00280107', instance.largestPixelValue)
|
||||||
|
.addTag('00281050', instance.windowCenter, true)
|
||||||
|
.addTag('00281051', instance.windowWidth, true)
|
||||||
|
.addTag('00281052', instance.rescaleIntercept)
|
||||||
|
.addTag('00281053', instance.rescaleSlope)
|
||||||
|
.addTag('00281054', instance.rescaleType)
|
||||||
|
.toJSON();
|
||||||
|
|
||||||
if (instance.pixelSpacing) {
|
_.extend(imageMetadata, {
|
||||||
const split = instance.pixelSpacing.split('\\');
|
uri: uri,
|
||||||
rowPixelSpacing = parseFloat(split[0]);
|
|
||||||
columnPixelSpacing = parseFloat(split[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
let windowWidth;
|
|
||||||
let windowCenter;
|
|
||||||
|
|
||||||
if (instance.windowWidth && instance.windowCenter) {
|
|
||||||
windowWidth = parseFloat(instance.windowWidth.split('\\')[0]);
|
|
||||||
windowCenter = parseFloat(instance.windowCenter.split('\\')[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
const image = {
|
|
||||||
uri: instance.wadorsuri,
|
|
||||||
//imageId : '',
|
|
||||||
//minPixelValue : 0,
|
|
||||||
//maxPixelValue : 255,
|
|
||||||
slope: instance.rescaleSlope,
|
|
||||||
intercept: instance.rescaleIntercept,
|
|
||||||
samplesPerPixel: instance.samplesPerPixel,
|
|
||||||
imageOrientationPatient: instance.imageOrientationPatient,
|
|
||||||
imagePositionPatient: instance.imagePositionPatient,
|
|
||||||
sopClassUid: instance.sopClassUid,
|
|
||||||
instanceNumber: instance.instanceNumber,
|
|
||||||
frameOfReferenceUID: instance.frameOfReferenceUID,
|
|
||||||
windowCenter: windowCenter,
|
|
||||||
windowWidth: windowWidth,
|
|
||||||
//render: cornerstone.renderColorImage,
|
|
||||||
//getPixelData: getPixelData,
|
|
||||||
//getImageData: getImageData,
|
|
||||||
//getCanvas: getCanvas,
|
|
||||||
rows: instance.rows,
|
|
||||||
columns: instance.columns,
|
|
||||||
height: instance.rows,
|
|
||||||
width: instance.columns,
|
|
||||||
color: false,
|
|
||||||
columnPixelSpacing: columnPixelSpacing,
|
|
||||||
rowPixelSpacing: rowPixelSpacing,
|
|
||||||
invert: false,
|
|
||||||
sizeInBytes: instance.rows * instance.columns * (instance.bitsAllocated / 8),
|
sizeInBytes: instance.rows * instance.columns * (instance.bitsAllocated / 8),
|
||||||
instance: instance
|
instance: instance
|
||||||
};
|
});
|
||||||
|
|
||||||
cornerstoneWADOImageLoader.wadors.metaDataManager.add(imageId, image);
|
cornerstoneWADOImageLoader.wadors.metaDataManager.add(imageId, imageMetadata);
|
||||||
|
|
||||||
OHIF.log.info('WADO-RS ImageID: ' + imageId);
|
OHIF.log.info('WADO-RS ImageID: ' + imageId);
|
||||||
return imageId;
|
return imageId;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user