cornerstonejs / dicomParser

JavaScript parser for DICOM Part 10 data
MIT License
716 stars 230 forks source link

Dicom tag dict exposed in the lib #271

Closed SophieDel closed 3 months ago

SophieDel commented 3 months ago

Hi there,

Maybe I am missing something, but I don't see how to import the dicom tag dict that is used in the examples currently. Am I missing something...?

Plus, I am wondering why the name of the tag is not in the dataset...?

Thank you !

yagni commented 3 months ago

How you import the dictionary depends on how you deploy your app. The examples just load it via script tag (<script src="../dataDictionary.js"></script>) so that's one option. You can also include it in your build pipeline via something like webpack or rollup (note you'll need to add an export to the dataDictionary.js if you do this but that'll let you use import syntax). Either way, you'll need to add it manually to your own source code since it's not in the built version of the library, only in the examples directory.

Your second question is one that goes back to the beginning of the design of this library so @chafey will be the authority, but having the tags as the keys instead of their names gives a consistent way to access them regardless of whether a dictionary is provided. If you'd rather the keys be names, you can write a simple nested loop given a dataset and a dictionary that remaps the keys to their names.

SophieDel commented 3 months ago

Thank you @yagni ! For the first question, it was precisely about having an export of the dataDictionary.js file, which is cleaner and more consistent than a copy-paste in my source code. And for the second question, I was not wondering why the tag is not the key, but why the name is not in the object value associated to the key of the dataset. I can have it from the data dictionary, but I was wondering whether it is possible to retrieve the name of the attribute in a cleaner way.

Thank you !

yagni commented 3 months ago

@SophieDel I'm not aware of a cleaner way than looking them up in the dictionary as a post-process step. Also, there are no plans to export the data dictionary in order to keep the size of this library small.