Split packages into platform and extensions
This commit is contained in:
1 parent
f175d4b96b
commit
e8969fba11
992 files changed
+2
-1
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,174 @@
|
||||
import OHIFError from '../classes/OHIFError.js';
|
||||
import getImageId from './getImageId';
|
||||
|
||||
let stackMap = {};
|
||||
let configuration = {};
|
||||
let stackManagerMetaDataProvider;
|
||||
const stackUpdatedCallbacks = [];
|
||||
|
||||
/**
|
||||
* Loop through the current series and add metadata to the
|
||||
* Cornerstone meta data provider. This will be used to fill information
|
||||
* into the viewport overlays, and to calculate reference lines and orientation markers
|
||||
* @param {Object} stackMap stackMap object
|
||||
* @param {Object} study Study object
|
||||
* @param {Object} displaySet The set of images to make the stack from
|
||||
* @return {Array} Array with image IDs
|
||||
*/
|
||||
function createAndAddStack(
|
||||
stackMap,
|
||||
study,
|
||||
displaySet,
|
||||
stackUpdatedCallbacks,
|
||||
metadataProvider
|
||||
) {
|
||||
const images = displaySet.images;
|
||||
if (!images) {
|
||||
return;
|
||||
}
|
||||
|
||||
const numImages = images.length;
|
||||
const imageIds = [];
|
||||
let imageId;
|
||||
|
||||
displaySet.images.forEach((instance, imageIndex) => {
|
||||
const image = instance.getData();
|
||||
const metaData = {
|
||||
instance: image, // in this context, instance will be the data of the InstanceMetadata object...
|
||||
series: displaySet, // TODO: Check this
|
||||
study,
|
||||
numImages,
|
||||
imageIndex: imageIndex + 1,
|
||||
};
|
||||
|
||||
const numberOfFrames = image.numberOfFrames;
|
||||
if (numberOfFrames > 1) {
|
||||
for (let i = 0; i < numberOfFrames; i++) {
|
||||
metaData.frameNumber = i;
|
||||
imageId = getImageId(image, i);
|
||||
imageIds.push(imageId);
|
||||
metadataProvider.addMetadata(imageId, metaData);
|
||||
}
|
||||
} else {
|
||||
metaData.frameNumber = 1;
|
||||
imageId = getImageId(image);
|
||||
imageIds.push(imageId);
|
||||
metadataProvider.addMetadata(imageId, metaData);
|
||||
}
|
||||
});
|
||||
|
||||
const stack = {
|
||||
studyInstanceUid: study.studyInstanceUid,
|
||||
displaySetInstanceUid: displaySet.displaySetInstanceUid,
|
||||
imageIds,
|
||||
frameRate: displaySet.frameRate,
|
||||
isClip: displaySet.isClip,
|
||||
};
|
||||
|
||||
stackMap[displaySet.displaySetInstanceUid] = stack;
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
configuration = {
|
||||
createAndAddStack,
|
||||
};
|
||||
|
||||
/**
|
||||
* This object contains all the functions needed for interacting with the stack manager.
|
||||
* Generally, findStack is the only function used. If you want to know when new stacks
|
||||
* come in, you can register a callback with addStackUpdatedCallback.
|
||||
*/
|
||||
const StackManager = {
|
||||
setMetadataProvider(provider) {
|
||||
stackManagerMetaDataProvider = provider;
|
||||
},
|
||||
/**
|
||||
* Removes all current stacks
|
||||
*/
|
||||
clearStacks() {
|
||||
stackMap = {};
|
||||
},
|
||||
/**
|
||||
* Create a stack from an image set, as well as add in the metadata on a per image bases.
|
||||
* @param study The study who's metadata will be added
|
||||
* @param displaySet The set of images to make the stack from
|
||||
* @return {Array} Array with image IDs
|
||||
*/
|
||||
makeAndAddStack(study, displaySet) {
|
||||
if (!stackManagerMetaDataProvider) {
|
||||
throw new Error(
|
||||
'Please call StackManager.setMetadataProvider(provider) first.'
|
||||
);
|
||||
}
|
||||
|
||||
return configuration.createAndAddStack(
|
||||
stackMap,
|
||||
study,
|
||||
displaySet,
|
||||
stackUpdatedCallbacks,
|
||||
stackManagerMetaDataProvider
|
||||
);
|
||||
},
|
||||
/**
|
||||
* Find a stack from the currently created stacks.
|
||||
* @param displaySetInstanceUid The UID of the stack to find.
|
||||
* @returns {*} undefined if not found, otherwise the stack object is returned.
|
||||
*/
|
||||
findStack(displaySetInstanceUid) {
|
||||
return stackMap[displaySetInstanceUid];
|
||||
},
|
||||
/**
|
||||
* Find a stack or reate one if it has not been created yet
|
||||
* @param study The study who's metadata will be added
|
||||
* @param displaySet The set of images to make the stack from
|
||||
* @return {Array} Array with image IDs
|
||||
*/
|
||||
findOrCreateStack(study, displaySet) {
|
||||
let stack = this.findStack(displaySet.displaySetInstanceUid);
|
||||
|
||||
if (!stack || !stack.imageIds) {
|
||||
stack = this.makeAndAddStack(study, displaySet);
|
||||
}
|
||||
|
||||
return stack;
|
||||
},
|
||||
/**
|
||||
* Gets the underlying map of displaySetInstanceUid to stack object.
|
||||
* WARNING: Do not change this object. It directly affects the manager.
|
||||
* @returns {{}} map of displaySetInstanceUid -> stack.
|
||||
*/
|
||||
getAllStacks() {
|
||||
return stackMap;
|
||||
},
|
||||
/**
|
||||
* Adds in a callback to be called on a stack being added / updated.
|
||||
* @param callback must accept at minimum one argument,
|
||||
* which is the stack that was added / updated.
|
||||
*/
|
||||
addStackUpdatedCallback(callback) {
|
||||
if (typeof callback !== 'function') {
|
||||
throw new OHIFError('callback must be provided as a function');
|
||||
}
|
||||
stackUpdatedCallbacks.push(callback);
|
||||
},
|
||||
/**
|
||||
* Return configuration
|
||||
*/
|
||||
getConfiguration() {
|
||||
return configuration;
|
||||
},
|
||||
/**
|
||||
* Set configuration, in order to provide compatibility
|
||||
* with other systems by overriding this functions
|
||||
* @param {Object} config object with functions to be overrided
|
||||
*
|
||||
* For now, only makeAndAddStack can be overrided
|
||||
*/
|
||||
setConfiguration(config) {
|
||||
configuration = config;
|
||||
},
|
||||
};
|
||||
|
||||
export { StackManager };
|
||||
export default StackManager;
|
||||
@@ -0,0 +1,16 @@
|
||||
export default function absoluteUrl(path) {
|
||||
let absolutePath = '/';
|
||||
|
||||
// TODO: Find another way to get root url
|
||||
const absoluteUrl = window.location.origin;
|
||||
const absoluteUrlParts = absoluteUrl.split('/');
|
||||
|
||||
if (absoluteUrlParts.length > 4) {
|
||||
const rootUrlPrefixIndex = absoluteUrl.indexOf(absoluteUrlParts[3]);
|
||||
absolutePath += absoluteUrl.substring(rootUrlPrefixIndex) + path;
|
||||
} else {
|
||||
absolutePath += path;
|
||||
}
|
||||
|
||||
return absolutePath.replace(/\/\/+/g, '/');
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// TODO: figure out where else to put this function
|
||||
export default function addServers(servers, store) {
|
||||
Object.keys(servers).forEach(serverType => {
|
||||
const endpoints = servers[serverType];
|
||||
endpoints.forEach(endpoint => {
|
||||
const server = Object.assign({}, endpoint);
|
||||
server.type = serverType;
|
||||
|
||||
store.dispatch({
|
||||
type: 'ADD_SERVER',
|
||||
server,
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Leaving here as a starting point
|
||||
// import createStacks from './createStacks.js';
|
||||
|
||||
// describe('createStacks.js', () => {
|
||||
// const seriesMetadatas = [
|
||||
// {
|
||||
// getInstanceCount: jest.fn().mockReturnValue(1),
|
||||
// getData: jest.fn().mockReturnValue({
|
||||
// seriesDate: '2019-06-04',
|
||||
// }),
|
||||
// },
|
||||
// {
|
||||
// getInstanceCount: jest.fn().mockReturnValue(1),
|
||||
// getData: jest.fn().mockReturnValue({
|
||||
// seriesDate: '2018-06-04',
|
||||
// }),
|
||||
// },
|
||||
// ];
|
||||
// const studyMetadata = {
|
||||
// getSeriesCount: jest.fn().mockReturnValue(2),
|
||||
// forEachSeries: jest.fn().mockImplementation(callback => {
|
||||
// callback(seriesMetadatas[0], 0);
|
||||
// callback(seriesMetadatas[1], 1);
|
||||
// }),
|
||||
// getStudyInstanceUID: jest.fn(),
|
||||
// };
|
||||
|
||||
// it('sorts displaySets by seriesNumber, then by seriesDate', () => {
|
||||
// const displaySets = createStacks(studyMetadata);
|
||||
|
||||
// expect(displaySets.length).toBe(2);
|
||||
// });
|
||||
// });
|
||||
@@ -0,0 +1,55 @@
|
||||
import getWADORSImageId from './getWADORSImageId';
|
||||
|
||||
// https://stackoverflow.com/a/6021027/3895126
|
||||
function updateQueryStringParameter(uri, 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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain an imageId for Cornerstone from an image instance
|
||||
*
|
||||
* @param instance
|
||||
* @param frame
|
||||
* @param thumbnail
|
||||
* @returns {string} The imageId to be used by Cornerstone
|
||||
*/
|
||||
export default function getImageId(instance, frame, thumbnail = false) {
|
||||
if (!instance) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof instance.getImageId === 'function') {
|
||||
return instance.getImageId();
|
||||
}
|
||||
|
||||
if (instance.url) {
|
||||
if (frame !== undefined) {
|
||||
instance.url = updateQueryStringParameter(instance.url, 'frame', frame);
|
||||
}
|
||||
|
||||
return instance.url;
|
||||
}
|
||||
|
||||
const renderingAttr = thumbnail ? 'thumbnailRendering' : 'imageRendering';
|
||||
|
||||
if (
|
||||
!instance[renderingAttr] ||
|
||||
instance[renderingAttr] === 'wadouri' ||
|
||||
!instance.wadorsuri
|
||||
) {
|
||||
let imageId = 'dicomweb:' + instance.wadouri;
|
||||
if (frame !== undefined) {
|
||||
imageId += '&frame=' + frame;
|
||||
}
|
||||
|
||||
return imageId;
|
||||
} else {
|
||||
return getWADORSImageId(instance, frame, thumbnail); // WADO-RS Retrieve Frame
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
function getWADORSImageUrl(instance, frame) {
|
||||
let wadorsuri = instance.wadorsuri;
|
||||
|
||||
if (!wadorsuri) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We need to sum 1 because WADO-RS frame number is 1-based
|
||||
frame = (frame || 0) + 1;
|
||||
|
||||
// Replaces /frame/1 by /frame/{frame}
|
||||
wadorsuri = wadorsuri.replace(/(%2Fframes%2F)(\d+)/, `$1${frame}`);
|
||||
|
||||
return wadorsuri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain an imageId for Cornerstone based on the WADO-RS scheme
|
||||
*
|
||||
* @param {object} instanceMetada metadata object (InstanceMetadata)
|
||||
* @returns {string} The imageId to be used by Cornerstone
|
||||
*/
|
||||
export default function getWADORSImageId(instance, frame) {
|
||||
const uri = getWADORSImageUrl(instance, frame);
|
||||
|
||||
if (!uri) {
|
||||
return;
|
||||
}
|
||||
|
||||
return `wadors:${uri}`;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Create a random GUID
|
||||
*
|
||||
* @return {string}
|
||||
*/
|
||||
export default function guid() {
|
||||
function s4() {
|
||||
return Math.floor((1 + Math.random()) * 0x10000)
|
||||
.toString(16)
|
||||
.substring(1);
|
||||
}
|
||||
return (
|
||||
s4() +
|
||||
s4() +
|
||||
'-' +
|
||||
s4() +
|
||||
'-' +
|
||||
s4() +
|
||||
'-' +
|
||||
s4() +
|
||||
'-' +
|
||||
s4() +
|
||||
s4() +
|
||||
s4()
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import { DICOMTagDescriptions } from './DICOMTagDescriptions';
|
||||
import ObjectPath from './objectPath';
|
||||
import StackManager from './StackManager.js';
|
||||
import absoluteUrl from './absoluteUrl';
|
||||
import addServers from './addServers';
|
||||
import guid from './guid';
|
||||
import sortBy from './sortBy.js';
|
||||
import studyMetadataManager from './studyMetadataManager';
|
||||
import updateMetaDataManager from './updateMetaDataManager.js';
|
||||
import writeScript from './writeScript.js';
|
||||
|
||||
const utils = {
|
||||
guid,
|
||||
ObjectPath,
|
||||
absoluteUrl,
|
||||
addServers,
|
||||
sortBy,
|
||||
writeScript,
|
||||
StackManager,
|
||||
studyMetadataManager,
|
||||
// Updates WADO-RS metaDataManager
|
||||
updateMetaDataManager,
|
||||
DICOMTagDescriptions,
|
||||
};
|
||||
|
||||
export {
|
||||
guid,
|
||||
ObjectPath,
|
||||
absoluteUrl,
|
||||
addServers,
|
||||
sortBy,
|
||||
writeScript,
|
||||
StackManager,
|
||||
studyMetadataManager,
|
||||
// Updates WADO-RS metaDataManager
|
||||
updateMetaDataManager,
|
||||
DICOMTagDescriptions,
|
||||
};
|
||||
|
||||
export default utils;
|
||||
@@ -0,0 +1,76 @@
|
||||
import { sopClassDictionary } from './sopClassDictionary';
|
||||
|
||||
/**
|
||||
* Checks whether dicom files with specified SOP Class UID have image data
|
||||
* @param {string} sopClassUid - SOP Class UID to be checked
|
||||
* @returns {boolean} - true if it has image data
|
||||
*/
|
||||
export function isImage(sopClassUid) {
|
||||
if (
|
||||
sopClassUid === sopClassDictionary.ComputedRadiographyImageStorage ||
|
||||
sopClassUid === sopClassDictionary.DigitalXRayImageStorageForPresentation ||
|
||||
sopClassUid === sopClassDictionary.DigitalXRayImageStorageForProcessing ||
|
||||
sopClassUid ===
|
||||
sopClassDictionary.DigitalMammographyXRayImageStorageForPresentation ||
|
||||
sopClassUid ===
|
||||
sopClassDictionary.DigitalMammographyXRayImageStorageForProcessing ||
|
||||
sopClassUid ===
|
||||
sopClassDictionary.DigitalIntraOralXRayImageStorageForPresentation ||
|
||||
sopClassUid ===
|
||||
sopClassDictionary.DigitalIntraOralXRayImageStorageForProcessing ||
|
||||
sopClassUid === sopClassDictionary.CTImageStorage ||
|
||||
sopClassUid === sopClassDictionary.EnhancedCTImageStorage ||
|
||||
sopClassUid === sopClassDictionary.LegacyConvertedEnhancedCTImageStorage ||
|
||||
sopClassUid === sopClassDictionary.UltrasoundMultiframeImageStorage ||
|
||||
sopClassUid === sopClassDictionary.MRImageStorage ||
|
||||
sopClassUid === sopClassDictionary.EnhancedMRImageStorage ||
|
||||
sopClassUid === sopClassDictionary.EnhancedMRColorImageStorage ||
|
||||
sopClassUid === sopClassDictionary.LegacyConvertedEnhancedMRImageStorage ||
|
||||
sopClassUid === sopClassDictionary.UltrasoundImageStorage ||
|
||||
sopClassUid === sopClassDictionary.SecondaryCaptureImageStorage ||
|
||||
sopClassUid ===
|
||||
sopClassDictionary.MultiframeSingleBitSecondaryCaptureImageStorage ||
|
||||
sopClassUid ===
|
||||
sopClassDictionary.MultiframeGrayscaleByteSecondaryCaptureImageStorage ||
|
||||
sopClassUid ===
|
||||
sopClassDictionary.MultiframeGrayscaleWordSecondaryCaptureImageStorage ||
|
||||
sopClassUid ===
|
||||
sopClassDictionary.MultiframeTrueColorSecondaryCaptureImageStorage ||
|
||||
sopClassUid === sopClassDictionary.XRayAngiographicImageStorage ||
|
||||
sopClassUid === sopClassDictionary.EnhancedXAImageStorage ||
|
||||
sopClassUid === sopClassDictionary.XRayRadiofluoroscopicImageStorage ||
|
||||
sopClassUid === sopClassDictionary.EnhancedXRFImageStorage ||
|
||||
sopClassUid === sopClassDictionary.XRay3DAngiographicImageStorage ||
|
||||
sopClassUid === sopClassDictionary.XRay3DCraniofacialImageStorage ||
|
||||
sopClassUid === sopClassDictionary.BreastTomosynthesisImageStorage ||
|
||||
sopClassUid ===
|
||||
sopClassDictionary.BreastProjectionXRayImageStorageForPresentation ||
|
||||
sopClassUid ===
|
||||
sopClassDictionary.BreastProjectionXRayImageStorageForProcessing ||
|
||||
sopClassUid ===
|
||||
sopClassDictionary.IntravascularOpticalCoherenceTomographyImageStorageForPresentation ||
|
||||
sopClassUid ===
|
||||
sopClassDictionary.IntravascularOpticalCoherenceTomographyImageStorageForProcessing ||
|
||||
sopClassUid === sopClassDictionary.NuclearMedicineImageStorage ||
|
||||
sopClassUid === sopClassDictionary.VLEndoscopicImageStorage ||
|
||||
sopClassUid === sopClassDictionary.VideoEndoscopicImageStorage ||
|
||||
sopClassUid === sopClassDictionary.VLMicroscopicImageStorage ||
|
||||
sopClassUid === sopClassDictionary.VideoMicroscopicImageStorage ||
|
||||
sopClassUid ===
|
||||
sopClassDictionary.VLSlideCoordinatesMicroscopicImageStorage ||
|
||||
sopClassUid === sopClassDictionary.VLPhotographicImageStorage ||
|
||||
sopClassUid === sopClassDictionary.VideoPhotographicImageStorage ||
|
||||
sopClassUid === sopClassDictionary.OphthalmicPhotography8BitImageStorage ||
|
||||
sopClassUid === sopClassDictionary.OphthalmicPhotography16BitImageStorage ||
|
||||
sopClassUid === sopClassDictionary.OphthalmicTomographyImageStorage ||
|
||||
sopClassUid === sopClassDictionary.VLWholeSlideMicroscopyImageStorage ||
|
||||
sopClassUid === sopClassDictionary.PositronEmissionTomographyImageStorage ||
|
||||
sopClassUid === sopClassDictionary.EnhancedPETImageStorage ||
|
||||
sopClassUid === sopClassDictionary.LegacyConvertedEnhancedPETImageStorage ||
|
||||
sopClassUid === sopClassDictionary.RTImageStorage
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
export class ObjectPath {
|
||||
/**
|
||||
* Set an object property based on "path" (namespace) supplied creating
|
||||
* ... intermediary objects if they do not exist.
|
||||
* @param object {Object} An object where the properties specified on path should be set.
|
||||
* @param path {String} A string representing the property to be set, e.g. "user.study.series.timepoint".
|
||||
* @param value {Any} The value of the property that will be set.
|
||||
* @return {Boolean} Returns "true" on success, "false" if any intermediate component of the supplied path
|
||||
* ... is not a valid Object, in which case the property cannot be set. No excpetions are thrown.
|
||||
*/
|
||||
static set(object, path, value) {
|
||||
let components = ObjectPath.getPathComponents(path),
|
||||
length = components !== null ? components.length : 0,
|
||||
result = false;
|
||||
|
||||
if (length > 0 && ObjectPath.isValidObject(object)) {
|
||||
let i = 0,
|
||||
last = length - 1,
|
||||
currentObject = object;
|
||||
|
||||
while (i < last) {
|
||||
let field = components[i];
|
||||
|
||||
if (field in currentObject) {
|
||||
if (!ObjectPath.isValidObject(currentObject[field])) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
currentObject[field] = {};
|
||||
}
|
||||
|
||||
currentObject = currentObject[field];
|
||||
i++;
|
||||
}
|
||||
|
||||
if (i === last) {
|
||||
currentObject[components[last]] = value;
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an object property based on "path" (namespace) supplied traversing the object
|
||||
* ... tree as necessary.
|
||||
* @param object {Object} An object where the properties specified might exist.
|
||||
* @param path {String} A string representing the property to be searched for, e.g. "user.study.series.timepoint".
|
||||
* @return {Any} The value of the property if found. By default, returns the special type "undefined".
|
||||
*/
|
||||
static get(object, path) {
|
||||
let found, // undefined by default
|
||||
components = ObjectPath.getPathComponents(path),
|
||||
length = components !== null ? components.length : 0;
|
||||
|
||||
if (length > 0 && ObjectPath.isValidObject(object)) {
|
||||
let i = 0,
|
||||
last = length - 1,
|
||||
currentObject = object;
|
||||
|
||||
while (i < last) {
|
||||
let field = components[i];
|
||||
|
||||
const isValid = ObjectPath.isValidObject(currentObject[field]);
|
||||
if (field in currentObject && isValid) {
|
||||
currentObject = currentObject[field];
|
||||
i++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i === last && components[last] in currentObject) {
|
||||
found = currentObject[components[last]];
|
||||
}
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the supplied argument is a real JavaScript Object instance.
|
||||
* @param object {Any} The subject to be tested.
|
||||
* @return {Boolean} Returns "true" if the object is a real Object instance and "false" otherwise.
|
||||
*/
|
||||
static isValidObject(object) {
|
||||
return (
|
||||
typeof object === 'object' && object !== null && object instanceof Object
|
||||
);
|
||||
}
|
||||
|
||||
static getPathComponents(path) {
|
||||
return typeof path === 'string' ? path.split('.') : null;
|
||||
}
|
||||
}
|
||||
|
||||
export default ObjectPath;
|
||||
@@ -0,0 +1,130 @@
|
||||
// TODO: Deprecate since we have the same thing in dcmjs?
|
||||
export const sopClassDictionary = {
|
||||
ComputedRadiographyImageStorage: '1.2.840.10008.5.1.4.1.1.1',
|
||||
DigitalXRayImageStorageForPresentation: '1.2.840.10008.5.1.4.1.1.1.1',
|
||||
DigitalXRayImageStorageForProcessing: '1.2.840.10008.5.1.4.1.1.1.1.1',
|
||||
DigitalMammographyXRayImageStorageForPresentation:
|
||||
'1.2.840.10008.5.1.4.1.1.1.2',
|
||||
DigitalMammographyXRayImageStorageForProcessing:
|
||||
'1.2.840.10008.5.1.4.1.1.1.2.1',
|
||||
DigitalIntraOralXRayImageStorageForPresentation:
|
||||
'1.2.840.10008.5.1.4.1.1.1.3',
|
||||
DigitalIntraOralXRayImageStorageForProcessing:
|
||||
'1.2.840.10008.5.1.4.1.1.1.3.1',
|
||||
CTImageStorage: '1.2.840.10008.5.1.4.1.1.2',
|
||||
EnhancedCTImageStorage: '1.2.840.10008.5.1.4.1.1.2.1',
|
||||
LegacyConvertedEnhancedCTImageStorage: '1.2.840.10008.5.1.4.1.1.2.2',
|
||||
UltrasoundMultiframeImageStorage: '1.2.840.10008.5.1.4.1.1.3.1',
|
||||
MRImageStorage: '1.2.840.10008.5.1.4.1.1.4',
|
||||
EnhancedMRImageStorage: '1.2.840.10008.5.1.4.1.1.4.1',
|
||||
MRSpectroscopyStorage: '1.2.840.10008.5.1.4.1.1.4.2',
|
||||
EnhancedMRColorImageStorage: '1.2.840.10008.5.1.4.1.1.4.3',
|
||||
LegacyConvertedEnhancedMRImageStorage: '1.2.840.10008.5.1.4.1.1.4.4',
|
||||
UltrasoundImageStorage: '1.2.840.10008.5.1.4.1.1.6.1',
|
||||
EnhancedUSVolumeStorage: '1.2.840.10008.5.1.4.1.1.6.2',
|
||||
SecondaryCaptureImageStorage: '1.2.840.10008.5.1.4.1.1.7',
|
||||
MultiframeSingleBitSecondaryCaptureImageStorage:
|
||||
'1.2.840.10008.5.1.4.1.1.7.1',
|
||||
MultiframeGrayscaleByteSecondaryCaptureImageStorage:
|
||||
'1.2.840.10008.5.1.4.1.1.7.2',
|
||||
MultiframeGrayscaleWordSecondaryCaptureImageStorage:
|
||||
'1.2.840.10008.5.1.4.1.1.7.3',
|
||||
MultiframeTrueColorSecondaryCaptureImageStorage:
|
||||
'1.2.840.10008.5.1.4.1.1.7.4',
|
||||
Sop12LeadECGWaveformStorage: '1.2.840.10008.5.1.4.1.1.9.1.1',
|
||||
GeneralECGWaveformStorage: '1.2.840.10008.5.1.4.1.1.9.1.2',
|
||||
AmbulatoryECGWaveformStorage: '1.2.840.10008.5.1.4.1.1.9.1.3',
|
||||
HemodynamicWaveformStorage: '1.2.840.10008.5.1.4.1.1.9.2.1',
|
||||
CardiacElectrophysiologyWaveformStorage: '1.2.840.10008.5.1.4.1.1.9.3.1',
|
||||
BasicVoiceAudioWaveformStorage: '1.2.840.10008.5.1.4.1.1.9.4.1',
|
||||
GeneralAudioWaveformStorage: '1.2.840.10008.5.1.4.1.1.9.4.2',
|
||||
ArterialPulseWaveformStorage: '1.2.840.10008.5.1.4.1.1.9.5.1',
|
||||
RespiratoryWaveformStorage: '1.2.840.10008.5.1.4.1.1.9.6.1',
|
||||
GrayscaleSoftcopyPresentationStateStorage: '1.2.840.10008.5.1.4.1.1.11.1',
|
||||
ColorSoftcopyPresentationStateStorage: '1.2.840.10008.5.1.4.1.1.11.2',
|
||||
PseudoColorSoftcopyPresentationStateStorage: '1.2.840.10008.5.1.4.1.1.11.3',
|
||||
BlendingSoftcopyPresentationStateStorage: '1.2.840.10008.5.1.4.1.1.11.4',
|
||||
XAXRFGrayscaleSoftcopyPresentationStateStorage:
|
||||
'1.2.840.10008.5.1.4.1.1.11.5',
|
||||
XRayAngiographicImageStorage: '1.2.840.10008.5.1.4.1.1.12.1',
|
||||
EnhancedXAImageStorage: '1.2.840.10008.5.1.4.1.1.12.1.1',
|
||||
XRayRadiofluoroscopicImageStorage: '1.2.840.10008.5.1.4.1.1.12.2',
|
||||
EnhancedXRFImageStorage: '1.2.840.10008.5.1.4.1.1.12.2.1',
|
||||
XRay3DAngiographicImageStorage: '1.2.840.10008.5.1.4.1.1.13.1.1',
|
||||
XRay3DCraniofacialImageStorage: '1.2.840.10008.5.1.4.1.1.13.1.2',
|
||||
BreastTomosynthesisImageStorage: '1.2.840.10008.5.1.4.1.1.13.1.3',
|
||||
BreastProjectionXRayImageStorageForPresentation:
|
||||
'1.2.840.10008.5.1.4.1.1.13.1.4',
|
||||
BreastProjectionXRayImageStorageForProcessing:
|
||||
'1.2.840.10008.5.1.4.1.1.13.1.5',
|
||||
IntravascularOpticalCoherenceTomographyImageStorageForPresentation:
|
||||
'1.2.840.10008.5.1.4.1.1.14.1',
|
||||
IntravascularOpticalCoherenceTomographyImageStorageForProcessing:
|
||||
'1.2.840.10008.5.1.4.1.1.14.2',
|
||||
NuclearMedicineImageStorage: '1.2.840.10008.5.1.4.1.1.20',
|
||||
RawDataStorage: '1.2.840.10008.5.1.4.1.1.66',
|
||||
SpatialRegistrationStorage: '1.2.840.10008.5.1.4.1.1.66.1',
|
||||
SpatialFiducialsStorage: '1.2.840.10008.5.1.4.1.1.66.2',
|
||||
DeformableSpatialRegistrationStorage: '1.2.840.10008.5.1.4.1.1.66.3',
|
||||
SegmentationStorage: '1.2.840.10008.5.1.4.1.1.66.4',
|
||||
SurfaceSegmentationStorage: '1.2.840.10008.5.1.4.1.1.66.5',
|
||||
RealWorldValueMappingStorage: '1.2.840.10008.5.1.4.1.1.67',
|
||||
SurfaceScanMeshStorage: '1.2.840.10008.5.1.4.1.1.68.1',
|
||||
SurfaceScanPointCloudStorage: '1.2.840.10008.5.1.4.1.1.68.2',
|
||||
VLEndoscopicImageStorage: '1.2.840.10008.5.1.4.1.1.77.1.1',
|
||||
VideoEndoscopicImageStorage: '1.2.840.10008.5.1.4.1.1.77.1.1.1',
|
||||
VLMicroscopicImageStorage: '1.2.840.10008.5.1.4.1.1.77.1.2',
|
||||
VideoMicroscopicImageStorage: '1.2.840.10008.5.1.4.1.1.77.1.2.1',
|
||||
VLSlideCoordinatesMicroscopicImageStorage: '1.2.840.10008.5.1.4.1.1.77.1.3',
|
||||
VLPhotographicImageStorage: '1.2.840.10008.5.1.4.1.1.77.1.4',
|
||||
VideoPhotographicImageStorage: '1.2.840.10008.5.1.4.1.1.77.1.4.1',
|
||||
OphthalmicPhotography8BitImageStorage: '1.2.840.10008.5.1.4.1.1.77.1.5.1',
|
||||
OphthalmicPhotography16BitImageStorage: '1.2.840.10008.5.1.4.1.1.77.1.5.2',
|
||||
StereometricRelationshipStorage: '1.2.840.10008.5.1.4.1.1.77.1.5.3',
|
||||
OphthalmicTomographyImageStorage: '1.2.840.10008.5.1.4.1.1.77.1.5.4',
|
||||
VLWholeSlideMicroscopyImageStorage: '1.2.840.10008.5.1.4.1.1.77.1.6',
|
||||
LensometryMeasurementsStorage: '1.2.840.10008.5.1.4.1.1.78.1',
|
||||
AutorefractionMeasurementsStorage: '1.2.840.10008.5.1.4.1.1.78.2',
|
||||
KeratometryMeasurementsStorage: '1.2.840.10008.5.1.4.1.1.78.3',
|
||||
SubjectiveRefractionMeasurementsStorage: '1.2.840.10008.5.1.4.1.1.78.4',
|
||||
VisualAcuityMeasurementsStorage: '1.2.840.10008.5.1.4.1.1.78.5',
|
||||
SpectaclePrescriptionReportStorage: '1.2.840.10008.5.1.4.1.1.78.6',
|
||||
OphthalmicAxialMeasurementsStorage: '1.2.840.10008.5.1.4.1.1.78.7',
|
||||
IntraocularLensCalculationsStorage: '1.2.840.10008.5.1.4.1.1.78.8',
|
||||
MacularGridThicknessandVolumeReport: '1.2.840.10008.5.1.4.1.1.79.1',
|
||||
OphthalmicVisualFieldStaticPerimetryMeasurementsStorage:
|
||||
'1.2.840.10008.5.1.4.1.1.80.1',
|
||||
OphthalmicThicknessMapStorage: '1.2.840.10008.5.1.4.1.1.81.1',
|
||||
CornealTopographyMapStorage: '1.2.840.10008.5.1.4.1.1.82.1',
|
||||
BasicTextSR: '1.2.840.10008.5.1.4.1.1.88.11',
|
||||
EnhancedSR: '1.2.840.10008.5.1.4.1.1.88.22',
|
||||
ComprehensiveSR: '1.2.840.10008.5.1.4.1.1.88.33',
|
||||
Comprehensive3DSR: '1.2.840.10008.5.1.4.1.1.88.34',
|
||||
ProcedureLog: '1.2.840.10008.5.1.4.1.1.88.40',
|
||||
MammographyCADSR: '1.2.840.10008.5.1.4.1.1.88.50',
|
||||
KeyObjectSelection: '1.2.840.10008.5.1.4.1.1.88.59',
|
||||
ChestCADSR: '1.2.840.10008.5.1.4.1.1.88.65',
|
||||
XRayRadiationDoseSR: '1.2.840.10008.5.1.4.1.1.88.67',
|
||||
RadiopharmaceuticalRadiationDoseSR: '1.2.840.10008.5.1.4.1.1.88.68',
|
||||
ColonCADSR: '1.2.840.10008.5.1.4.1.1.88.69',
|
||||
ImplantationPlanSRDocumentStorage: '1.2.840.10008.5.1.4.1.1.88.70',
|
||||
EncapsulatedPDFStorage: '1.2.840.10008.5.1.4.1.1.104.1',
|
||||
EncapsulatedCDAStorage: '1.2.840.10008.5.1.4.1.1.104.2',
|
||||
PositronEmissionTomographyImageStorage: '1.2.840.10008.5.1.4.1.1.128',
|
||||
EnhancedPETImageStorage: '1.2.840.10008.5.1.4.1.1.130',
|
||||
LegacyConvertedEnhancedPETImageStorage: '1.2.840.10008.5.1.4.1.1.128.1',
|
||||
BasicStructuredDisplayStorage: '1.2.840.10008.5.1.4.1.1.131',
|
||||
RTImageStorage: '1.2.840.10008.5.1.4.1.1.481.1',
|
||||
RTDoseStorage: '1.2.840.10008.5.1.4.1.1.481.2',
|
||||
RTStructureSetStorage: '1.2.840.10008.5.1.4.1.1.481.3',
|
||||
RTBeamsTreatmentRecordStorage: '1.2.840.10008.5.1.4.1.1.481.4',
|
||||
RTPlanStorage: '1.2.840.10008.5.1.4.1.1.481.5',
|
||||
RTBrachyTreatmentRecordStorage: '1.2.840.10008.5.1.4.1.1.481.6',
|
||||
RTTreatmentSummaryRecordStorage: '1.2.840.10008.5.1.4.1.1.481.7',
|
||||
RTIonPlanStorage: '1.2.840.10008.5.1.4.1.1.481.8',
|
||||
RTIonBeamsTreatmentRecordStorage: '1.2.840.10008.5.1.4.1.1.481.9',
|
||||
RTBeamsDeliveryInstructionStorage: '1.2.840.10008.5.1.4.34.7',
|
||||
GenericImplantTemplateStorage: '1.2.840.10008.5.1.4.43.1',
|
||||
ImplantAssemblyTemplateStorage: '1.2.840.10008.5.1.4.44.1',
|
||||
ImplantTemplateGroupStorage: '1.2.840.10008.5.1.4.45.1',
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
// Return the array sorting function for its object's properties
|
||||
export default function sortBy() {
|
||||
var fields = [].slice.call(arguments),
|
||||
n_fields = fields.length;
|
||||
|
||||
return function(A, B) {
|
||||
var a, b, field, key, reverse, result, i;
|
||||
|
||||
for (i = 0; i < n_fields; i++) {
|
||||
result = 0;
|
||||
field = fields[i];
|
||||
|
||||
key = typeof field === 'string' ? field : field.name;
|
||||
|
||||
a = A[key];
|
||||
b = B[key];
|
||||
|
||||
if (typeof field.primer !== 'undefined') {
|
||||
a = field.primer(a);
|
||||
b = field.primer(b);
|
||||
}
|
||||
|
||||
reverse = field.reverse ? -1 : 1;
|
||||
|
||||
if (a < b) {
|
||||
result = reverse * -1;
|
||||
}
|
||||
|
||||
if (a > b) {
|
||||
result = reverse * 1;
|
||||
}
|
||||
|
||||
if (result !== 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import { TypeSafeCollection } from '../classes/TypeSafeCollection';
|
||||
|
||||
const studyMetadataList = new TypeSafeCollection();
|
||||
|
||||
function add(studyMetadata) {
|
||||
studyMetadataList.insert(studyMetadata);
|
||||
}
|
||||
|
||||
function get(studyInstanceUID) {
|
||||
return studyMetadataList.findBy({ studyInstanceUID });
|
||||
}
|
||||
|
||||
function all(options) {
|
||||
return studyMetadataList.all(options);
|
||||
}
|
||||
|
||||
function remove(studyInstanceUID) {
|
||||
studyMetadataList.remove({ studyInstanceUID });
|
||||
}
|
||||
|
||||
function purge() {
|
||||
studyMetadataList.removeAll();
|
||||
}
|
||||
|
||||
export default {
|
||||
add,
|
||||
get,
|
||||
all,
|
||||
remove,
|
||||
purge,
|
||||
};
|
||||
@@ -0,0 +1,101 @@
|
||||
import { WadoRsMetaDataBuilder } from '../classes/metadata/WadoRsMetaDataBuilder';
|
||||
import cornerstoneWADOImageLoader from 'cornerstone-wado-image-loader';
|
||||
import getWADORSImageId from './getWADORSImageId';
|
||||
|
||||
function getRadiopharmaceuticalInfoMetaData(instance) {
|
||||
const radiopharmaceuticalInfo = instance.radiopharmaceuticalInfo;
|
||||
|
||||
if (instance.modality !== 'PT' || !radiopharmaceuticalInfo) {
|
||||
return;
|
||||
}
|
||||
|
||||
return new WadoRsMetaDataBuilder()
|
||||
.addTag('00181072', radiopharmaceuticalInfo.radiopharmaceuticalStartTime)
|
||||
.addTag('00181074', radiopharmaceuticalInfo.radionuclideTotalDose)
|
||||
.addTag('00181075', radiopharmaceuticalInfo.radionuclideHalfLife)
|
||||
.toJSON();
|
||||
}
|
||||
|
||||
const getWadoRsInstanceMetaData = (study, series, instance) => {
|
||||
return new WadoRsMetaDataBuilder()
|
||||
.addTag('00080016', instance.sopClassUid)
|
||||
.addTag('00080018', instance.sopInstanceUid)
|
||||
.addTag('00080021', series.seriesDate)
|
||||
.addTag('00080031', series.seriesTime)
|
||||
.addTag('0008103e', series.seriesDescription)
|
||||
.addTag('00080060', series.modality)
|
||||
.addTag('00101010', study.patientAge)
|
||||
.addTag('00101020', study.patientSize)
|
||||
.addTag('00101030', study.patientWeight)
|
||||
.addTag('0020000d', study.studyInstanceUid)
|
||||
.addTag('00081030', study.studyDescription)
|
||||
.addTag('00100010', study.patientName)
|
||||
.addTag('00100020', study.patientId)
|
||||
.addTag('00080020', study.studyDate)
|
||||
.addTag('00080030', study.studyTime)
|
||||
.addTag('00080050', study.accessionNumber)
|
||||
.addTag('00200013', instance.instanceNumber)
|
||||
.addTag('00180050', instance.sliceThickness)
|
||||
.addTag('0020000e', series.seriesInstanceUid)
|
||||
.addTag('00200011', series.seriesNumber)
|
||||
.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)
|
||||
.addTag('00281101', instance.redPaletteColorLookupTableDescriptor)
|
||||
.addTag('00281102', instance.greenPaletteColorLookupTableDescriptor)
|
||||
.addTag('00281103', instance.bluePaletteColorLookupTableDescriptor)
|
||||
.addTag('00281201', instance.redPaletteColorLookupTableData)
|
||||
.addTag('00281202', instance.greenPaletteColorLookupTableData)
|
||||
.addTag('00281203', instance.bluePaletteColorLookupTableData)
|
||||
.addTag('00540016', getRadiopharmaceuticalInfoMetaData(instance))
|
||||
.toJSON();
|
||||
};
|
||||
|
||||
export default function updateMetaDataManager(study) {
|
||||
study.seriesList.forEach(series => {
|
||||
series.instances.forEach(instance => {
|
||||
// Cache just images that are going to be loaded via WADO-RS
|
||||
if (
|
||||
instance.imageRendering !== 'wadors' &&
|
||||
instance.thumbnailRendering !== 'wadors'
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const metaData = getWadoRsInstanceMetaData(study, series, instance);
|
||||
const numberOfFrames = instance.numberOfFrames || 1;
|
||||
|
||||
// We can share the same metaData with all frames because it doesn't have
|
||||
// any frame specific data, such as frameNumber, pixelData, offset, etc.
|
||||
// WADO-RS frame number is 1-based
|
||||
for (let frameNumber = 0; frameNumber < numberOfFrames; frameNumber++) {
|
||||
const imageId = getWADORSImageId(instance, frameNumber);
|
||||
|
||||
// TODO Drop dependency on this
|
||||
cornerstoneWADOImageLoader.wadors.metaDataManager.add(
|
||||
imageId,
|
||||
metaData
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
/* jshint -W060 */
|
||||
import absoluteUrl from './absoluteUrl';
|
||||
|
||||
export default function writeScript(fileName, callback) {
|
||||
const script = document.createElement('script');
|
||||
script.src = absoluteUrl(fileName);
|
||||
script.onload = () => {
|
||||
if (typeof callback === 'function') {
|
||||
callback(script);
|
||||
}
|
||||
};
|
||||
|
||||
document.body.appendChild(script);
|
||||
}
|
||||
Reference in new issue
Block a user