Instance metadata/metadata providers overhaul (#1481)
* Instance metadata plus metadata provider overhaul. Fix consumption of wado-uri urls fallbacks + datatype agnosticism. WIP DICOMify things. fix various issues with naturalized variable naming migration. Remove metadata provider. Fix consumption of multiframe images and addition of CWIL metadata. Fix strange build issues. Fix CWIL style windowWidth to array from naturalized DICOM. Fix PT, CT, CR and DX issues for cornerstone + DX issues for vtkjs. Move color palette fetching down to the natuaralized JSON level. Remove unused StudyMetadataSummary Remove redundant dicom metadata dictionary. Working local + json routes. Fix SR read. Finished first round of testing + cleaned up debugging etc. * data => metadata for instance naturalizedJSON * Update dcmjs version * Correct github isssues. * Fix erroneously replaced files. * Danny's recommended changes. * Instance metadata plus metadata provider overhaul. Fix consumption of wado-uri urls fallbacks + datatype agnosticism. WIP DICOMify things. fix various issues with naturalized variable naming migration. Remove metadata provider. Fix consumption of multiframe images and addition of CWIL metadata. Fix strange build issues. Fix CWIL style windowWidth to array from naturalized DICOM. Fix PT, CT, CR and DX issues for cornerstone + DX issues for vtkjs. Move color palette fetching down to the natuaralized JSON level. Remove unused StudyMetadataSummary Remove redundant dicom metadata dictionary. Working local + json routes. Fix SR read. Finished first round of testing + cleaned up debugging etc. * data => metadata for instance naturalizedJSON * Update dcmjs version * Correct github isssues. * Fix erroneously replaced files. * Danny's recommended changes. * Update JSON CI * Update casing of import. * Fix jump for SR. * Fix unit tests for measurements service * Fix json CI test. * fix: update yarn lock * Fix local non-encapsulated pdf view * CI updated to new sucess message. Co-authored-by: Danny <danny.ri.brown@gmail.com>
This commit is contained in:
1 parent
8833731ad3
commit
1d85f7a74e
142 files changed
+5322
-8570
No files matched your search
@@ -8,20 +8,12 @@ import OHIFError from '../OHIFError.js';
|
||||
|
||||
const UNDEFINED = 'undefined';
|
||||
const STRING = 'string';
|
||||
const STUDY_INSTANCE_UID = 'x0020000d';
|
||||
const SERIES_INSTANCE_UID = 'x0020000e';
|
||||
|
||||
export class InstanceMetadata extends Metadata {
|
||||
constructor(data, uid) {
|
||||
super(data, uid);
|
||||
// Initialize Private Properties
|
||||
Object.defineProperties(this, {
|
||||
_sopInstanceUID: {
|
||||
configurable: true, // configurable so that it can be redefined in sub-classes...
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
value: null,
|
||||
},
|
||||
_imageId: {
|
||||
configurable: true, // configurable so that it can be redefined in sub-classes...
|
||||
enumerable: false,
|
||||
@@ -43,14 +35,14 @@ export class InstanceMetadata extends Metadata {
|
||||
*/
|
||||
_definePublicProperties() {
|
||||
/**
|
||||
* Property: this.sopInstanceUID
|
||||
* Property: this.SOPInstanceUID
|
||||
* Same as this.getSOPInstanceUID()
|
||||
* It's specially useful in contexts where a method call is not suitable like in search criteria. For example:
|
||||
* sopInstanceCollection.findBy({
|
||||
* sopInstanceUID: '1.2.3.4.5.6.77777.8888888.99999999999.0'
|
||||
* SOPInstanceUID: '1.2.3.4.5.6.77777.8888888.99999999999.0'
|
||||
* });
|
||||
*/
|
||||
Object.defineProperty(this, 'sopInstanceUID', {
|
||||
Object.defineProperty(this, 'SOPInstanceUID', {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
get: function() {
|
||||
@@ -67,21 +59,21 @@ export class InstanceMetadata extends Metadata {
|
||||
* Returns the StudyInstanceUID of the current instance. This method is basically a shorthand the full "getTagValue" method call.
|
||||
*/
|
||||
getStudyInstanceUID() {
|
||||
return this.getTagValue(STUDY_INSTANCE_UID, null);
|
||||
return this.getTagValue('StudyInstanceUID', null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the SeriesInstanceUID of the current instance. This method is basically a shorthand the full "getTagValue" method call.
|
||||
*/
|
||||
getSeriesInstanceUID() {
|
||||
return this.getTagValue(SERIES_INSTANCE_UID, null);
|
||||
return this.getTagValue('SeriesInstanceUID', null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the SOPInstanceUID of the current instance.
|
||||
*/
|
||||
getSOPInstanceUID() {
|
||||
return this._sopInstanceUID;
|
||||
return this.getTagValue('SOPInstanceUID', null);
|
||||
}
|
||||
|
||||
// @TODO: Improve this... (E.g.: blob data)
|
||||
@@ -127,13 +119,6 @@ export class InstanceMetadata extends Metadata {
|
||||
return typeof value === STRING ? parseInt(value) : value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use getTagValue instead.
|
||||
*/
|
||||
getRawValue(tagOrProperty, defaultValue) {
|
||||
return this.getTagValue(tagOrProperty, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function should be overriden by specialized classes in order to allow client libraries or viewers to take advantage of the Study Metadata API.
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { InstanceMetadata } from './InstanceMetadata';
|
||||
import { DICOMTagDescriptions } from '../../utils/DICOMTagDescriptions.js';
|
||||
import getImageId from '../../utils/getImageId.js';
|
||||
|
||||
export class OHIFInstanceMetadata extends InstanceMetadata {
|
||||
@@ -20,7 +19,7 @@ export class OHIFInstanceMetadata extends InstanceMetadata {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: instance.sopInstanceUid,
|
||||
value: instance.SOPInstanceUID,
|
||||
},
|
||||
_study: {
|
||||
configurable: false,
|
||||
@@ -56,16 +55,16 @@ export class OHIFInstanceMetadata extends InstanceMetadata {
|
||||
return this._cache[tagOrProperty];
|
||||
}
|
||||
|
||||
const propertyName = OHIFInstanceMetadata.getPropertyName(tagOrProperty);
|
||||
const instanceData = this._instance.metadata;
|
||||
|
||||
// Search property value in the whole study metadata chain...
|
||||
let rawValue;
|
||||
if (propertyName in this._instance) {
|
||||
rawValue = this._instance[propertyName];
|
||||
} else if (propertyName in this._series) {
|
||||
rawValue = this._series[propertyName];
|
||||
} else if (propertyName in this._study) {
|
||||
rawValue = this._study[propertyName];
|
||||
if (tagOrProperty in instanceData) {
|
||||
rawValue = instanceData[tagOrProperty];
|
||||
} else if (tagOrProperty in this._series) {
|
||||
rawValue = this._series[tagOrProperty];
|
||||
} else if (tagOrProperty in this._study) {
|
||||
rawValue = this._study[tagOrProperty];
|
||||
}
|
||||
|
||||
if (rawValue !== void 0) {
|
||||
@@ -79,12 +78,10 @@ export class OHIFInstanceMetadata extends InstanceMetadata {
|
||||
|
||||
// Override
|
||||
tagExists(tagOrProperty) {
|
||||
const propertyName = OHIFInstanceMetadata.getPropertyName(tagOrProperty);
|
||||
|
||||
return (
|
||||
propertyName in this._instance ||
|
||||
propertyName in this._series ||
|
||||
propertyName in this._study
|
||||
tagOrProperty in this._instance.metadata ||
|
||||
tagOrProperty in this._series ||
|
||||
tagOrProperty in this._study
|
||||
);
|
||||
}
|
||||
|
||||
@@ -97,28 +94,4 @@ export class OHIFInstanceMetadata extends InstanceMetadata {
|
||||
|
||||
return this._imageId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
let propertyName;
|
||||
const tagInfo = DICOMTagDescriptions.find(tagOrProperty);
|
||||
|
||||
if (tagInfo !== void 0) {
|
||||
// This function tries to translate standard DICOM property names into local naming convention.
|
||||
propertyName = tagInfo.keyword
|
||||
.replace(/^SOP/, 'sop')
|
||||
.replace(/UID$/, 'Uid')
|
||||
.replace(/ID$/, 'Id');
|
||||
propertyName =
|
||||
propertyName.charAt(0).toLowerCase() + propertyName.substr(1);
|
||||
}
|
||||
|
||||
return propertyName;
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ export class OHIFSeriesMetadata extends SeriesMetadata {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: series.seriesInstanceUid,
|
||||
value: series.SeriesInstanceUID,
|
||||
});
|
||||
|
||||
// populate internal list of instances...
|
||||
|
||||
@@ -18,11 +18,11 @@ export class OHIFStudyMetadata extends StudyMetadata {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: study.studyInstanceUid,
|
||||
value: study.StudyInstanceUID,
|
||||
});
|
||||
|
||||
// populate internal list of series
|
||||
study.seriesList.forEach(series => {
|
||||
study.series.forEach(series => {
|
||||
this.addSeries(new OHIFSeriesMetadata(series, study));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -83,10 +83,10 @@ well (again, flexibility and extensibility are design goals). Most implemented
|
||||
methods rely on the implementation of an unimplemented method. For example, the
|
||||
method `getStringValue` from `InstanceMetadata` class, which has indeed been
|
||||
implemented and is meant to retrieve a metadata value as a string, internally
|
||||
calls the `getRawValue` method which _was NOT implemented_ and is meant to query
|
||||
calls the `getTagValue` method which _was NOT implemented_ and is meant to query
|
||||
the internal data structures for the requested metadata value and return it _as
|
||||
is_. Used in that way, an application would not benefit much from the already
|
||||
implemented methods. On the other hand, by simply overriding the `getRawValue`
|
||||
implemented methods. On the other hand, by simply overriding the `getTagValue`
|
||||
method on a specialized class to deal with the intrinsics of its internal data
|
||||
structures, this very application would now benefit from all already implemented
|
||||
methods.
|
||||
@@ -99,12 +99,12 @@ The following code snippet tries to illustrate the idea:
|
||||
|
||||
class InstanceMetadata {
|
||||
[ ... ]
|
||||
getRawValue(tagOrProperty, defaultValue) {
|
||||
getTagValue(tagOrProperty, defaultValue) {
|
||||
// Please implement this method in a specialized subclass...
|
||||
}
|
||||
[ ... ]
|
||||
getStringValue(tagOrProperty, index, defaultValue) {
|
||||
let rawValue = this.getRawValue(tagOrProperty, '');
|
||||
let rawValue = this.getTagValue(tagOrProperty, '');
|
||||
// parse the returned value into a string...
|
||||
[ ... ]
|
||||
return stringValue;
|
||||
@@ -117,11 +117,11 @@ class InstanceMetadata {
|
||||
class MyFancyAppInstanceMetadata extends InstanceMetadata {
|
||||
// Overriding this method will make all methods implemented in the super class
|
||||
// that rely on it to be immediately available...
|
||||
getRawValue(tagOrProperty, defaultValue) {
|
||||
let rawValue;
|
||||
getTagValue(tagOrProperty, defaultValue) {
|
||||
let tagValue;
|
||||
// retrieve raw value from internal data structures...
|
||||
[ ... ]
|
||||
return rawValue;
|
||||
return tagValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,9 +135,9 @@ if (sopInstaceMetadata instanceof MyFancyAppInstanceMetadata) { // true
|
||||
if (sopInstaceMetadata instanceof InstanceMetadata) { // also true
|
||||
// this code will also be executed...
|
||||
}
|
||||
// The following will also work since the internal "getRawValue" call inside
|
||||
// The following will also work since the internal "getTagValue" call inside
|
||||
// "getStringValue" method will now be satisfied... (thanks to the override)
|
||||
let patientName = sopInstaceMetadata.getStringValue('PatientName', '');
|
||||
let PatientName = sopInstaceMetadata.getStringValue('PatientName', '');
|
||||
[ ... ]
|
||||
|
||||
```
|
||||
|
||||
@@ -110,14 +110,14 @@ export class StudyMetadata extends Metadata {
|
||||
return;
|
||||
}
|
||||
|
||||
const sopClassUids = getSopClassUids(series);
|
||||
const sopClassUIDs = getSopClassUIDs(series);
|
||||
|
||||
if (sopClassHandlerModules && sopClassHandlerModules.length > 0) {
|
||||
const displaySet = _getDisplaySetFromSopClassModule(
|
||||
sopClassHandlerModules,
|
||||
series,
|
||||
study,
|
||||
sopClassUids
|
||||
sopClassUIDs
|
||||
);
|
||||
if (displaySet) {
|
||||
displaySet.sopClassModule = true;
|
||||
@@ -135,10 +135,10 @@ export class StudyMetadata extends Metadata {
|
||||
// series into another display set.
|
||||
const stackableInstances = [];
|
||||
series.forEachInstance(instance => {
|
||||
// All imaging modalities must have a valid value for sopClassUid (x00080016) or rows (x00280010)
|
||||
// All imaging modalities must have a valid value for SOPClassUID (x00080016) or Rows (x00280010)
|
||||
if (
|
||||
!isImage(instance.getRawValue('x00080016')) &&
|
||||
!instance.getRawValue('x00280010')
|
||||
!isImage(instance.getTagValue('SOPClassUID')) &&
|
||||
!instance.getTagValue('Rows')
|
||||
) {
|
||||
return;
|
||||
}
|
||||
@@ -149,23 +149,23 @@ export class StudyMetadata extends Metadata {
|
||||
displaySet = makeDisplaySet(series, [instance]);
|
||||
|
||||
displaySet.setAttributes({
|
||||
sopClassUids,
|
||||
sopClassUIDs,
|
||||
isClip: true,
|
||||
seriesInstanceUid: series.getSeriesInstanceUID(),
|
||||
studyInstanceUid: study.getStudyInstanceUID(), // Include the study instance Uid for drag/drop purposes
|
||||
numImageFrames: instance.getRawValue('x00280008'), // Override the default value of instances.length
|
||||
instanceNumber: instance.getRawValue('x00200013'), // Include the instance number
|
||||
acquisitionDatetime: instance.getRawValue('x0008002a'), // Include the acquisition datetime
|
||||
SeriesInstanceUID: series.getSeriesInstanceUID(),
|
||||
StudyInstanceUID: study.getStudyInstanceUID(), // Include the study instance UID for drag/drop purposes
|
||||
numImageFrames: instance.getTagValue('NumberOfFrames'), // Override the default value of instances.length
|
||||
InstanceNumber: instance.getTagValue('InstanceNumber'), // Include the instance number
|
||||
AcquisitionDatetime: instance.getTagValue('AcquisitionDateTime'), // Include the acquisition datetime
|
||||
});
|
||||
displaySets.push(displaySet);
|
||||
} else if (isSingleImageModality(instance.modality)) {
|
||||
} else if (isSingleImageModality(instance.Modality)) {
|
||||
displaySet = makeDisplaySet(series, [instance]);
|
||||
displaySet.setAttributes({
|
||||
sopClassUids,
|
||||
studyInstanceUid: study.getStudyInstanceUID(), // Include the study instance Uid
|
||||
seriesInstanceUid: series.getSeriesInstanceUID(),
|
||||
instanceNumber: instance.getRawValue('x00200013'), // Include the instance number
|
||||
acquisitionDatetime: instance.getRawValue('x0008002a'), // Include the acquisition datetime
|
||||
sopClassUIDs,
|
||||
StudyInstanceUID: study.getStudyInstanceUID(), // Include the study instance UID
|
||||
SeriesInstanceUID: series.getSeriesInstanceUID(),
|
||||
InstanceNumber: instance.getTagValue('InstanceNumber'), // Include the instance number
|
||||
AcquisitionDatetime: instance.getTagValue('AcquisitionDateTime'), // Include the acquisition datetime
|
||||
});
|
||||
displaySets.push(displaySet);
|
||||
} else {
|
||||
@@ -175,9 +175,9 @@ export class StudyMetadata extends Metadata {
|
||||
|
||||
if (stackableInstances.length) {
|
||||
const displaySet = makeDisplaySet(series, stackableInstances);
|
||||
displaySet.setAttribute('studyInstanceUid', study.getStudyInstanceUID());
|
||||
displaySet.setAttribute('StudyInstanceUID', study.getStudyInstanceUID());
|
||||
displaySet.setAttributes({
|
||||
sopClassUids,
|
||||
sopClassUIDs,
|
||||
});
|
||||
displaySets.push(displaySet);
|
||||
}
|
||||
@@ -416,7 +416,7 @@ export class StudyMetadata extends Metadata {
|
||||
* needs series sorted by the same criteria used for sorting display sets.
|
||||
*/
|
||||
sortSeriesByDisplaySets() {
|
||||
// Object for mapping display sets' index by seriesInstanceUid
|
||||
// Object for mapping display sets' index by SeriesInstanceUID
|
||||
const displaySetsMapping = {};
|
||||
|
||||
// Loop through each display set to create the mapping
|
||||
@@ -428,8 +428,8 @@ export class StudyMetadata extends Metadata {
|
||||
}
|
||||
|
||||
// In case of multiframe studies, just get the first index occurence
|
||||
if (displaySetsMapping[displaySet.seriesInstanceUid] === void 0) {
|
||||
displaySetsMapping[displaySet.seriesInstanceUid] = index;
|
||||
if (displaySetsMapping[displaySet.SeriesInstanceUID] === void 0) {
|
||||
displaySetsMapping[displaySet.SeriesInstanceUID] = index;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -581,8 +581,7 @@ export class StudyMetadata extends Metadata {
|
||||
const dwc = api.DICOMwebClient;
|
||||
|
||||
const isMultiFrame = instance => {
|
||||
// NumberOfFrames (0028,0008)
|
||||
return instance.getRawValue('x00280008') > 1;
|
||||
return instance.getTagValue('NumberOfFrames') > 1;
|
||||
};
|
||||
|
||||
const makeDisplaySet = (series, instances) => {
|
||||
@@ -592,15 +591,15 @@ const makeDisplaySet = (series, instances) => {
|
||||
|
||||
// set appropriate attributes to image set...
|
||||
imageSet.setAttributes({
|
||||
displaySetInstanceUid: imageSet.uid, // create a local alias for the imageSet UID
|
||||
seriesDate: seriesData.seriesDate,
|
||||
seriesTime: seriesData.seriesTime,
|
||||
seriesInstanceUid: series.getSeriesInstanceUID(),
|
||||
seriesNumber: instance.getRawValue('x00200011'),
|
||||
seriesDescription: instance.getRawValue('x0008103e'),
|
||||
displaySetInstanceUID: imageSet.uid, // create a local alias for the imageSet UID
|
||||
SeriesDate: seriesData.SeriesDate,
|
||||
SeriesTime: seriesData.SeriesTime,
|
||||
SeriesInstanceUID: series.getSeriesInstanceUID(),
|
||||
SeriesNumber: instance.getTagValue('SeriesNumber'),
|
||||
SeriesDescription: instance.getTagValue('SeriesDescription'),
|
||||
numImageFrames: instances.length,
|
||||
frameRate: instance.getRawValue('x00181063'),
|
||||
modality: instance.getRawValue('x00080060'),
|
||||
frameRate: instance.getTagValue('FrameTime'),
|
||||
Modality: instance.getTagValue('Modality'),
|
||||
isMultiFrame: isMultiFrame(instance),
|
||||
});
|
||||
|
||||
@@ -610,19 +609,19 @@ const makeDisplaySet = (series, instances) => {
|
||||
imageSet.sortBy((a, b) => {
|
||||
// Sort by InstanceNumber (0020,0013)
|
||||
return (
|
||||
(parseInt(a.getRawValue('x00200013', 0)) || 0) -
|
||||
(parseInt(b.getRawValue('x00200013', 0)) || 0)
|
||||
(parseInt(a.getTagValue('InstanceNumber', 0)) || 0) -
|
||||
(parseInt(b.getTagValue('InstanceNumber', 0)) || 0)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// Include the first image instance number (after sorted)
|
||||
imageSet.setAttribute(
|
||||
'instanceNumber',
|
||||
imageSet.getImage(0).getRawValue('x00200013')
|
||||
'InstanceNumber',
|
||||
imageSet.getImage(0).getTagValue('InstanceNumber')
|
||||
);
|
||||
|
||||
const isReconstructable = isDisplaySetReconstructable(series, instances);
|
||||
const isReconstructable = isDisplaySetReconstructable(instances);
|
||||
|
||||
imageSet.isReconstructable = isReconstructable.value;
|
||||
|
||||
@@ -635,57 +634,57 @@ const makeDisplaySet = (series, instances) => {
|
||||
return imageSet;
|
||||
};
|
||||
|
||||
const isSingleImageModality = modality => {
|
||||
return modality === 'CR' || modality === 'MG' || modality === 'DX';
|
||||
const isSingleImageModality = Modality => {
|
||||
return Modality === 'CR' || Modality === 'MG' || Modality === 'DX';
|
||||
};
|
||||
|
||||
function getSopClassUids(series) {
|
||||
const uniqueSopClassUidsInSeries = new Set();
|
||||
function getSopClassUIDs(series) {
|
||||
const uniqueSopClassUIDsInSeries = new Set();
|
||||
series.forEachInstance(instance => {
|
||||
const instanceSopClassUid = instance.getRawValue('x00080016');
|
||||
const instanceSopClassUID = instance.getTagValue('SOPClassUID');
|
||||
|
||||
uniqueSopClassUidsInSeries.add(instanceSopClassUid);
|
||||
uniqueSopClassUIDsInSeries.add(instanceSopClassUID);
|
||||
});
|
||||
const sopClassUids = Array.from(uniqueSopClassUidsInSeries);
|
||||
const sopClassUIDs = Array.from(uniqueSopClassUIDsInSeries);
|
||||
|
||||
return sopClassUids;
|
||||
return sopClassUIDs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {SeriesMetadata} series
|
||||
* @param {StudyMetadata} study
|
||||
* @param {string[]} sopClassUids
|
||||
* @param {string[]} sopClassUIDs
|
||||
*/
|
||||
function _getDisplaySetFromSopClassModule(
|
||||
sopClassHandlerExtensions, // TODO: Update Usage
|
||||
series,
|
||||
study,
|
||||
sopClassUids
|
||||
sopClassUIDs
|
||||
) {
|
||||
// TODO: For now only use the plugins if all instances have the same sopClassUid
|
||||
if (sopClassUids.length !== 1) {
|
||||
// TODO: For now only use the plugins if all instances have the same SOPClassUID
|
||||
if (sopClassUIDs.length !== 1) {
|
||||
console.warn(
|
||||
'getDisplaySetFromSopClassPlugin: More than one SOPClassUid in the same series is not yet supported.'
|
||||
'getDisplaySetFromSopClassPlugin: More than one SOPClassUID in the same series is not yet supported.'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const sopClassUid = sopClassUids[0];
|
||||
const SOPClassUID = sopClassUIDs[0];
|
||||
const sopClassHandlerModules = sopClassHandlerExtensions.map(extension => {
|
||||
return extension.module;
|
||||
});
|
||||
|
||||
const handlersForSopClassUid = sopClassHandlerModules.filter(module => {
|
||||
return module.sopClassUids.includes(sopClassUid);
|
||||
const handlersForSopClassUID = sopClassHandlerModules.filter(module => {
|
||||
return module.sopClassUIDs.includes(SOPClassUID);
|
||||
});
|
||||
|
||||
// TODO: Sort by something, so we can determine which plugin to use
|
||||
if (!handlersForSopClassUid || !handlersForSopClassUid.length) {
|
||||
if (!handlersForSopClassUID || !handlersForSopClassUID.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
const plugin = handlersForSopClassUid[0];
|
||||
const plugin = handlersForSopClassUID[0];
|
||||
const headers = DICOMWeb.getAuthorizationHeader();
|
||||
const dicomWebClient = new dwc({
|
||||
url: study.getData().wadoRoot,
|
||||
@@ -698,15 +697,15 @@ function _getDisplaySetFromSopClassModule(
|
||||
dicomWebClient,
|
||||
headers
|
||||
);
|
||||
if (displaySet && !displaySet.modality) {
|
||||
if (displaySet && !displaySet.Modality) {
|
||||
const instance = series.getFirstInstance();
|
||||
displaySet.modality = instance.getRawValue('x00080060');
|
||||
displaySet.Modality = instance.getTagValue('Modality');
|
||||
}
|
||||
return displaySet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort series primarily by modality (i.e., series with references to other
|
||||
* Sort series primarily by Modality (i.e., series with references to other
|
||||
* series like SEG, KO or PR are grouped in the end of the list) and then by
|
||||
* series number:
|
||||
*
|
||||
@@ -724,8 +723,8 @@ function _getDisplaySetFromSopClassModule(
|
||||
*/
|
||||
|
||||
function seriesSortingCriteria(a, b) {
|
||||
const isLowPriorityA = isLowPriorityModality(a.modality);
|
||||
const isLowPriorityB = isLowPriorityModality(b.modality);
|
||||
const isLowPriorityA = isLowPriorityModality(a.Modality);
|
||||
const isLowPriorityB = isLowPriorityModality(b.Modality);
|
||||
if (!isLowPriorityA && isLowPriorityB) {
|
||||
return -1;
|
||||
}
|
||||
@@ -742,7 +741,7 @@ function seriesSortingCriteria(a, b) {
|
||||
*/
|
||||
function sortBySeriesNumber(a, b) {
|
||||
const seriesNumberAIsGreaterOrUndefined =
|
||||
a.seriesNumber > b.seriesNumber || (!a.seriesNumber && b.seriesNumber);
|
||||
a.SeriesNumber > b.SeriesNumber || (!a.SeriesNumber && b.SeriesNumber);
|
||||
|
||||
return seriesNumberAIsGreaterOrUndefined ? 1 : -1;
|
||||
}
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
import { Metadata } from './Metadata';
|
||||
import { DICOMTagDescriptions } from '../../utils/DICOMTagDescriptions';
|
||||
|
||||
/**
|
||||
* Constants
|
||||
*/
|
||||
|
||||
const STUDY_INSTANCE_UID = 'x0020000d';
|
||||
|
||||
/**
|
||||
* Class Definition
|
||||
*/
|
||||
|
||||
export class StudySummary extends Metadata {
|
||||
constructor(tagMap, attributeMap, uid) {
|
||||
// Call the superclass constructor passing an plain object with no prototype to be used as the main "_data" attribute.
|
||||
const _data = Object.create(null);
|
||||
super(_data, uid);
|
||||
|
||||
// Initialize internal tag map if first argument is given.
|
||||
if (tagMap !== void 0) {
|
||||
this.addTags(tagMap);
|
||||
}
|
||||
|
||||
// Initialize internal property map if second argument is given.
|
||||
if (attributeMap !== void 0) {
|
||||
this.setCustomAttributes(attributeMap);
|
||||
}
|
||||
}
|
||||
|
||||
getStudyInstanceUID() {
|
||||
// This method should return null if StudyInstanceUID is not available to keep compatibility StudyMetadata API
|
||||
return this.getTagValue(STUDY_INSTANCE_UID) || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Append tags to internal tag map.
|
||||
* @param {Object} tagMap An object whose own properties will be used as tag values and appended to internal tag map.
|
||||
*/
|
||||
addTags(tagMap) {
|
||||
const _hasOwn = Object.prototype.hasOwnProperty;
|
||||
const _data = this._data;
|
||||
for (let tag in tagMap) {
|
||||
if (_hasOwn.call(tagMap, tag)) {
|
||||
const description = DICOMTagDescriptions.find(tag);
|
||||
// When a description is available, use its tag as internal key...
|
||||
if (description) {
|
||||
_data[description.tag] = tagMap[tag];
|
||||
} else {
|
||||
_data[tag] = tagMap[tag];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tagExists(tagName) {
|
||||
const _data = this._data;
|
||||
const description = DICOMTagDescriptions.find(tagName);
|
||||
if (description) {
|
||||
return description.tag in _data;
|
||||
}
|
||||
return tagName in _data;
|
||||
}
|
||||
|
||||
getTagValue(tagName) {
|
||||
const _data = this._data;
|
||||
const description = DICOMTagDescriptions.find(tagName);
|
||||
if (description) {
|
||||
return _data[description.tag];
|
||||
}
|
||||
return _data[tagName];
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
export class WadoRsMetaDataBuilder {
|
||||
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;
|
||||
let value = tag.value;
|
||||
|
||||
if (value == null || (value.length === 1 && value[0] == null)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof value === 'string' && multi) {
|
||||
value = value.split('\\');
|
||||
}
|
||||
|
||||
if (!Array.isArray(value)) {
|
||||
value = [value];
|
||||
}
|
||||
|
||||
json[key] = {
|
||||
Value: value,
|
||||
};
|
||||
});
|
||||
|
||||
return json;
|
||||
}
|
||||
}
|
||||
@@ -5,13 +5,9 @@ import { OHIFSeriesMetadata } from './OHIFSeriesMetadata';
|
||||
import { OHIFStudyMetadata } from './OHIFStudyMetadata';
|
||||
import { SeriesMetadata } from './SeriesMetadata';
|
||||
import { StudyMetadata } from './StudyMetadata';
|
||||
import { StudySummary } from './StudySummary';
|
||||
import { WadoRsMetaDataBuilder } from './WadoRsMetaDataBuilder';
|
||||
|
||||
const metadata = {
|
||||
Metadata,
|
||||
StudySummary,
|
||||
WadoRsMetaDataBuilder,
|
||||
StudyMetadata,
|
||||
SeriesMetadata,
|
||||
InstanceMetadata,
|
||||
@@ -22,8 +18,6 @@ const metadata = {
|
||||
|
||||
export {
|
||||
Metadata,
|
||||
StudySummary,
|
||||
WadoRsMetaDataBuilder,
|
||||
StudyMetadata,
|
||||
SeriesMetadata,
|
||||
InstanceMetadata,
|
||||
|
||||
Reference in new issue
Block a user