blairconrad / dicognito

A library and command line tool for anonymizing DICOM files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

datetime loading and storage

lmdulz opened this issue · comments

Hey @blairconrad,
I noticed, that you're loading in your datetimeanonymizer.py in both the methods _anonymize_date_and_time and _anonymize_datetime elements of a MultiValue into a list:
if isinstance(data_element.value, pydicom.multival.MultiValue):
datetimes = list([v for v in data_element.value])
but isn't the value of a MultiValue already a list?

later you store the altered values back concatenating them as a string:
new_dates_string = "\\".join(new_dates)
data_element.value = new_dates_string (line 98-100)

data_element.value = "\\".join(new_datetimes) (line 121)

but why? Shouldn't they be stored back as a list?

Hi, @lmdulz! Maybe you're right. What happens if you change the code?

Possibilities

  • I'm generally doing stuff wrong
  • older pydicom required something different
  • older Python required something different

So many options!

I'll take a gander if I can find some time.

While MultiValue objects aren't lists, they do act enough like list that there was no need to copy the individual values into a list, nor to serialize the results.
I don't really have enough interest to justify the time it would take to experiment with older versions of pydicom to see if this was not so in the past, so I'll just update the code and move on.

Thanks, @lmdulz.

Unfortunately I was mixing up, how single-values are stored accessing them with pydicom and dcmjs (JS) (in dcmjs tag values are stored in a list, either one or multiple in a multivalue)
But I saw that you knew that and solved it in your commits - Thank you that you're still taking the time to update that!

in dcmjs tag values are stored in a list, either one or multiple in a multivalue

I'm a little sad that pydicom didn't take a similar tack, but they probably had their reasons.
Cheerio.