allowing spliting by tag
This commit is contained in:
+9
-1
@@ -247,12 +247,20 @@ def view_dicom_tags(request, hash: str):
|
|||||||
def series_split_by_tag(request, series_id: int, dicom_tag:str):
|
def series_split_by_tag(request, series_id: int, dicom_tag:str):
|
||||||
series = get_object_or_404(Series, pk=series_id)
|
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)
|
image_map = defaultdict(list)
|
||||||
|
|
||||||
# Split teh associated images
|
# Split teh associated images
|
||||||
for image in series.images.all():
|
for image in series.images.all():
|
||||||
|
print(image)
|
||||||
ds = image.get_dicom_data()
|
ds = image.get_dicom_data()
|
||||||
|
|
||||||
|
print("2a", ds[dicom_tag])
|
||||||
|
|
||||||
if dicom_tag in ds:
|
if dicom_tag in ds:
|
||||||
val = ds[dicom_tag].value
|
val = ds[dicom_tag].value
|
||||||
|
|
||||||
@@ -261,7 +269,7 @@ def series_split_by_tag(request, series_id: int, dicom_tag:str):
|
|||||||
else:
|
else:
|
||||||
image_map[val].append(image)
|
image_map[val].append(image)
|
||||||
else:
|
else:
|
||||||
return {f"{dicom_tag} not found"}
|
return [f"{dicom_tag} not found"]
|
||||||
|
|
||||||
new_series = []
|
new_series = []
|
||||||
case = series.case.all()
|
case = series.case.all()
|
||||||
|
|||||||
Reference in New Issue
Block a user