blairconrad / dicognito

A library and command line tool for anonymizing DICOM files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fails to anonymize object with Issue Date of Imaging Service Request

blairconrad opened this issue · comments

… because we look for "Date" at the beginning or end of the element name:

UnboundLocalError: With tag (200b, 102b) got exception: local variable 'time_name' referenced before assignment
Traceback (most recent call last):
  File "c:\program files\python37\lib\site-packages\pydicom\tag.py", line 30, in tag_in_exception
    yield
  File "c:\program files\python37\lib\site-packages\pydicom\dataset.py", line 1773, in walk
    callback(self, data_element)  # self = this Dataset
  File "c:\program files\python37\lib\site-packages\dicognito\anonymizer.py", line 120, in _anonymize_element
    if handler(dataset, data_element):
  File "c:\program files\python37\lib\site-packages\dicognito\datetimeanonymizer.py", line 43, in __call__
    self._anonymize_date_and_time(dataset, data_element)
  File "c:\program files\python37\lib\site-packages\dicognito\datetimeanonymizer.py", line 61, in _anonymize_date_and_time
    if time_name in dataset:
UnboundLocalError: local variable 'time_name' referenced before assignment

Scary, but probably best to just replace any "Date" with "Time" when looking for the element that encodes the time.