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):
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user