From 7fd7ae6733215dd563f1430f58aa8d5c44b72ea5 Mon Sep 17 00:00:00 2001 From: SantaSpeen Date: Thu, 22 Oct 2026 22:29:28 +0300 Subject: [PATCH] Add profile 3D preferences and adapt DICOM preview resolution to memory budget --- docs/dicom-viewer-options.md | 2 + frontend/scripts/check-dicom-preview.cjs | 46 ++++++++ frontend/src/components/files/DicomViewer.vue | 5 +- .../components/files/DicomVolumeViewer.vue | 15 ++- frontend/src/i18n/en.json | 16 ++- frontend/src/i18n/ru.json | 16 ++- frontend/src/types/user.d.ts | 7 ++ .../src/utils/__tests__/dicom-quality.test.ts | 67 ++++++++++++ frontend/src/utils/dicom-diagnostics.ts | 12 ++- frontend/src/utils/dicom-quality.ts | 101 ++++++++++++++++++ frontend/src/utils/dicom-series.ts | 5 +- frontend/src/utils/dicom-volume.ts | 56 +++++++--- frontend/src/views/settings/Profile.vue | 45 +++++++- http/auth.go | 33 +++--- http/sso.go | 2 +- http/sso_security_test.go | 34 ++++++ http/users.go | 2 +- scripts/build-release.ps1 | 2 +- scripts/build-release.sh | 2 +- users/dicom.go | 26 +++++ users/dicom_test.go | 25 +++++ users/users.go | 49 +++++---- 22 files changed, 500 insertions(+), 68 deletions(-) create mode 100644 frontend/src/utils/__tests__/dicom-quality.test.ts create mode 100644 frontend/src/utils/dicom-quality.ts create mode 100644 users/dicom.go create mode 100644 users/dicom_test.go diff --git a/docs/dicom-viewer-options.md b/docs/dicom-viewer-options.md index 5bd348a1..3de747d8 100644 --- a/docs/dicom-viewer-options.md +++ b/docs/dicom-viewer-options.md @@ -18,6 +18,8 @@ Объёмный режим включает вращение и масштабирование 3D, аксиальную/сагиттальную/корональную реконструкцию, прокрутку срезов, перемещение, яркость/контрастность и непрозрачность. Нужен WebGL2. На неподходящем устройстве сохраняется 2D. +В настройках профиля есть раздел **DICOM — 3D-просмотр**: качество (автоматическое, исходное, половинное, четверть), лимит памяти вокселей 128–1536 МиБ и начальная непрозрачность. Настройки хранятся в аккаунте. По умолчанию автоматический режим подбирает разрешение под 1536 МиБ: большие срезы уменьшаются билинейной интерполяцией с сохранением поля обзора, координат пациента и физического масштаба; все срезы сохраняются. В просмотрщике показывается уменьшенное разрешение. Исходные DICOM-файлы не изменяются. При выборе исходного или фиксированного качества превышение персонального лимита по-прежнему останавливает просмотр. + Ограничения: до 2048 файлов, 64 МиБ на исходный файл, 1,5 ГиБ суммарной загрузки и 1,5 ГиБ Float32-вокселей. Это лимит массива объёма, а не всей памяти браузера: сборка и GPU требуют дополнительной памяти. Файлы читаются последовательно только после нажатия кнопки, загрузку можно отменить. При закрытии удаляются движок, GPU-ресурсы и принадлежащие просмотру записи кеша. При запуске 3D в консоль браузера выводятся сообщения `[DICOM 3D]`: число файлов, общий и максимальный исходный размер, а после декодирования первого среза — размеры сетки и оценка Float32-объёма. При превышении лимита выводятся конкретная причина, фактическое значение и порог. Размеры указаны в байтах и ГиБ; пути, токены и медицинские теги не логируются. diff --git a/frontend/scripts/check-dicom-preview.cjs b/frontend/scripts/check-dicom-preview.cjs index e7c7096b..c7bf3038 100644 --- a/frontend/scripts/check-dicom-preview.cjs +++ b/frontend/scripts/check-dicom-preview.cjs @@ -59,6 +59,23 @@ const { chromium } = require(process.env.PLAYWRIGHT_MODULE || "playwright"); res.end(JSON.stringify(data)); }; if (u.pathname === "/api/session") return json(user); + if (u.pathname === "/api/users/1" && req.method === "PUT") { + let body = ""; + req.on("data", (chunk) => { + body += chunk; + }); + req.on("end", () => { + const update = JSON.parse(body); + if (!update.which.includes("dicom3D")) { + res.writeHead(400); + res.end(); + return; + } + Object.assign(user, update.data); + json({}); + }); + return; + } if (u.pathname === "/api/addons") return json([]); if (u.pathname.startsWith("/api/resources")) return json( @@ -106,6 +123,30 @@ const { chromium } = require(process.env.PLAYWRIGHT_MODULE || "playwright"); }); await route.fulfill({ response }); }); + await page.goto(base + "/settings/profile"); + await page.getByLabel("3D preview quality").selectOption("half"); + await page.getByLabel("Voxel memory limit").selectOption("512"); + await page.getByLabel("Initial opacity").fill("50"); + await Promise.all([ + page.waitForResponse( + (r) => r.url().endsWith("/api/users/1") && r.status() === 200 + ), + page.getByRole("button", { name: "Save", exact: true }).click(), + ]); + await page.reload(); + await page.getByLabel("3D preview quality").waitFor(); + if ( + (await page.getByLabel("3D preview quality").inputValue()) !== "half" || + (await page.getByLabel("Voxel memory limit").inputValue()) !== "512" + ) + throw new Error("3D profile settings were not restored"); + await page.getByLabel("3D preview quality").selectOption("auto"); + await Promise.all([ + page.waitForResponse( + (r) => r.url().endsWith("/api/users/1") && r.status() === 200 + ), + page.getByRole("button", { name: "Save", exact: true }).click(), + ]); await page.goto(base + "/files/series/scan_1.dcm"); await page.waitForFunction( () => @@ -120,6 +161,11 @@ const { chromium } = require(process.env.PLAYWRIGHT_MODULE || "playwright"); await page .locator(".dicom-volume-stage canvas") .waitFor({ timeout: 20000 }); + if ( + (await page.locator('.dicom-volume input[type="range"]').inputValue()) !== + "0.5" + ) + throw new Error("Viewer ignored profile opacity"); for (const label of ["Axial", "Sagittal", "Coronal", "3D"]) { await page.getByRole("button", { name: label, exact: true }).click(); await page.waitForTimeout(150); diff --git a/frontend/src/components/files/DicomViewer.vue b/frontend/src/components/files/DicomViewer.vue index bdaabed9..ae367258 100644 --- a/frontend/src/components/files/DicomViewer.vue +++ b/frontend/src/components/files/DicomViewer.vue @@ -74,6 +74,7 @@ import { watch, } from "vue"; import { useI18n } from "vue-i18n"; +import { useAuthStore } from "@/stores/auth"; import DicomWorker from "@/utils/dicom.worker?worker"; import { readDicomFile } from "@/utils/dicom-file"; import { findDicomSeries } from "@/utils/dicom-context"; @@ -88,6 +89,7 @@ const DicomVolumeViewer = defineAsyncComponent({ }); const props = defineProps<{ source: string; resource?: Resource }>(); const { t } = useI18n(); +const auth = useAuthStore(); const series = shallowRef([]), volume = shallowRef(); const volumeLoading = ref(false), @@ -124,7 +126,8 @@ async function openVolume() { request.signal, (count) => { loaded.value = count; - } + }, + auth.user?.dicom3D ); if (!request.signal.aborted) volume.value = result; } catch (e) { diff --git a/frontend/src/components/files/DicomVolumeViewer.vue b/frontend/src/components/files/DicomVolumeViewer.vue index c5d11564..30221cc0 100644 --- a/frontend/src/components/files/DicomVolumeViewer.vue +++ b/frontend/src/components/files/DicomVolumeViewer.vue @@ -37,6 +37,17 @@

{{ t(mode === "3d" ? "documents.volumeHint" : "documents.sliceHint") }} + + · + {{ + t("documents.reduced3d", { + factor: volume.sampling.factor, + width: volume.dimensions[0], + height: volume.dimensions[1], + slices: volume.dimensions[2], + }) + }}

("3d"), center = ref(props.volume.first.center), width = ref(props.volume.first.width), - opacity = ref(0.3); + opacity = ref(props.volume.opacity ?? 0.3); const id = `fs-dicom-${crypto.getRandomValues(new Uint32Array(2)).join("-")}`; const viewportID = `${id}-viewport`; let engine: InstanceType | undefined; @@ -154,7 +165,7 @@ async function switchView(value: Mode) { function reset() { center.value = props.volume.first.center; width.value = props.volume.first.width; - opacity.value = 0.3; + opacity.value = props.volume.opacity ?? 0.3; viewport()?.resetCamera(); schedule(); } diff --git a/frontend/src/i18n/en.json b/frontend/src/i18n/en.json index 981a59d3..1b9b9ba2 100644 --- a/frontend/src/i18n/en.json +++ b/frontend/src/i18n/en.json @@ -365,7 +365,7 @@ "open3d": "Open as 3D", "back2d": "Back to 2D", "loading3d": "Loading series: {count} / {total}", - "volumeLimit": "This series exceeds the safe 3D preview limit (1.5 GiB of decoded voxels, 2048 files). Use 2D preview.", + "volumeLimit": "3D preview limit exceeded. See the browser console for the size and limiting condition.", "volumeInvalid": "Cannot build a volume: the slices must belong to one study and series, have matching geometry and uniform spacing. 2D preview remains available.", "volumeUnavailable": "3D preview is unavailable on this device. WebGL2 with volume rendering support is required.", "axial": "Axial", @@ -373,7 +373,8 @@ "coronal": "Coronal", "opacity": "Opacity", "volumeHint": "Drag to rotate · Scroll to zoom", - "sliceHint": "Scroll to change slice · Drag to pan · Ctrl + scroll to zoom" + "sliceHint": "Scroll to change slice · Drag to pan · Ctrl + scroll to zoom", + "reduced3d": "Reduced 3D preview: {width} × {height} × {slices}" }, "fileInfo": { "dicom": "DICOM metadata", @@ -409,7 +410,16 @@ "regional": "Language and dates", "publicPages": "Public pages", "homeFolders": "Home folders", - "manage": "Manage" + "manage": "Manage", + "dicom3D": "DICOM — 3D preview", + "dicomQuality": "3D preview quality", + "dicomAuto": "Automatic — fit memory limit", + "dicomOriginal": "Original resolution", + "dicomHalf": "Half resolution", + "dicomQuarter": "Quarter resolution", + "dicomMemory": "Voxel memory limit", + "dicomOpacity": "Initial opacity", + "dicomHint": "Automatic mode reduces large series while preserving all slices and physical proportions. The limit covers voxels; assembly and GPU rendering need additional memory." }, "notifications": { "success": "Done", diff --git a/frontend/src/i18n/ru.json b/frontend/src/i18n/ru.json index d34d4480..8d00659b 100644 --- a/frontend/src/i18n/ru.json +++ b/frontend/src/i18n/ru.json @@ -362,7 +362,7 @@ "open3d": "Открыть как 3D", "back2d": "Вернуться к 2D", "loading3d": "Загрузка серии: {count} / {total}", - "volumeLimit": "Серия превышает безопасный лимит 3D-просмотра (1,5 ГиБ декодированных вокселей, 2048 файлов). Используйте 2D.", + "volumeLimit": "Превышен лимит 3D-просмотра. Размер и причина ограничения указаны в консоли браузера.", "volumeInvalid": "Не удалось построить объём: нужны срезы одного исследования и серии, с одинаковой геометрией и равномерным шагом. Просмотр в 2D доступен.", "volumeUnavailable": "3D-просмотр недоступен на этом устройстве. Нужна поддержка WebGL2 и объёмного рендеринга.", "axial": "Аксиально", @@ -370,7 +370,8 @@ "coronal": "Коронально", "opacity": "Непрозрачность", "volumeHint": "Перетаскивание — вращение · Колесо — масштаб", - "sliceHint": "Колесо — смена среза · Перетаскивание — перемещение · Ctrl + колесо — масштаб" + "sliceHint": "Колесо — смена среза · Перетаскивание — перемещение · Ctrl + колесо — масштаб", + "reduced3d": "Уменьшенное 3D-превью: {width} × {height} × {slices}" }, "fileInfo": { "dicom": "Метаданные DICOM", @@ -406,7 +407,16 @@ "regional": "Язык и даты", "publicPages": "Публичные страницы", "homeFolders": "Личные папки", - "manage": "Управление" + "manage": "Управление", + "dicom3D": "DICOM — 3D-просмотр", + "dicomQuality": "Качество 3D-превью", + "dicomAuto": "Автоматически — под лимит памяти", + "dicomOriginal": "Исходное разрешение", + "dicomHalf": "Уменьшить разрешение в 2 раза", + "dicomQuarter": "Уменьшить разрешение в 4 раза", + "dicomMemory": "Лимит памяти для вокселей", + "dicomOpacity": "Начальная непрозрачность", + "dicomHint": "Автоматический режим уменьшает большие серии, сохраняя все срезы и физические пропорции. Лимит относится к вокселям; сборка и видеокарта требуют дополнительной памяти." }, "notifications": { "success": "Готово", diff --git a/frontend/src/types/user.d.ts b/frontend/src/types/user.d.ts index 32c3acc4..74715452 100644 --- a/frontend/src/types/user.d.ts +++ b/frontend/src/types/user.d.ts @@ -14,6 +14,7 @@ interface IUser { lockPassword: boolean; hideDotfiles: boolean; hidePreviews?: boolean; + dicom3D?: Dicom3DSettings; singleClick: boolean; redirectAfterCopyMove: boolean; dateFormat: boolean; @@ -22,6 +23,12 @@ interface IUser { aceEditorTheme: string; } +interface Dicom3DSettings { + memoryMiB: number; + quality: "auto" | "original" | "half" | "quarter"; + opacity: number; +} + type ViewModeType = "list" | "mosaic" | "mosaic gallery"; interface IUserForm { diff --git a/frontend/src/utils/__tests__/dicom-quality.test.ts b/frontend/src/utils/__tests__/dicom-quality.test.ts new file mode 100644 index 00000000..7d90d217 --- /dev/null +++ b/frontend/src/utils/__tests__/dicom-quality.test.ts @@ -0,0 +1,67 @@ +import { expect, it } from "vitest"; +import { + dicomPreferences, + volumeSampling, + resampleSlice, +} from "../dicom-quality"; +import { assembleVolume, type DicomSlice } from "../dicom-series"; +it("fits a 768-slice volume into the profile memory budget", () => { + const plan = volumeSampling(1024, 1024, 768); + expect(plan.factor).toBe(2); + expect(plan.bytes).toBe(768 * 512 * 512 * 4); + expect(plan.bytes).toBeLessThanOrEqual(plan.limit); + expect(volumeSampling(1024, 1024, 768, { memoryMiB: 128 }).factor).toBe(5); + expect(() => + volumeSampling(1024, 1024, 768, { quality: "original" }) + ).toThrow("DICOM_VOLUME_LIMIT"); +}); +it("handles odd dimensions, rounding and explicit quality modes", () => { + const plan = volumeSampling(1025, 1025, 768); + expect(plan.bytes).toBeLessThanOrEqual(plan.limit); + expect(volumeSampling(1024, 1024, 768, { quality: "quarter" }).cols).toBe( + 256 + ); + expect(dicomPreferences({ memoryMiB: Infinity, opacity: -10 })).toEqual({ + memoryMiB: 1536, + quality: "auto", + opacity: 30, + }); +}); +it("preserves patient-space extent, positions, signed intensities and source pixels", () => { + const original: DicomSlice = { + study: "study", + series: "series", + reference: "frame", + instance: "one", + modality: "CT", + rows: 4, + cols: 4, + orientation: [1, 0, 0, 0, 1, 0], + position: [10, 20, 30], + spacing: [0.5, 0.75], + pixels: Float32Array.from({ length: 16 }, (_, i) => i - 8), + center: 0, + width: 20, + }; + const plan = { + rows: 2, + cols: 2, + factor: 2, + bytes: 32, + limit: 100, + originalDimensions: [4, 4, 2] as [number, number, number], + }; + const reduced = resampleSlice(original, plan); + expect(Array.from(reduced.pixels)).toEqual([-8, -5, 4, 7]); + expect(reduced.spacing).toEqual([1.5, 2.25]); + expect(reduced.position).toEqual(original.position); + expect(reduced.orientation).toEqual(original.orientation); + expect(original.pixels.length).toBe(16); + expect(original.spacing).toEqual([0.5, 0.75]); + const volume = assembleVolume([ + reduced, + { ...reduced, instance: "two", position: [10, 20, 31] }, + ]); + expect(volume.spacing).toEqual([2.25, 1.5, 1]); + expect(volume.origin).toEqual([10, 20, 30]); +}); diff --git a/frontend/src/utils/dicom-diagnostics.ts b/frontend/src/utils/dicom-diagnostics.ts index f2083000..5c7fd30b 100644 --- a/frontend/src/utils/dicom-diagnostics.ts +++ b/frontend/src/utils/dicom-diagnostics.ts @@ -7,7 +7,10 @@ import { const size = (bytes: number) => `${(bytes / 1024 ** 3).toFixed(3)} GiB (${bytes.toLocaleString("en-US")} bytes)`; -export function logDicomSeries(sources: DicomSource[]) { +export function logDicomSeries( + sources: DicomSource[], + decodedLimit = MAX_VOLUME_BYTES +) { const sourceBytes = sources.reduce((total, file) => total + file.size, 0); const largestFileBytes = sources.reduce( (largest, file) => Math.max(largest, file.size), @@ -21,7 +24,7 @@ export function logDicomSeries(sources: DicomSource[]) { largestFileBytes, largestFileSize: size(largestFileBytes), sourceLimit: size(MAX_VOLUME_BYTES), - decodedVolumeLimit: size(MAX_VOLUME_BYTES), + decodedVolumeLimit: size(decodedLimit), perFileLimit: "64 MiB", fileCountLimit: MAX_SERIES_FILES, }); @@ -31,7 +34,8 @@ export function logDicomSeries(sources: DicomSource[]) { export function logDicomVolumeEstimate( rows: number, cols: number, - count: number + count: number, + decodedLimit = MAX_VOLUME_BYTES ) { const decodedBytes = rows * cols * count * Float32Array.BYTES_PER_ELEMENT; console.info("[DICOM 3D] Decoded volume estimate", { @@ -39,7 +43,7 @@ export function logDicomVolumeEstimate( bytesPerVoxel: Float32Array.BYTES_PER_ELEMENT, decodedBytes, decodedSize: size(decodedBytes), - decodedVolumeLimit: size(MAX_VOLUME_BYTES), + decodedVolumeLimit: size(decodedLimit), }); return decodedBytes; } diff --git a/frontend/src/utils/dicom-quality.ts b/frontend/src/utils/dicom-quality.ts new file mode 100644 index 00000000..51e048bc --- /dev/null +++ b/frontend/src/utils/dicom-quality.ts @@ -0,0 +1,101 @@ +import { MAX_VOLUME_BYTES, type DicomSlice } from "./dicom-series"; + +export function dicomPreferences( + value?: Partial +): Dicom3DSettings { + return { + memoryMiB: + Number.isInteger(value?.memoryMiB) && + value!.memoryMiB! >= 128 && + value!.memoryMiB! <= 1536 + ? value!.memoryMiB! + : 1536, + quality: ["auto", "original", "half", "quarter"].includes( + value?.quality || "" + ) + ? value!.quality! + : "auto", + opacity: + Number.isInteger(value?.opacity) && + value!.opacity! >= 5 && + value!.opacity! <= 100 + ? value!.opacity! + : 30, + }; +} + +export function volumeSampling( + rows: number, + cols: number, + count: number, + preferences?: Partial +) { + const settings = dicomPreferences(preferences); + const limit = Math.min(MAX_VOLUME_BYTES, settings.memoryMiB * 1024 * 1024); + let factor = + settings.quality === "half" ? 2 : settings.quality === "quarter" ? 4 : 1; + const dimensions = () => ({ + rows: Math.max(2, Math.ceil(rows / factor)), + cols: Math.max(2, Math.ceil(cols / factor)), + }); + const bytes = () => dimensions().rows * dimensions().cols * count * 4; + if (settings.quality === "auto") { + factor = Math.max( + 1, + Math.ceil(Math.sqrt((rows * cols * count * 4) / limit)) + ); + while (bytes() > limit && factor < Math.max(rows, cols)) factor++; + } + if ( + rows < 2 || + cols < 2 || + ![rows, cols, count].every((n) => Number.isSafeInteger(n) && n > 0) + ) + throw new Error("DICOM_GEOMETRY"); + if (bytes() > limit) throw new Error("DICOM_VOLUME_LIMIT"); + return { + ...dimensions(), + factor, + bytes: bytes(), + limit, + originalDimensions: [cols, rows, count] as [number, number, number], + }; +} + +// Bilinear resampling keeps the full field of view and its physical spacing. +// Every slice keeps its original patient position and orientation. +export function resampleSlice( + slice: DicomSlice, + target: ReturnType +): DicomSlice { + if (target.rows === slice.rows && target.cols === slice.cols) return slice; + const dx = (slice.cols - 1) / (target.cols - 1), + dy = (slice.rows - 1) / (target.rows - 1); + const pixels = new Float32Array(target.rows * target.cols); + for (let y = 0; y < target.rows; y++) { + const sy = y * dy, + y0 = Math.floor(sy), + y1 = Math.min(slice.rows - 1, y0 + 1), + fy = sy - y0; + for (let x = 0; x < target.cols; x++) { + const sx = x * dx, + x0 = Math.floor(sx), + x1 = Math.min(slice.cols - 1, x0 + 1), + fx = sx - x0; + const a = + slice.pixels[y0 * slice.cols + x0] * (1 - fx) + + slice.pixels[y0 * slice.cols + x1] * fx; + const b = + slice.pixels[y1 * slice.cols + x0] * (1 - fx) + + slice.pixels[y1 * slice.cols + x1] * fx; + pixels[y * target.cols + x] = a * (1 - fy) + b * fy; + } + } + return { + ...slice, + rows: target.rows, + cols: target.cols, + pixels, + spacing: [slice.spacing[0] * dy, slice.spacing[1] * dx], + }; +} diff --git a/frontend/src/utils/dicom-series.ts b/frontend/src/utils/dicom-series.ts index 22f0b5f8..2df80976 100644 --- a/frontend/src/utils/dicom-series.ts +++ b/frontend/src/utils/dicom-series.ts @@ -152,4 +152,7 @@ export function assembleVolume(slices: DicomSlice[]) { first, }; } -export type DicomVolume = ReturnType; +export type DicomVolume = ReturnType & { + sampling?: { factor: number; originalDimensions: [number, number, number] }; + opacity?: number; +}; diff --git a/frontend/src/utils/dicom-volume.ts b/frontend/src/utils/dicom-volume.ts index ece4194d..02d31b68 100644 --- a/frontend/src/utils/dicom-volume.ts +++ b/frontend/src/utils/dicom-volume.ts @@ -1,5 +1,10 @@ import DicomWorker from "./dicom.worker?worker"; import { readDicomFile } from "./dicom-file"; +import { + dicomPreferences, + volumeSampling, + resampleSlice, +} from "./dicom-quality"; import { logDicomSeries, logDicomVolumeEstimate, @@ -17,9 +22,15 @@ import { export async function loadDicomVolume( sources: DicomSource[], signal: AbortSignal, - progress: (loaded: number) => void + progress: (loaded: number) => void, + preferences?: Partial ) { - const { sourceBytes, largestFileBytes } = logDicomSeries(sources); + const settings = dicomPreferences(preferences); + const memoryLimit = settings.memoryMiB * 1024 * 1024; + const { sourceBytes, largestFileBytes } = logDicomSeries( + sources, + memoryLimit + ); if (sources.length < 2 || sources.length > MAX_SERIES_FILES) dicomLimitExceeded("file count", sources.length, MAX_SERIES_FILES); if (largestFileBytes > 64 * 1024 * 1024) @@ -36,6 +47,8 @@ export async function loadDicomVolume( ); const worker = new DicomWorker(); const slices: DicomSlice[] = []; + let originalFirst: DicomSlice | undefined; + let sampling: ReturnType | undefined; let bytes = 0; try { for (const source of sources) { @@ -78,16 +91,31 @@ export async function loadDicomVolume( buffer, ]); }); - checkSlice(slice, slices[0] || slice); - if (slices.length === 0) - logDicomVolumeEstimate(slice.rows, slice.cols, sources.length); - if (slice.pixels.byteLength * sources.length > MAX_VOLUME_BYTES) - dicomLimitExceeded( - "decoded Float32 voxel bytes", - slice.pixels.byteLength * sources.length, - MAX_VOLUME_BYTES + checkSlice(slice, originalFirst || slice); + if (!originalFirst) { + originalFirst = slice; + logDicomVolumeEstimate( + slice.rows, + slice.cols, + sources.length, + memoryLimit ); - slices.push(slice); + sampling = volumeSampling( + slice.rows, + slice.cols, + sources.length, + settings + ); + console.info("[DICOM 3D] Preview resolution", { + quality: settings.quality, + factor: sampling.factor, + originalDimensions: sampling.originalDimensions, + previewDimensions: [sampling.cols, sampling.rows, sources.length], + decodedBytes: sampling.bytes, + memoryLimitBytes: sampling.limit, + }); + } + slices.push(resampleSlice(slice, sampling!)); progress(slices.length); } if (signal.aborted) throw new DOMException("Aborted", "AbortError"); @@ -95,7 +123,11 @@ export async function loadDicomVolume( fileCount: slices.length, downloadedBytes: bytes, }); - return assembleVolume(slices); + return { + ...assembleVolume(slices), + sampling, + opacity: settings.opacity / 100, + }; } catch (error) { if (!signal.aborted) console.warn("[DICOM 3D] Loading stopped", { diff --git a/frontend/src/views/settings/Profile.vue b/frontend/src/views/settings/Profile.vue index 5d02e27f..17dc59d1 100644 --- a/frontend/src/views/settings/Profile.vue +++ b/frontend/src/views/settings/Profile.vue @@ -46,7 +46,45 @@ > -
+
+

{{ t("preferences.dicom3D") }}

+ + + +

{{ t("preferences.dicomHint") }}

+
+

{{ t("preferences.regional") }}