From 8a767a798d42d281ddb9a0304f36db1e5894d0b5 Mon Sep 17 00:00:00 2001 From: Julien Lamy Date: Mon, 11 Mar 2024 09:40:37 +0100 Subject: [PATCH] Fix repeated conversion of frame-specific elements --- src/python/dicomifier/dicom_to_nifti/meta_data.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/python/dicomifier/dicom_to_nifti/meta_data.py b/src/python/dicomifier/dicom_to_nifti/meta_data.py index 4bb8581..5f3ca46 100644 --- a/src/python/dicomifier/dicom_to_nifti/meta_data.py +++ b/src/python/dicomifier/dicom_to_nifti/meta_data.py @@ -96,11 +96,13 @@ def get_meta_data(stack, cache=None): if frame is not None: # Fetch frame-specific elements groups = data_set[odil.registry.PerFrameFunctionalGroupsSequence][frame] - _fill_meta_data_dictionary( - groups, - lambda tag, value: - elements.setdefault(tag, {}).update({i: value}), - skipped, no_recurse) + if tag not in elements or isinstance(elements[tag], dict): + _fill_meta_data_dictionary( + groups, + lambda tag, value: + elements.setdefault(tag, {}).update({i: value}), + skipped, no_recurse) + # Otherwise element has already been converted # Convert dictionary with possible holes to list: iteration is quicker. elements = {