Skip to content

Commit

Permalink
feat(anonymizer): export Array tagNamesToEmpty and modify cleanTags (#…
Browse files Browse the repository at this point in the history
…303)

* feat(anonymizer) - export Array tagNamesToEmpty and add parameter in function cleanTags -> manage the tags to anonymize/modify in dicom

* fix comma

* return a copy of the list tagsNameToEmpty and then pass in the lists as optional arguments to cleanTags

Co-authored-by: CASTELNEAU Julien <[email protected]>
  • Loading branch information
juliencastelneau and juliencastelneau authored Sep 13, 2022
1 parent f8911da commit 42a7ca7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
23 changes: 16 additions & 7 deletions src/anonymizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,19 +235,28 @@ var tagNamesToEmpty = [
"DataSetTrailingPadding"
];

export function cleanTags(dict) {
tagNamesToEmpty.forEach(function (tag) {
export function getTagsNameToEmpty() {
return [...tagNamesToEmpty];
}

export function cleanTags(
dict,
tagNamesToReplace,
customTagNamesToEmpty = undefined
) {
var tags =
customTagNamesToEmpty != undefined
? customTagNamesToEmpty
: tagNamesToEmpty;
tags.forEach(function (tag) {
var tagInfo = DicomMetaDictionary.nameMap[tag];
if (tagInfo && tagInfo.version != "PrivateTag") {
var tagNumber = tagInfo.tag,
tagString = Tag.fromPString(tagNumber).toCleanString();
if (dict[tagString]) {
log.log("empty tag " + tag);
var newValue;
if (tagString == "00100010") {
newValue = ["ANON^PATIENT"];
} else if (tagString == "00100020") {
newValue = ["ANONID"];
if (tagString in tagNamesToReplace) {
newValue = [tagNamesToReplace[tagString]];
} else {
newValue = [];
}
Expand Down
5 changes: 3 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import adapters from "./adapters/index.js";
import utilities from "./utilities/index.js";
import sr from "./sr/index.js";

import { cleanTags } from "./anonymizer.js";
import { cleanTags, getTagsNameToEmpty } from "./anonymizer.js";

let data = {
BitArray,
Expand Down Expand Up @@ -80,7 +80,8 @@ let normalizers = {
};

let anonymizer = {
cleanTags
cleanTags,
getTagsNameToEmpty
};

const dcmjs = {
Expand Down

0 comments on commit 42a7ca7

Please sign in to comment.