Skip to content

Tags "hidden" inside sequences #1692

Answered by mrbean-bremen
EllenWasbo asked this question in Q&A
Discussion options

You must be logged in to vote

I converted this to a discussion issue, as this comes up every now and then.

There is no build-in way to do this, but to get the common tags for enhanced image classes, you could write a convenience function, as these tags are always in a nested sequence inside the SharedFunctionalGroupsSequence:

def get_tag(ds, tag):
    if tag in ds:
        return ds[tag]
    if "SharedFunctionalGroupsSequence" in ds:
        item = ds.SharedFunctionalGroupsSequence[0]
        for element in item:
            if element.VR == "SQ":
                if element.value and tag in element.value[0]:
                    return element.value[0][tag]

This will return a DataElement object:

>>> ds = dcmread("my_en…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by EllenWasbo
Comment options

You must be logged in to vote
1 reply
@mrbean-bremen
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants
Converted from issue

This discussion was converted from issue #1690 on September 12, 2022 18:36.