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

Unexpected behavior on re-adding a private tag to a dataset after remove_private_tags #1097

Closed
eeilon79 opened this issue May 7, 2020 · 0 comments · Fixed by #1098
Closed
Labels

Comments

@eeilon79
Copy link

eeilon79 commented May 7, 2020

I've encountered this issue while trying to write a solution to #1087.
I'm trying to add a past private tag to a dataset that had all his private tags removed with remove_private_tags. It leads to a single element update - just the private tag data. No private creator element is added. Also, the private tag is updated on the second free block rather than the first - that's supposed to be free after remove_private_tags.
It seems the dataset preserves some information on past private creators blocks even after remove_private_tags.

I expect that a private creator element would be (re-)created if I'm trying to add a private tag, and that it would created on the first available place in the private group.

Reproducing code:

from pydicom import Dataset

ds = Dataset()
block = ds.private_block(0x000b, 'dog^1', create=True)
block.add_new(0x01, "SH", "Border Collie")
block = ds.private_block(0x000b, 'dog^2', create=True)
block.add_new(0x01, "SH", "Poodle")

ds.remove_private_tags()
block = ds.private_block(0x000b, 'dog^2', create=True)
block.add_new(0x01, "SH", "Poodle")
print(ds)

Output:

(000b, 1101) Private tag data                    SH: 'Poodle'`

Aa far as I understand, output should be:

(000b, 0010) Private Creator                     LO: 'dog^2'
(000b, 1001) Private tag data                    SH: 'Poodle'

My environment (Running with docker from PyCharm):
Linux-4.15.0-74-generic-x86_64-with-debian-buster-sid
Python 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 19:07:31)
[GCC 7.3.0]
pydicom 2.0.0.dev

mrbean-bremen added a commit to mrbean-bremen/pydicom that referenced this issue May 7, 2020
- try to minimize performance impact by removing all private blocks
  and checking for existing private blocks first
- fixes pydicom#1097
darcymason pushed a commit that referenced this issue May 12, 2020
* Invalidate private blocks on deleting private creator

- try to minimize performance impact by removing all private blocks
  and checking for existing private blocks first
- fixes #1097

* Add support for non-contiguous private blocks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants