Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tags duplication in meta and in DCM body #1740

Closed
alipairon opened this issue Dec 7, 2022 · 6 comments
Closed

Tags duplication in meta and in DCM body #1740

alipairon opened this issue Dec 7, 2022 · 6 comments

Comments

@alipairon
Copy link

Hello!
I came across this problem with a particular DICOM file.
The 0002,0010 tag occurs twice in the dataset.

image

If you do:

ds = pydicom.dcmread('badTSUID.dcm')
print(ds.file_meta.TransferSyntaxUID)

The output will be:

1.2.840.10008.1.2.1

If you do:

del ds.file_meta.TransferSyntaxUID

Both of the tags are deleted.

In this particular case the one that's in the file meta should be trusted.
I could use the del to delete them both and rewrite, but to do that I need to know the value of the tag in Meta to write the correct one.
I am not sure how to deal with this kind of cases correctly.
I've attached the anonymized dataset to this message.
Thank you!
badTSUID.zip

@mrbean-bremen
Copy link
Member

Hm, this is of course invalid DICOM, but I don't understand what you mean by "the one in the file meta". Meta tags are all group 2 tags, so both are are in the file meta, as far as I understand. I can see that it is shown in the dataset if using dcmdump, but this is probably not correct.
The only way to handle this is to ignore one of them (probably the second, which is in the wrong place anyway). Have you checked which one pydicom actually uses?

@alipairon
Copy link
Author

I am sorry my bad.
I have a language barrier and I do not yet fully understand the DICOM format due to inexperience.
pydicom always returns a tag with the value 1.2.840.10008.1.2.1 - probably because it is latest?
Can't find a way to reach the first one via pydicom.

@mrbean-bremen
Copy link
Member

No problem. Yes, I think the tag gets overwritten by the last one, so that one will be used. I'm not sure how expansive changing that behavior would be, and if it even makes sense to do this, but in principle I agree that in such a case the first tag shall be taken.
I'm quite sure we already had a similar issue with double tags, and wrong one taken, but I can't find it. @darcymason - maybe you remember this?

@darcymason
Copy link
Member

@darcymason - maybe you remember this?

Perhaps #820? I posted some 'fixer' code there which possibly could be adapted for this case. Maybe the fixer callback could somehow keep the first and remove the second -- I haven't actually looked into it in detail.

@mrbean-bremen
Copy link
Member

Perhaps #820? I posted some 'fixer' code there which possibly could be adapted for this case.

Thank you, that is exactly what I meant! Well, that fixed the crash that happened before that in this case, and got implicit/explicit transfer syntax mixup sorted, but in the current case this does not help. But maybe using the fixer could be enough here...

@darcymason
Copy link
Member

Closing this issue for now; I think (as noted in the #820 discussion) that checking for duplicate tags is too high a cost for a rare kind of invalid DICOM. The check for the actual transfer syntax was added, so should help. If someone can think of a more elegant solution we could bring it back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants