in python/de-identifier/research_pacs/de_identifier/dicom.py [0:0]
def _find_transformations_to_apply(self):
"""
Generate a list of transformations to apply based on the DICOM file's matching labels.
It also determines if access to pixel data is needed to remove burned-in annotations,
and if OCR is requested.
"""
transformations = {}
remove_burned_in_annotations = False
use_ocr = False
for t in self._config['Transformations']:
# Check if the transformation should be apply based on the matching labels
if self._do_labels_match_scope_rules(self._matching_labels, t['Scope']) is True:
for key in t.keys():
if key == 'Transcode':
transformations[key] = t[key]
else:
transformations.setdefault(key, [])
transformations[key] += t[key]
# Check if access to pixel data and OCR are needed
if 'RemoveBurnedInAnnotations' in t.keys():
remove_burned_in_annotations = True
for element in t['RemoveBurnedInAnnotations']:
if element['Type'] == 'OCR':
use_ocr = True
return transformations, remove_burned_in_annotations, use_ocr