diff --git a/src/store/data-browser.ts b/src/store/data-browser.ts
index a7c5fd925..910e53664 100644
--- a/src/store/data-browser.ts
+++ b/src/store/data-browser.ts
@@ -1,10 +1,20 @@
import { defineStore } from 'pinia';
import { ref } from 'vue';
+import { onImageDeleted } from '@/src/composables/onImageDeleted';
+import type { Maybe } from '@/src/types';
export const useDataBrowserStore = defineStore('data-browser', () => {
const hideSampleData = ref(import.meta.env.VITE_SHOW_SAMPLE_DATA !== 'true');
+ /** The image whose Info dialog is open. */
+ const infoImageID = ref>();
+
+ onImageDeleted((deletedIDs) => {
+ const id = infoImageID.value;
+ if (id && deletedIDs.includes(id)) infoImageID.value = undefined;
+ });
return {
hideSampleData,
+ infoImageID,
};
});
diff --git a/src/store/datasets-dicom.ts b/src/store/datasets-dicom.ts
index 9a7f11087..65fba3591 100644
--- a/src/store/datasets-dicom.ts
+++ b/src/store/datasets-dicom.ts
@@ -485,6 +485,18 @@ export const useDICOMStore = defineStore('dicom', {
volumeStudy: {},
studyPatient: {},
}),
+ getters: {
+ /** A DICOM volume's info with its study's and patient's. */
+ volumeRecords: (state) => (volumeKey: string) => {
+ if (!(volumeKey in state.volumeInfo)) return undefined;
+ const studyKey = state.volumeStudy[volumeKey];
+ return {
+ volume: state.volumeInfo[volumeKey],
+ study: state.studyInfo[studyKey],
+ patient: state.patientInfo[state.studyPatient[studyKey]],
+ };
+ },
+ },
actions: {
/**
* Plans, allocates and publishes each series of the batch in one
diff --git a/tests/pageobjects/volview.page.ts b/tests/pageobjects/volview.page.ts
index 9f334c1ce..9f8265658 100644
--- a/tests/pageobjects/volview.page.ts
+++ b/tests/pageobjects/volview.page.ts
@@ -330,14 +330,19 @@ export const createVolViewPage = (page: Page, scratch: Scratch) => {
return settingsDialog;
};
+ /** Clicks the close button within `dialog` and waits for `dialog` to hide. */
+ const closeDialog = async (dialog: Locator) => {
+ // The active class leaves on close, so follow the element itself out.
+ const handle = await dialog.elementHandle();
+ await dialog.locator('button.close-button').click();
+ await handle.waitForElementState('hidden');
+ };
+
const closeSettings = async () => {
await expect(settingsDialog.locator('.v-card-title')).toHaveText(
'Settings'
);
- // The active class leaves on close, so follow the element itself out.
- const dialog = await settingsDialog.elementHandle();
- await settingsDialog.locator('button.close-button').click();
- await dialog?.waitForElementState('hidden');
+ await closeDialog(settingsDialog);
};
const openLayoutMenu = async (minOptionCount = 1) => {
@@ -552,6 +557,7 @@ export const createVolViewPage = (page: Page, scratch: Scratch) => {
openMenu,
closeMenu,
openSettings,
+ closeDialog,
closeSettings,
openLayoutMenu,
getLayoutOptionTitles,
diff --git a/tests/specs/dicom-import-regressions.e2e.ts b/tests/specs/dicom-import-regressions.e2e.ts
index 81a50745e..501680e62 100644
--- a/tests/specs/dicom-import-regressions.e2e.ts
+++ b/tests/specs/dicom-import-regressions.e2e.ts
@@ -91,7 +91,7 @@ async function selectSlice(
}
test.describe('Local DICOM import regressions', () => {
- test('loads every slice in order with slightly different slice orientations', async ({
+ test('keeps the planned 5 mm spacing with slightly different slice orientations', async ({
page,
volview,
utils,
@@ -119,6 +119,9 @@ test.describe('Local DICOM import regressions', () => {
await volview.waitForLoadingIndicator(
page.locator('[data-testid~="vtk-two-view"]').first()
);
+ await utils.openVolumeInfo();
+ await expect(utils.volumeInfoStep('Z')).toHaveText('5');
+ await utils.closeVolumeInfo();
const view = await axialView(page, 121);
for (const index of [0, 60, 120]) {
await selectSlice(page, view, index, 121);
diff --git a/tests/specs/utils.ts b/tests/specs/utils.ts
index 800140c6a..5b20a165b 100644
--- a/tests/specs/utils.ts
+++ b/tests/specs/utils.ts
@@ -390,9 +390,33 @@ export const createUtils = (page: Page, scratch: Scratch) => {
);
};
+ const volumeInfo = page.locator('[data-testid="volume-info"]');
+
+ /** Opens the Info dialog from the first data card's menu. */
+ const openVolumeInfo = async () => {
+ const menu = await volview.openMenu(volview.datasetMenuButtons.first());
+ await menu.locator('[data-testid="dataset-menu-info-item"]').click();
+ await expect(volumeInfo).toBeVisible();
+ await waitForTransitions(volumeInfo);
+ };
+
+ // The fading scrim takes clicks until the whole overlay unmounts.
+ const closeVolumeInfo = () =>
+ volview.closeDialog(
+ page.locator('.v-dialog.v-overlay--active', { has: volumeInfo })
+ );
+
+ /** The Info dialog's spacing step along `axis`. */
+ const volumeInfoStep = (axis: 'X' | 'Y' | 'Z') =>
+ volumeInfo.locator(`[data-testid="spacing-axis-${axis}"] td:nth-child(2)`);
+
return {
dropFiles,
writeAcquisitions,
+ volumeInfo,
+ openVolumeInfo,
+ closeVolumeInfo,
+ volumeInfoStep,
captureViewPixels,
capture2DViewPixels,
capture2DViewScreenshotMetrics,
diff --git a/tests/specs/volume-info.e2e.ts b/tests/specs/volume-info.e2e.ts
new file mode 100644
index 000000000..aeba19e6b
--- /dev/null
+++ b/tests/specs/volume-info.e2e.ts
@@ -0,0 +1,244 @@
+import type { Page } from '@playwright/test';
+import { test, expect } from '../fixtures';
+import {
+ setValueVueInput,
+ type VolViewPage,
+} from '../pageobjects/volview.page';
+import type { Scratch } from '../scratch';
+import type { Utils } from './utils';
+import {
+ buildSyntheticDicom,
+ newUid,
+ rawElement,
+ type SyntheticSliceOptions,
+} from './syntheticDicom';
+
+type Kit = { volview: VolViewPage; utils: Utils; scratch: Scratch };
+
+function slice(options: Partial = {}) {
+ return buildSyntheticDicom({
+ studyUid: newUid(),
+ seriesUid: newUid(),
+ sopUid: newUid(),
+ instanceNumber: 1,
+ imageOrientationPatient: [1, 0, 0, 0, 1, 0],
+ imagePositionPatient: [0, 0, 0],
+ pixelSpacing: [0.5, 0.25],
+ pixelValue: 80,
+ ...options,
+ });
+}
+
+async function openFile(
+ { volview, utils, scratch }: Kit,
+ name: string,
+ bytes: Uint8Array,
+ slices = 1
+) {
+ scratch.writeFile(name, bytes);
+ await volview.open(`?urls=[tmp/${name}]`);
+ await volview.waitForVolumeCardSliceCounts([slices]);
+ await utils.openVolumeInfo();
+}
+
+const openFromView = (page: Page) =>
+ page.locator('[data-testid="view-info-button"]').first().click();
+
+test.describe('Volume Info dialog', () => {
+ test('updates derived spacing after another slice arrives and restores it with the session', async ({
+ volview,
+ utils,
+ scratch,
+ }) => {
+ const step = utils.volumeInfoStep;
+ const studyUid = newUid();
+ const seriesUid = newUid();
+ const second = scratch.writeFile(
+ 'spacing-second.dcm',
+ slice({
+ studyUid,
+ seriesUid,
+ instanceNumber: 2,
+ imagePositionPatient: [0, 0, 2],
+ })
+ );
+ await openFile(
+ { volview, utils, scratch },
+ 'spacing-first.dcm',
+ slice({ studyUid, seriesUid })
+ );
+ await expect(step('X')).toHaveText('0.25');
+ await expect(
+ utils.volumeInfo.locator('[data-testid="spacing-axis-Z"]')
+ ).toContainText('One sample');
+ await utils.closeVolumeInfo();
+
+ await utils.dropFiles([second]);
+ await volview.waitForVolumeCardSliceCounts([2]);
+ await utils.openVolumeInfo();
+ await expect(step('Z')).toHaveText('2');
+ await utils.closeVolumeInfo();
+
+ const saved = await volview.saveSession();
+ await volview.open(`?urls=[tmp/${saved}]`);
+ await volview.waitForVolumeCardSliceCounts([2]);
+ await utils.openVolumeInfo();
+ await expect(step('X')).toHaveText('0.25');
+ await expect(step('Z')).toHaveText('2');
+ });
+
+ test('preserves the valid axis when the other PixelSpacing value is unusable', async ({
+ volview,
+ utils,
+ scratch,
+ }) => {
+ await openFile(
+ { volview, utils, scratch },
+ 'spacing-partial.dcm',
+ slice({ pixelSpacing: [0, 0.25] })
+ );
+ await expect(utils.volumeInfoStep('X')).toHaveText('0.25');
+ });
+
+ test('reports the declared step of a single-file multiframe volume', async ({
+ volview,
+ utils,
+ scratch,
+ }) => {
+ await openFile(
+ { volview, utils, scratch },
+ 'spacing-multiframe.dcm',
+ slice({ framePixelValues: [40, 80], spacingBetweenSlices: 1.5 }),
+ 2
+ );
+ await expect(utils.volumeInfoStep('Z')).toHaveText('1.5');
+ });
+
+ test('converts ultrasound region spacing from cm to mm', async ({
+ volview,
+ utils,
+ scratch,
+ }) => {
+ await openFile(
+ { volview, utils, scratch },
+ 'spacing-ultrasound.dcm',
+ slice({
+ modality: 'US',
+ sopClassUid: '1.2.840.10008.5.1.4.1.1.6.1',
+ ultrasoundRegion: { physicalDeltaX: 0.05, physicalDeltaY: 0.03 },
+ })
+ );
+ await expect(utils.volumeInfoStep('X')).toHaveText('0.5');
+ await expect(utils.volumeInfoStep('Y')).toHaveText('0.3');
+ });
+
+ test('describes a non-DICOM image without DICOM sections', async ({
+ page,
+ utils,
+ scratch,
+ }) => {
+ const { volumeInfo: dialog, volumeInfoStep: step } = utils;
+ const header = [
+ 'NRRD0005',
+ 'type: unsigned char',
+ 'dimension: 3',
+ 'sizes: 4 3 2',
+ 'space: left-posterior-superior',
+ 'space directions: (0,0.5,0) (-0.25,0,0) (0,0,2)',
+ 'space origin: (10,20,30)',
+ 'encoding: ascii',
+ ].join('\n');
+ const values = Array.from({ length: 24 }, (_, index) => index).join(' ');
+ scratch.writeFile('volume-info-grid.nrrd', `${header}\n\n${values}`);
+ await utils.openVolViewPage('volume-info-grid.nrrd');
+ await utils.openVolumeInfo();
+ await expect(dialog).toContainText('volume-info-grid.nrrd');
+ await expect(
+ dialog.locator('[data-testid="volume-info-Dimensions"]')
+ ).toContainText('4, 3, 2');
+ await expect(
+ dialog.locator('[data-testid="volume-info-Origin"]')
+ ).toContainText('10, 20, 30');
+ await expect(
+ dialog.locator('[data-testid="volume-info-X direction"]')
+ ).toContainText('0, 1, 0');
+ await expect(step('X')).toHaveText('0.5');
+ await expect(step('Y')).toHaveText('0.25');
+ await expect(step('Z')).toHaveText('2');
+ await expect(dialog).not.toContainText('Patient and study');
+ await expect(
+ dialog.locator('[data-testid="volume-info-tags"]')
+ ).toHaveCount(0);
+ await utils.closeVolumeInfo();
+
+ await openFromView(page);
+ await expect(dialog).toContainText('volume-info-grid.nrrd');
+ });
+
+ test('lists study details and the first instance tags, and opens from the view', async ({
+ page,
+ volview,
+ utils,
+ scratch,
+ }) => {
+ const dialog = utils.volumeInfo;
+ await openFile(
+ { volview, utils, scratch },
+ 'volume-info-tags.dcm',
+ slice({
+ patientId: 'INFO-PATIENT-7',
+ seriesNumber: 42,
+ extraElements: [
+ rawElement(
+ 0x0040,
+ 0x0280,
+ 'ST',
+ new TextEncoder().encode('A'.repeat(300))
+ ),
+ ],
+ })
+ );
+ await expect(dialog).toContainText('INFO-PATIENT-7');
+ await expect(dialog).toContainText('Series number');
+ // Double-click the text itself, which sits at the start of a wide cell.
+ const seriesNumber = dialog.locator(
+ '[data-testid="volume-info-Series number"] td:nth-child(2)'
+ );
+ const box = await seriesNumber.boundingBox();
+ if (!box) throw new Error('The series number cell is off screen');
+ await seriesNumber.dblclick({
+ position: { x: 18, y: Math.round(box.height / 2) },
+ });
+ await expect
+ .poll(() => page.evaluate(() => window.getSelection()?.toString().trim()))
+ .toBe('42');
+
+ const tags = dialog.locator('[data-testid="volume-info-tags"]');
+ await tags.locator('button').click();
+ const filter = tags.locator('input');
+ await expect(tags.locator('thead')).toHaveText(/Tag\s+Name\s+VR\s+Value/, {
+ useInnerText: true,
+ });
+ await setValueVueInput(filter, 'SeriesNumber');
+ const rows = tags.locator('[data-testid="volume-info-tag"]');
+ await expect(rows).toHaveCount(1);
+ await expect(rows).toHaveText(/\(0020,0011\)\s+SeriesNumber\s+IS\s+42/, {
+ useInnerText: true,
+ });
+ await tags.locator('.v-field__clearable .v-icon').click();
+ await expect
+ .poll(() => rows.count(), {
+ message: 'Expected the cleared filter to list every tag',
+ })
+ .toBeGreaterThanOrEqual(10);
+ await setValueVueInput(filter, 'CommentsOnThePerformedProcedureStep');
+ await expect(rows).toHaveCount(1);
+ await expect(rows).toContainText(`${'A'.repeat(256)}… (300 characters)`);
+ await expect(dialog).toContainText('Transfer syntax: 1.2.840.10008.1.2.1.');
+ await utils.closeVolumeInfo();
+
+ await volview.waitForViews();
+ await openFromView(page);
+ await expect(dialog).toContainText('INFO-PATIENT-7');
+ });
+});