From a9950802eee40102c4a4317b5ef48071df94a480 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 30 Oct 2023 16:41:47 +0000 Subject: [PATCH] allowing spliting by tag --- atlas/api.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/atlas/api.py b/atlas/api.py index 3de73fcc..9f7cc9f8 100644 --- a/atlas/api.py +++ b/atlas/api.py @@ -247,12 +247,20 @@ def view_dicom_tags(request, hash: str): def series_split_by_tag(request, series_id: int, dicom_tag:str): series = get_object_or_404(Series, pk=series_id) + if dicom_tag.startswith("(") and dicom_tag.endswith(")"): + dicom_tag = tuple([hex(int(i.strip(),16)) for i in dicom_tag[1:-1].split(",")]) + + print("1", dicom_tag) + image_map = defaultdict(list) # Split teh associated images for image in series.images.all(): + print(image) ds = image.get_dicom_data() + print("2a", ds[dicom_tag]) + if dicom_tag in ds: val = ds[dicom_tag].value @@ -261,7 +269,7 @@ def series_split_by_tag(request, series_id: int, dicom_tag:str): else: image_map[val].append(image) else: - return {f"{dicom_tag} not found"} + return [f"{dicom_tag} not found"] new_series = [] case = series.case.all()