Replies: 5 comments 2 replies
-
First problem is that your callback function iterates over the entire dataset. You need to pick one or the other -- I suggest using |
Beta Was this translation helpful? Give feedback.
-
Thanks for your help. I have tried exactly the same before and it dowsn't work for all tags in def _xa50_private_callback(dataset, data_element):
r'''
Callback function to find sensible private tags corresponding for
software version XA50, and remove all.
'''
tags_to_remove = [
(0x0021, 0x1019),
(0x0021, 0x1026),
(0x0021, 0x1171)
]
if data_element.tag in tags_to_remove:
del dataset[data_element.tag]
ds.walk(_xa50_private_callback) Or have I misunderstood something? |
Beta Was this translation helpful? Give feedback.
-
Several new thoughts:
|
Beta Was this translation helpful? Give feedback.
-
Thanks for the outputs, however I don't see anything obvious from them. However, the original SQ (0021, 10fe) doesn't appear to be in there.
I'm not entirely clear -- is it (consistently) working okay now? If not then perhaps if you could post the relevant code in your latest use of |
Beta Was this translation helpful? Give feedback.
-
Yes, so it's working consistently now across multiple studies with no issues. It was just me ;) So I understood that ds[(0x5200, 0x9230)][0][(0x0021, 0x11fe)][0][(0x0021, 0x1171)] And then delete the tags, right? I use an external config.py file for my function, in which I have stored all tags software specific. Here I would like to store the nested tags as well. How would one do that then? configurations = {
"PhoenixZIPReport": {
"blank_values": [
(0x0070, 0x0084), # content creator's name
(0x300E, 0x0008), # reviewer name
(0x0032, 0x1060), # requested procedure description
(0x0032, 0x1064), # requested procedure code sequence
(0x0021, 0x1011) # private tag (array)
],
"dummy_values": [
(0x0040, 0xA075), # Verifying Observer Name
(0x0040, 0xA088) # Verifying Observer Identification Code Sequence
]
},
"syngo MR XA50": {
"blank_values": [
(0x0010, 0x0032), # patient's birth time
(0x0070, 0x0084), # content creator's name
(0x300E, 0x0008), # reviewer name
(0x0032, 0x1060), # requested procedure description
(0x0032, 0x1064) # requested procedure code sequence
],
"dummy_values": [
(0x0040, 0xA075), # Verifying Observer Name
(0x0040, 0xA088) # Verifying Observer Identification Code Sequence
]
},
"default": {
"blank_values": [
(0x0070, 0x0084), # content creator's name
(0x300E, 0x0008), # reviewer name
(0x0032, 0x1060), # requested procedure description
(0x0032, 0x1064) # requested procedure code sequence
],
"dummy_values": [
(0x0040, 0xA075), # Verifying Observer Name
(0x0040, 0xA088) # Verifying Observer Identification Code Sequence
]
}
} |
Beta Was this translation helpful? Give feedback.
-
I want to delete specific DICOM tags in a DICOM file, which are contained in a nested tree and which is repeated over and over again, here is an excerpt:
I've tried several approaches before, but most recently my idea was to do it via a callback function and then use
walk(callback[, recursive])
from pydicom. So that I don't have this tree structure any longer I wanted to useiterall()→ Iterator[DataElement]
, so to say flatten the dataset.This way all tags from the tags_to_remove list will really be found. Now I want to delete them all, but as soon as I use
del dataset[data_element.tag]
I get the error:This is an extremely large DICOM header with about 7000 lines.
Beta Was this translation helpful? Give feedback.
All reactions