Skip to content

Commit

Permalink
Fix DICOM JSON generator and add accessors
Browse files Browse the repository at this point in the history
  • Loading branch information
sedghi committed Nov 10, 2023
1 parent 6fac359 commit 64f81f7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
9 changes: 5 additions & 4 deletions .scripts/dicom-json-generator.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This script uses nodejs to generate a JSON file from a DICOM study folder.
* You need to have dcmjs installed in your project.
* The JSON file will can be used to load the study into the OHIF Viewer. You can get more detail
* The JSON file can be used to load the study into the OHIF Viewer. You can get more detail
* in the DICOM JSON Data source on docs.ohif.org
*
* Usage: node dicomStudyToJSONLaunch.js <studyFolder> <urlPrefix> <outputJSONPath>
Expand Down Expand Up @@ -78,7 +78,9 @@ async function recursiveReadDir(dir) {
}

function createImageId(fileLocation, urlPrefix, studyDirectory) {
return `dicomweb:${urlPrefix}${fileLocation.replace(studyDirectory, '')}`;
const relativePath = path.relative(studyDirectory, fileLocation);
const normalizedPath = path.normalize(relativePath).replace(/\\/g, '/');
return `dicomweb:${urlPrefix}${normalizedPath}`;
}

function processInstance(instance) {
Expand Down Expand Up @@ -188,7 +190,6 @@ function commonMetaData(instance) {
}

function conditionalMetaData(instance) {
debugger;
return {
...(instance.ConceptNameCodeSequence && {
ConceptNameCodeSequence: instance.ConceptNameCodeSequence,
Expand Down Expand Up @@ -253,7 +254,7 @@ function createInstanceMetaDataMultiFrame(instance) {
const commonData = commonMetaData(instance);
const conditionalData = conditionalMetaData(instance);

for (let i = 1; i < instance.NumberOfFrames; i++) {
for (let i = 1; i <= instance.NumberOfFrames; i++) {
const metadata = { ...commonData, ...conditionalData };
const result = { metadata, url: instance.fileLocation + `?frame=${i}` };
instances.push(result);
Expand Down
4 changes: 1 addition & 3 deletions platform/core/src/utils/addAccessors.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ const handler = {
},

set: (obj, prop, value) => {
if (typeof prop === 'number') {
obj[prop] = value;
} else if (prop in obj) {
if (typeof prop === 'number' || prop in obj) {
obj[prop] = value;
} else {
obj[0][prop] = value;
Expand Down
2 changes: 1 addition & 1 deletion platform/docs/docs/configuration/url.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ WorkList by adding the `dataSources` query parameter.
```
Note1: You should pass the `sourceName` of the data source in the configuration file (not the friendly name nor the name)
Note2: Make sure that the configuration file you are using actually include that data source. You cannot use a data source from other configuration file.
Note2: Make sure that the configuration file you are using actually includes that data source. You cannot use a data source from another configuration file.
:::tip
Expand Down

0 comments on commit 64f81f7

Please sign in to comment.