Fixed issue on ordering of display sets in OHIF Viewers + Fixed issue with tag to property name translation on OHIFInstanceMetadata class.
This commit is contained in:
parent
a06da4e6e1
commit
6003f67865
@ -9,6 +9,7 @@ export class OHIFInstanceMetadata extends InstanceMetadata {
|
|||||||
*/
|
*/
|
||||||
constructor(data) {
|
constructor(data) {
|
||||||
super(data);
|
super(data);
|
||||||
|
this._cache = Object.create(null); // Object with null prototype for fast and safe lookups...
|
||||||
this.init();
|
this.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,13 +20,24 @@ export class OHIFInstanceMetadata extends InstanceMetadata {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Override
|
// Override
|
||||||
getRawValue(tagOrProperty, defaultValue) {
|
getRawValue(tagOrProperty, defaultValue, bypassCache) {
|
||||||
const propertyName = OHIFInstanceMetadata.getPropertyName(tagOrProperty);
|
|
||||||
|
|
||||||
|
// check if this property has been cached...
|
||||||
|
if (tagOrProperty in this._cache && bypassCache !== true) {
|
||||||
|
return this._cache[tagOrProperty];
|
||||||
|
}
|
||||||
|
|
||||||
|
const propertyName = OHIFInstanceMetadata.getPropertyName(tagOrProperty);
|
||||||
const data = this.getData();
|
const data = this.getData();
|
||||||
const rawValue = data[propertyName];
|
const rawValue = data[propertyName];
|
||||||
|
|
||||||
return rawValue !== void 0 ? rawValue : defaultValue;
|
if (rawValue !== void 0) {
|
||||||
|
// if rawValue value is not undefined, cache result...
|
||||||
|
this._cache[tagOrProperty] = rawValue;
|
||||||
|
return rawValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Override
|
// Override
|
||||||
@ -41,18 +53,19 @@ export class OHIFInstanceMetadata extends InstanceMetadata {
|
|||||||
* Static methods
|
* Static methods
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// @TODO: The current mapping of standard DICOM property names to local property names is not optimal.
|
||||||
|
// The inconsistency in property naming makes this function increasingly complex.
|
||||||
|
// A possible solution to improve this would be adapt retriveMetadata names to use DICOM standard names as in dicomTagDescriptions.js
|
||||||
static getPropertyName(tagOrProperty) {
|
static getPropertyName(tagOrProperty) {
|
||||||
|
let propertyName;
|
||||||
const tagInfo = InstanceMetadata.getTagInfo(tagOrProperty);
|
const tagInfo = InstanceMetadata.getTagInfo(tagOrProperty);
|
||||||
|
|
||||||
if(tagInfo.propertyName === null) {
|
if (tagInfo.propertyName !== null) {
|
||||||
return;
|
// This function tries to translate standard DICOM property names into local naming convention.
|
||||||
|
propertyName = tagInfo.propertyName.replace(/^SOP/, 'sop').replace(/UID$/, 'Uid');
|
||||||
|
propertyName = propertyName.charAt(0).toLowerCase() + propertyName.substr(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
let propertyName = tagInfo.propertyName.charAt(0).toLowerCase() + tagInfo.propertyName.substr(1);
|
|
||||||
// TODO: Improve this: change retriveMetadata to use dicom standard names (see dicomTagDescriptions.js)
|
|
||||||
propertyName = propertyName.replace(/^sop/, 'SOP');
|
|
||||||
propertyName = propertyName.replace(/uid$/i, 'UID');
|
|
||||||
|
|
||||||
return propertyName;
|
return propertyName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -126,22 +126,25 @@ export class InstanceMetadata extends Metadata {
|
|||||||
if (typeof tagOrProperty === NUMBER) {
|
if (typeof tagOrProperty === NUMBER) {
|
||||||
// if it's a number, build an hexadecimal representation...
|
// if it's a number, build an hexadecimal representation...
|
||||||
tagName = 'x' + ('00000000' + tagOrProperty.toString(16)).substr(-8);
|
tagName = 'x' + ('00000000' + tagOrProperty.toString(16)).substr(-8);
|
||||||
} else if (typeof tagOrProperty === STRING && REGEX_TAG.test(tagOrProperty)) {
|
} else if (typeof tagOrProperty === STRING) {
|
||||||
tagName = tagOrProperty;
|
if (REGEX_TAG.test(tagOrProperty)) {
|
||||||
} else {
|
tagName = tagOrProperty;
|
||||||
// use it as a property name otherwise...
|
} else {
|
||||||
propertyName = tagOrProperty;
|
propertyName = tagOrProperty;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// It's a property
|
if (propertyName !== null) {
|
||||||
if (tagName === null) {
|
// try to figure out the "tagName" using the provided "propertyName"...
|
||||||
for (let tag in dicomTagDescriptions) {
|
for (let tag in dicomTagDescriptions) {
|
||||||
|
// No need to check for "hasOwnProperty" here since dicomTagDescriptions is an object with no prototype...
|
||||||
if (dicomTagDescriptions[tag] === propertyName) {
|
if (dicomTagDescriptions[tag] === propertyName) {
|
||||||
tagName = tag;
|
tagName = tag;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (propertyName === null) {
|
} else if (tagName !== null) {
|
||||||
|
// try to figure out the "propertyName" using the provided "tagName"...
|
||||||
propertyName = dicomTagDescriptions[tagName] || null;
|
propertyName = dicomTagDescriptions[tagName] || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,8 @@ import { ImageSet } from './classes/ImageSet';
|
|||||||
import { isImage } from './isImage';
|
import { isImage } from './isImage';
|
||||||
|
|
||||||
const isMultiFrame = instance => {
|
const isMultiFrame = instance => {
|
||||||
return instance.getRawValue('NumberOfFrames') > 1;
|
// NumberOfFrames (0028,0008)
|
||||||
|
return instance.getRawValue('x00280008') > 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
const makeDisplaySet = (series, instances) => {
|
const makeDisplaySet = (series, instances) => {
|
||||||
@ -25,13 +26,8 @@ const makeDisplaySet = (series, instances) => {
|
|||||||
|
|
||||||
// Sort the images in this series
|
// Sort the images in this series
|
||||||
imageSet.sortBy((a, b) => {
|
imageSet.sortBy((a, b) => {
|
||||||
// Sort by instance Number
|
// Sort by InstanceNumber (0020,0013)
|
||||||
const aInstanceNumber = a.getRawValue('x00200013');
|
return (parseInt(a.getRawValue('x00200013', 0)) || 0) - (parseInt(b.getRawValue('x00200013', 0)) || 0);
|
||||||
const bInstanceNumber = b.getRawValue('x00200013');
|
|
||||||
if (a.instanceNumber && b.instanceNumber &&
|
|
||||||
a.instanceNumber !== b.instanceNumber) {
|
|
||||||
return a.instanceNumber - b.instanceNumber;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Include the first image instance number (after sorted)
|
// Include the first image instance number (after sorted)
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
export const dicomTagDescriptions = {
|
|
||||||
|
const dicomTagDescriptions = Object.create(null); // Object with null prototype for fast and safe lookups...
|
||||||
|
let _dicomTagDescriptions = {
|
||||||
x00020000: 'FileMetaInfoGroupLength',
|
x00020000: 'FileMetaInfoGroupLength',
|
||||||
x00020001: 'FileMetaInfoVersion',
|
x00020001: 'FileMetaInfoVersion',
|
||||||
x00020002: 'MediaStorageSOPClassUID',
|
x00020002: 'MediaStorageSOPClassUID',
|
||||||
@ -3146,3 +3148,18 @@ export const dicomTagDescriptions = {
|
|||||||
xfffee00d: 'EndOfItems',
|
xfffee00d: 'EndOfItems',
|
||||||
xfffee0dd: 'EndOfSequence'
|
xfffee0dd: 'EndOfSequence'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Safely copy tag descriptions to exported objects...
|
||||||
|
(function(_dicomTagDescriptions) {
|
||||||
|
const _hasOwn = Object.prototype.hasOwnProperty;
|
||||||
|
for (let tag in _dicomTagDescriptions) {
|
||||||
|
if (_hasOwn.call(_dicomTagDescriptions, tag)) {
|
||||||
|
dicomTagDescriptions[tag] = _dicomTagDescriptions[tag];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}(_dicomTagDescriptions));
|
||||||
|
|
||||||
|
// Discard original object...
|
||||||
|
_dicomTagDescriptions = null;
|
||||||
|
|
||||||
|
export { dicomTagDescriptions };
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user