I just realized there are some issues with my proposed solution:
- data_elem.keyword is only in the repository code, not in the last pydicom release. Would instead have to use 'from dicom.datadict import dictionary_keyword, and then use "mod_ds = {dictionary_keyword(data_elem.tag), ..."
- the solution won't work well for datasets with Sequences - it won't iterate into them. And if it did, each dataset in the sequence would have the same keywords, so each item in the sequence would overwrite the previous values by using the same dictionary key. Actually, this is true even if you don't convert the tag to a keyword -- each item in a sequence would generally have the same tags.
- it may have trouble with private data elements, which also may have repeated keywords
A more general solution would build the mod_ds dictionary using Dataset.walk(), and perhaps where needed modify keywords to add something (e.g. a sequence item index) to make them unique when adding to the dictionary.
However, for simple datasets with no sequences, I think what I wrote should work reasonably well, if the keyword lookup is fixed.
Hopefully what I've written above this time is correct -- nothing is based on tested code.
-Darcy