suyashkumar/dicom

De-identify DICOM tags

vijaysubramanya opened this issue · 3 comments

I'm trying to update/de-identify some of the metadata tags (such as Patient ID). Is there a way to update the file directly without reading the file and writing back to the file? Currently, I'm reading the file into a variable, updating the elements, and writing back to a new file as below:

dataset, _ := dicom.ParseFile("dicom/1.dcm", nil)
    for _, elem := range dataset.Elements {
        s := reflect.TypeOf(elem.Value.GetValue()).Kind()
        if s == reflect.Slice {
            elem.Value, _ = dicom.NewValue([]string{"abc"})
        }
    }
    f, err := os.Open("test.dcm")
    err = dicom.Write(f, dataset)
    }

Hi there! At the moment, I'm not sure of a great way to safely update the file "in place" if that's what you want.

Something I would like to do is update the element-by-element parsing API (e.g. the Next() API on the parser) be more memory efficient by only holding onto the Dataset elements it needs for future parsing, and otherwise just transiently emitting the Elements one at a time.