Improve registration fusion interaction
This commit is contained in:
@@ -996,6 +996,8 @@ def dicom_fusion_volume(
|
||||
series_uid: str,
|
||||
center_index: int = 0,
|
||||
window: str = "soft",
|
||||
detail: str = "high",
|
||||
texture_size: int | None = Query(default=None, ge=128, le=1024),
|
||||
radius: int = Query(default=96, ge=4, le=512),
|
||||
range_start: int | None = None,
|
||||
range_end: int | None = None,
|
||||
@@ -1014,19 +1016,22 @@ def dicom_fusion_volume(
|
||||
else:
|
||||
start = max(0, center_index - radius)
|
||||
end = min(total - 1, center_index + radius)
|
||||
max_frames = 72
|
||||
max_frames = {"low": 48, "medium": 64, "high": 80}.get(str(detail).lower(), 64)
|
||||
if end - start + 1 > max_frames:
|
||||
step = int(np.ceil((end - start + 1) / max_frames))
|
||||
indices = list(range(start, end + 1, step))
|
||||
else:
|
||||
indices = list(range(start, end + 1))
|
||||
sample_ds = datasets[center_index]
|
||||
focus_index = min(max(center_index, start), end)
|
||||
indices = sorted({*indices, start, end, focus_index})
|
||||
sample_ds = datasets[focus_index]
|
||||
center, width = window_values(sample_ds, window)
|
||||
max_texture_size = int(texture_size or {"low": 384, "medium": 512, "high": 768}.get(str(detail).lower(), 512))
|
||||
frames = []
|
||||
frame_width = 0
|
||||
frame_height = 0
|
||||
for index in indices:
|
||||
png = render_array(stack[index], center, width, max_size=256, spacing=(stack_data["row_spacing"], stack_data["col_spacing"]))
|
||||
png = render_array(stack[index], center, width, max_size=max_texture_size, spacing=(stack_data["row_spacing"], stack_data["col_spacing"]))
|
||||
frames.append("data:image/png;base64," + base64.b64encode(png).decode("ascii"))
|
||||
if not frame_width:
|
||||
with Image.open(io.BytesIO(png)) as pil:
|
||||
@@ -1036,7 +1041,7 @@ def dicom_fusion_volume(
|
||||
"indices": indices,
|
||||
"start": start,
|
||||
"end": end,
|
||||
"center": center_index,
|
||||
"center": focus_index,
|
||||
"total": total,
|
||||
"width": frame_width,
|
||||
"height": frame_height,
|
||||
|
||||
Reference in New Issue
Block a user