feat(dicomJSON): Add Loading Other Display Sets and JSON Metadata Generation script (#3777)

This commit is contained in:
Alireza authored and GitHub committed 2023-11-10 16:51:23 -05:00
1 parent 5b513fd30e
commit 43b1c17209
9 files changed
+390 -3

No files matched your search

@@ -200,7 +200,11 @@ function _checkIfCanAddMeasurementsToDisplaySet(srDisplaySet, newDisplaySet, dat
return;
}
const { sopClassUids, images } = newDisplaySet;
if (newDisplaySet.unsupported) {
return;
}
const { sopClassUids } = newDisplaySet;
// Check if any have the newDisplaySet is the correct SOPClass.
unloadedMeasurements = unloadedMeasurements.filter(measurement =>
@@ -176,6 +176,7 @@ class DicomLoaderService {
authorizationHeaders,
wadoRoot,
wadoUri,
instance,
} = dataset;
// Retrieve wadors or just try to fetch wadouri
if (!someInvalidStrings(wadoRoot)) {
@@ -188,6 +189,13 @@ class DicomLoaderService {
);
} else if (!someInvalidStrings(wadoUri)) {
return fetchIt(wadoUri, { headers: authorizationHeaders });
} else if (!someInvalidStrings(instance?.url)) {
// make sure the url is absolute, remove the scope
// from it if it is not absolute. For instance it might be dicomweb:http://....
// and we need to remove the dicomweb: part
const url = instance.url;
const absoluteUrl = url.startsWith('http') ? url : url.substring(url.indexOf(':') + 1);
return fetchIt(absoluteUrl, { headers: authorizationHeaders });
}
}
@@ -25,6 +25,23 @@ let _store = {
// }
};
function wrapSequences(obj) {
return Object.keys(obj).reduce(
(acc, key) => {
if (typeof obj[key] === 'object' && obj[key] !== null) {
// Recursively wrap sequences for nested objects
acc[key] = wrapSequences(obj[key]);
} else {
acc[key] = obj[key];
}
if (key.endsWith('Sequence')) {
acc[key] = OHIF.utils.addAccessors(acc[key]);
}
return acc;
},
Array.isArray(obj) ? [] : {}
);
}
const getMetaDataByURL = url => {
return _store.urls.find(metaData => metaData.url === url);
};
@@ -190,8 +207,14 @@ function createDicomJSONApi(dicomJsonConfig) {
const numberOfSeries = series.length;
series.forEach((series, index) => {
const instances = series.instances.map(instance => {
// for instance.metadata if the key ends with sequence then
// we need to add a proxy to the first item in the sequence
// so that we can access the value of the sequence
// by using sequenceName.value
const modifiedMetadata = wrapSequences(instance.metadata);
const obj = {
...instance.metadata,
...modifiedMetadata,
url: instance.url,
imageId: instance.url,
...series,