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

PatientName and PatientID not getting properly replaced #46

Open
apt2000 opened this issue Jul 6, 2023 · 3 comments
Open

PatientName and PatientID not getting properly replaced #46

apt2000 opened this issue Jul 6, 2023 · 3 comments
Assignees

Comments

@apt2000
Copy link

apt2000 commented Jul 6, 2023

I used the following JSON file:
{
"(0x0010, 0x0010)": {
"action": "regexp",
"find": ".",
"replace": "ID001^ID002"
},
"(0x0010, 0x0020)": {
"action": "regexp",
"find": ".
",
"replace": "ID003"
},
}
In the anonymized DICOM files, the PatientID tag gets set to ID003ID003 (i.e. it is duplicated).
The PatientName tag is similarly duplicated and set to ID001^ID002ID001^ID002

@apt2000
Copy link
Author

apt2000 commented Jul 7, 2023

FYI. I am seeing this duplication issue only with DicomAnonymizer.exe. When I invoke anonymize() from Python code, it appears to behave correctly.

@pchoisel
Copy link
Collaborator

Hello @apt2000,

I suspect that this comes from the regexp.
"find": "." is going to take each character of the initial value and replace it with whatever is in replace.
So in my test file, 3860448 is replaced by ID003ID003ID003ID003ID003ID003ID003 (7xID003 because there are 7 characters in 3860448)

What do you intend to do with this regexp ?

@apt2000
Copy link
Author

apt2000 commented Jul 10, 2023

Hello @apt2000,

I suspect that this comes from the regexp. "find": "." is going to take each character of the initial value and replace it with whatever is in replace. So in my test file, 3860448 is replaced by ID003ID003ID003ID003ID003ID003ID003 (7xID003 because there are 7 characters in 3860448)

What do you intend to do with this regexp ?

Thanks for looking into this. I am just looking to simply replace, the original PatientID with something different. Is there a way to specify this in the JSON file? I don't think "find": "*" worked for me.

In Python code which works fine, I am just using:
def setupPatientID(dataset, tag):
element = dataset.get(tag)
if element is not None:
element.value = args.new_id

extraAnonymizationRules[(0x0010, 0x0020)] = setupPatientID

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

2 participants