dicom.raw.data.anonymizer: DICOM anonymizer

View source: R/dicom_raw_data_anonymizer.R

dicom.raw.data.anonymizerR Documentation

DICOM anonymizer

Description

the dicom.raw.data.anonymizer function anonymizes dicom.raw.data.

Usage

dicom.raw.data.anonymizer(
  dicom.raw.data,
  offset = 0,
  new.PIN = "ANONYMOUS^Unknown",
  reset.private.tag = FALSE,
  new.UID = FALSE,
  UID.white.list = "UID",
  UID.black.list = c("class", "context", "mapping", "coding"),
  tag.dictionary = dicom.tag.dictionary()
)

Arguments

dicom.raw.data

Raw vector, representing the binary extraction of the DICOM file.

offset

Integer, default to 0. Each date of the DICOM will be shifted by this offset expressed in days.

new.PIN

Character string, representing the PIN remplacing the old one.

reset.private.tag

Boolean, if TRUE, the value of tags that are not in the tag.dictionary is removed.

new.UID

Boolean. If TRUE, new UID are generated and replace the old ones.

UID.white.list

List of words or parts of DICOM names containing “UID”, defining UIDs that will be modified if new.UID is equal to TRUE. The default is “UID”.

UID.black.list

List of words or parts of DICOM names containing “UID”, defining UIDs that will not be modified if new.UID is equal to TRUE. The default is c("class", "context", "mapping", "coding").

tag.dictionary

Dataframe, by default equal to dicom.tag.dictionary, whose structure it must keep. This dataframe is used to parse DICOM files.

Value

Returns an anonymyzed raw vector. See Note.

Note

The raw data is anonymized as follows:

  • Each date of the DICOM file will be shifted by offset expressed in days.

  • Each patient's name, and patient'ID are remplaced by new.PIN

  • All other patient data are deleted, except age, weight, height, gender and shifted birthday.

  • All address, phone, physician, operator, author, reviewer, service.

  • If reset.private.tag = TRUE, the values of the tags not contained in the tag.dictionary are deleted.

Examples

# pseudomization of the dummy raw data toy.dicom.raw ()
an.raw.data <- dicom.raw.data.anonymizer (toy.dicom.raw (), offset = -2)
data <- dicom.parser (toy.dicom.raw ())
an.data <- dicom.parser (an.raw.data) 

# Checking for differences
flag.dif <- data$Value !=  an.data$Value  
df <- cbind (data[flag.dif, c ("VM","Value")], an.data[flag.dif, "Value"])      
colnames (df) <-   c ("VM","old Value","new Value")    
df                                     

# save data in a the new file
#############################
# new.file.name <- "an.dcm"
# zz <- file (new.file.name, "wb")
# writeBin (an.raw.data, zz, size = 1)
# close (zz)


espadon documentation built on April 11, 2025, 5:57 p.m.