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

feat(anonymizer) - export Array tagNamesToEmpty and modify cleanTags #303

Merged
merged 3 commits into from
Sep 13, 2022

Conversation

juliencastelneau
Copy link
Contributor

  • export Array tagNamesToEmpty => Modify (add or remove) values before calling cleanTags
  • add dict as parameter to function cleanTags => Choose which tags you want to modify for de-identification
    For instance, a call to anonymizer should be:
               const { cleanTags, tagNamesToEmpty } = dcmjs.anonymizer;

                var tagsToReplace = {
                    "00100010":   "ANON^PATIENT",
                    "00100020":   "ANON^ID"
                }
                var seriesDescription = "SeriesDescription";
                if (tagNamesToEmpty.indexOf(seriesDescription) != -1) {
                    tagNamesToEmpty.splice(tagNamesToEmpty.indexOf(seriesDescription), 1);
                } 
                var studyDescription = "StudyDescription";
                if (tagNamesToEmpty.indexOf(studyDescription) == -1) {
                    tagNamesToEmpty.push(studyDescription);
                } 

                cleanTags(dicomDict.dict, tagsToReplace);

CASTELNEAU Julien added 2 commits August 10, 2022 11:10
…function cleanTags -> manage the tags to anonymize/modify in dicom
Copy link
Collaborator

@pieper pieper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this 👍

src/anonymizer.js Outdated Show resolved Hide resolved
@juliencastelneau
Copy link
Contributor Author

Hello,
Is there an issue with the PR ?
@pieper I made the changes you requested.
Maybe I do not understand something. Do you want another modification ?
thx

@pieper pieper merged commit 42a7ca7 into dcmjs-org:master Sep 13, 2022
@pieper
Copy link
Collaborator

pieper commented Sep 13, 2022

Thanks for the contribution and the reminder 👍

@pieper
Copy link
Collaborator

pieper commented Sep 13, 2022

@juliencastelneau it looks like there's at least one error due to the anonymizer - could you have a look?

https://github.com/dcmjs-org/dcmjs/actions/runs/3047634658/jobs/4911834982#step:5:2486

@juliencastelneau
Copy link
Contributor Author

The test fails because I added an argument to the method cleanTags
I think there are 2 ways to solve.

  1. Modify the test:

Add the lines below in anonymizer.test.js (line 26)

    var tagsToReplace = {
        "00100010":   "ANON^PATIENT",
    }
    
    // when
    cleanTags(dicomDict.dict, tagsToReplace);

instead of

    cleanTags(dicomDict.dict);
  1. Modify the method cleanTags to ensure the behaviour is unchanged:
export function cleanTags(
    dict,
    tagNamesToReplace = undefined,
    customTagNamesToEmpty = undefined
) {
    
    if (tagNamesToReplace==undefined) {
         tagNamesToReplace = {
            "00100010":   "ANON^PATIENT",
            "00100020":   "ANON^ID"
         }
    }
    
    var tags =
        customTagNamesToEmpty != undefined
            ? customTagNamesToEmpty
            : tagNamesToEmpty;

@pieper The best way is to modify the method cleanTags I guess.
Do I need to make a new PR ?

@pieper
Copy link
Collaborator

pieper commented Sep 13, 2022

Thanks for looking into this. I think the second option is better since it maintains backwards compatibility for the API. We should also add a new test demonstrating the ways to use the method and confirm it keeps working.

Yes, a new PR would be great since this has already been merged.

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

Successfully merging this pull request may close these issues.

2 participants