Skip to content

Commit

Permalink
fix(CinePlayer): always show cine player for dynamic data (#4575)
Browse files Browse the repository at this point in the history
Co-authored-by: Ibrahim <[email protected]>
  • Loading branch information
sedghi and IbrahimCSAE authored Dec 5, 2024
1 parent 72a35ce commit b8e8bbe
Show file tree
Hide file tree
Showing 20 changed files with 122 additions and 59 deletions.
4 changes: 2 additions & 2 deletions extensions/cornerstone-dicom-pmap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
},
"dependencies": {
"@babel/runtime": "^7.20.13",
"@cornerstonejs/adapters": "^2.2.20",
"@cornerstonejs/core": "^2.2.20",
"@cornerstonejs/adapters": "^2.7.3",
"@cornerstonejs/core": "^2.7.3",
"@kitware/vtk.js": "32.1.1",
"react-color": "^2.19.3"
}
Expand Down
4 changes: 2 additions & 2 deletions extensions/cornerstone-dicom-seg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
},
"dependencies": {
"@babel/runtime": "^7.20.13",
"@cornerstonejs/adapters": "^2.2.20",
"@cornerstonejs/core": "^2.2.20",
"@cornerstonejs/adapters": "^2.7.3",
"@cornerstonejs/core": "^2.7.3",
"@kitware/vtk.js": "32.1.1",
"react-color": "^2.19.3"
}
Expand Down
6 changes: 3 additions & 3 deletions extensions/cornerstone-dicom-sr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
},
"dependencies": {
"@babel/runtime": "^7.20.13",
"@cornerstonejs/adapters": "^2.2.20",
"@cornerstonejs/core": "^2.2.20",
"@cornerstonejs/tools": "^2.2.20",
"@cornerstonejs/adapters": "^2.7.3",
"@cornerstonejs/core": "^2.7.3",
"@cornerstonejs/tools": "^2.7.3",
"classnames": "^2.3.2"
}
}
4 changes: 2 additions & 2 deletions extensions/cornerstone-dynamic-volume/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
},
"dependencies": {
"@babel/runtime": "^7.20.13",
"@cornerstonejs/core": "^2.2.20",
"@cornerstonejs/tools": "^2.2.20",
"@cornerstonejs/core": "^2.7.3",
"@cornerstonejs/tools": "^2.7.3",
"classnames": "^2.3.2"
}
}
8 changes: 4 additions & 4 deletions extensions/cornerstone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@cornerstonejs/codec-libjpeg-turbo-8bit": "^1.2.2",
"@cornerstonejs/codec-openjpeg": "^1.2.4",
"@cornerstonejs/codec-openjph": "^2.4.5",
"@cornerstonejs/dicom-image-loader": "^2.2.20",
"@cornerstonejs/dicom-image-loader": "^2.7.3",
"@icr/polyseg-wasm": "^0.4.0",
"@ohif/core": "3.10.0-beta.14",
"@ohif/ui": "3.10.0-beta.14",
Expand All @@ -55,9 +55,9 @@
},
"dependencies": {
"@babel/runtime": "^7.20.13",
"@cornerstonejs/adapters": "^2.2.20",
"@cornerstonejs/core": "^2.2.20",
"@cornerstonejs/tools": "^2.2.20",
"@cornerstonejs/adapters": "^2.7.3",
"@cornerstonejs/core": "^2.7.3",
"@cornerstonejs/tools": "^2.7.3",
"@icr/polyseg-wasm": "^0.4.0",
"@kitware/vtk.js": "32.1.1",
"html2canvas": "^1.4.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,17 @@ function CornerstoneImageScrollbar({
return;
}

const imageIndex = viewport.getCurrentImageIdIndex();
const numberOfSlices = viewport.getNumberOfSlices();
try {
const imageIndex = viewport.getCurrentImageIdIndex();
const numberOfSlices = viewport.getNumberOfSlices();

setImageSliceData({
imageIndex: imageIndex,
numberOfSlices,
});
setImageSliceData({
imageIndex: imageIndex,
numberOfSlices,
});
} catch (error) {
console.warn(error);
}
}, [viewportId, viewportData]);

useEffect(() => {
Expand Down
3 changes: 2 additions & 1 deletion extensions/cornerstone/src/utils/ActiveViewportBehavior.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const ActiveViewportBehavior = memo(
}

const modalities = displaySets.map(displaySet => displaySet?.Modality);
const isDynamicVolume = displaySets.some(displaySet => displaySet?.isDynamicVolume);

const { modalities: sourceModalities } = customizationService.getModeCustomization(
'autoCineModalities',
Expand All @@ -50,7 +51,7 @@ const ActiveViewportBehavior = memo(

const requiresCine = modalities.some(modality => sourceModalities.includes(modality));

if (requiresCine && !cineService.getState().isCineEnabled) {
if ((requiresCine || isDynamicVolume) && !cineService.getState().isCineEnabled) {
cineService.setIsCineEnabled(true);
}
}, [
Expand Down
3 changes: 2 additions & 1 deletion extensions/default/src/DicomWebDataSource/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,8 @@ function createDicomWebApi(dicomWebConfig, servicesManager) {

if (Array.isArray(value) && typeof value[0] === 'object') {
// Fix recursive values
value.forEach(child => addRetrieveBulkDataNaturalized(child, instance));
const validValues = value.filter(Boolean);
validValues.forEach(child => addRetrieveBulkDataNaturalized(child, instance));
continue;
}

Expand Down
4 changes: 2 additions & 2 deletions extensions/measurement-tracking/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"start": "yarn run dev"
},
"peerDependencies": {
"@cornerstonejs/core": "^2.2.20",
"@cornerstonejs/tools": "^2.2.20",
"@cornerstonejs/core": "^2.7.3",
"@cornerstonejs/tools": "^2.7.3",
"@ohif/core": "3.10.0-beta.14",
"@ohif/extension-cornerstone-dicom-sr": "3.10.0-beta.14",
"@ohif/extension-default": "3.10.0-beta.14",
Expand Down
2 changes: 1 addition & 1 deletion platform/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"@cornerstonejs/codec-libjpeg-turbo-8bit": "^1.2.2",
"@cornerstonejs/codec-openjpeg": "^1.2.4",
"@cornerstonejs/codec-openjph": "^2.4.5",
"@cornerstonejs/dicom-image-loader": "^2.2.20",
"@cornerstonejs/dicom-image-loader": "^2.7.3",
"@emotion/serialize": "^1.1.3",
"@ohif/core": "3.10.0-beta.14",
"@ohif/extension-cornerstone": "3.10.0-beta.14",
Expand Down
2 changes: 1 addition & 1 deletion platform/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@cornerstonejs/codec-libjpeg-turbo-8bit": "^1.2.2",
"@cornerstonejs/codec-openjpeg": "^1.2.4",
"@cornerstonejs/codec-openjph": "^2.4.5",
"@cornerstonejs/dicom-image-loader": "^2.2.20",
"@cornerstonejs/dicom-image-loader": "^2.7.3",
"@ohif/ui": "3.10.0-beta.14",
"cornerstone-math": "0.1.9",
"dicom-parser": "^1.8.21"
Expand Down
8 changes: 5 additions & 3 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@ import { defineConfig, devices } from '@playwright/test';

export default defineConfig({
testDir: './tests',
fullyParallel: true,
fullyParallel: !!process.env.CI,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
snapshotPathTemplate: './tests/screenshots{/projectName}/{testFilePath}/{arg}{ext}',
outputDir: './tests/test-results',
reporter: [[process.env.CI ? 'blob' : 'html', { outputFolder: './tests/playwright-report' }]],
timeout: 720 * 1000,
globalTimeout: 800_000,
timeout: 800_000,
use: {
baseURL: 'http://localhost:3000',
trace: 'on-first-retry',
video: 'on',
testIdAttribute: 'data-cy',
actionTimeout: 10_000,
},

projects: [
Expand All @@ -39,6 +41,6 @@ export default defineConfig({
command: 'yarn test:e2e:serve',
url: 'http://localhost:3000',
reuseExistingServer: !process.env.CI,
timeout: 240 * 1000,
timeout: 360_000,
},
});
12 changes: 10 additions & 2 deletions tests/3DFourUp.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { test } from '@playwright/test';
import { visitStudy, checkForScreenshot, screenShotPaths, reduce3DViewportSize } from './utils';
import {
visitStudy,
checkForScreenshot,
screenShotPaths,
reduce3DViewportSize,
attemptAction,
} from './utils';

test.beforeEach(async ({ page }) => {
const studyInstanceUID = '1.3.6.1.4.1.14519.5.2.1.1706.8374.643249677828306008300337414785';
Expand All @@ -15,7 +21,9 @@ test.describe('3D four up Test', async () => {
.filter({ hasText: /^3D four up$/ })
.first()
.click();
await reduce3DViewportSize(page);

await attemptAction(() => reduce3DViewportSize(page), 10, 100);

await checkForScreenshot(
page,
page,
Expand Down
10 changes: 8 additions & 2 deletions tests/3DMain.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { test } from '@playwright/test';
import { visitStudy, checkForScreenshot, screenShotPaths, reduce3DViewportSize } from './utils';
import {
visitStudy,
checkForScreenshot,
screenShotPaths,
reduce3DViewportSize,
attemptAction,
} from './utils';

test.beforeEach(async ({ page }) => {
const studyInstanceUID = '1.3.6.1.4.1.14519.5.2.1.1706.8374.643249677828306008300337414785';
Expand All @@ -15,7 +21,7 @@ test.describe('3D main Test', async () => {
.filter({ hasText: /^3D main$/ })
.first()
.click();
await reduce3DViewportSize(page);
await attemptAction(() => reduce3DViewportSize(page), 10, 100);
await checkForScreenshot(
page,
page,
Expand Down
10 changes: 8 additions & 2 deletions tests/3DOnly.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { test } from '@playwright/test';
import { visitStudy, checkForScreenshot, screenShotPaths, reduce3DViewportSize } from './utils';
import {
visitStudy,
checkForScreenshot,
screenShotPaths,
reduce3DViewportSize,
attemptAction,
} from './utils';

test.beforeEach(async ({ page }) => {
const studyInstanceUID = '1.3.6.1.4.1.14519.5.2.1.1706.8374.643249677828306008300337414785';
Expand All @@ -15,7 +21,7 @@ test.describe('3D only Test', async () => {
.filter({ hasText: /^3D only$/ })
.first()
.click();
await reduce3DViewportSize(page);
await attemptAction(() => reduce3DViewportSize(page), 10, 100);
await checkForScreenshot(
page,
page,
Expand Down
10 changes: 8 additions & 2 deletions tests/3DPrimary.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { test } from '@playwright/test';
import { visitStudy, checkForScreenshot, screenShotPaths, reduce3DViewportSize } from './utils';
import {
visitStudy,
checkForScreenshot,
screenShotPaths,
reduce3DViewportSize,
attemptAction,
} from './utils';

test.beforeEach(async ({ page }) => {
const studyInstanceUID = '1.3.6.1.4.1.14519.5.2.1.1706.8374.643249677828306008300337414785';
Expand All @@ -16,7 +22,7 @@ test.describe('3D primary Test', async () => {
.first()
.click();

await reduce3DViewportSize(page);
await attemptAction(() => reduce3DViewportSize(page), 10, 100);
await checkForScreenshot(
page,
page,
Expand Down
20 changes: 13 additions & 7 deletions tests/Crosshairs.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { Page, test } from '@playwright/test';
import { visitStudy, checkForScreenshot, screenShotPaths, initilizeMousePositionTracker, getMousePosition } from './utils/index.js';

import {
visitStudy,
checkForScreenshot,
screenShotPaths,
initilizeMousePositionTracker,
getMousePosition,
} from './utils/index.js';

const rotateCrosshairs = async (page: Page, id: string, lineNumber: number) => {
const locator = await page.locator(id).locator('line').nth(lineNumber);
Expand All @@ -12,10 +17,10 @@ const rotateCrosshairs = async (page: Page, id: string, lineNumber: number) => {
const position = await getMousePosition(page);
await page.mouse.move(position.x, position.y + 100);
await page.mouse.up();
}
};

const increaseSlabThickness = async (page: Page, id: string, lineNumber: number, axis: string) => {
const locator = await page.locator(id).locator('line').nth(lineNumber)
const locator = await page.locator(id).locator('line').nth(lineNumber);
await locator.click({ force: true });
await locator.hover({ force: true });
const circleLocator = await page.locator(id).locator('rect').first();
Expand All @@ -31,7 +36,7 @@ const increaseSlabThickness = async (page: Page, id: string, lineNumber: number,
break;
}
await page.mouse.up();
}
};

test.beforeEach(async ({ page }) => {
const studyInstanceUID = '1.3.6.1.4.1.14519.5.2.1.1706.8374.643249677828306008300337414785';
Expand Down Expand Up @@ -73,7 +78,9 @@ test.describe('Crosshairs Test', async () => {
await checkForScreenshot(page, page, screenShotPaths.crosshairs.crosshairsSlabThickness);
});

test('should reset the crosshairs to the initial position when reset is clicked', async ({ page }) => {
test('should reset the crosshairs to the initial position when reset is clicked', async ({
page,
}) => {
await page.getByTestId('Layout').click();
await page.locator('div').filter({ hasText: /^MPR$/ }).first().click();
await page.getByTestId('Crosshairs').click();
Expand All @@ -100,5 +107,4 @@ test.describe('Crosshairs Test', async () => {

await checkForScreenshot(page, page, screenShotPaths.crosshairs.crosshairsNewDisplayset);
});

});
21 changes: 21 additions & 0 deletions tests/utils/attemptAction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
*
* @param action The action function to attempt
* @param attempts The number of attempts to try the action
* @param delay delay between attempts
* @returns True if the action is successful, otherwise throws an error
*/

export const attemptAction = async (action: () => Promise<void>, attempts = 10, delay = 100) => {
for (let i = 1; i < attempts; i++) {
try {
await action();
return true;
} catch (error) {
if (i === attempts) {
throw new Error('Action failed.');
}
await new Promise(resolve => setTimeout(resolve, delay));
}
}
};
2 changes: 2 additions & 0 deletions tests/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { getSUV } from './getSUV';
import { getTMTVModalityUnit } from './getTMTVModalityUnit';
import { clearAllAnnotations } from './clearAllAnnotations';
import { scrollVolumeViewport } from './scrollVolumeViewport';
import { attemptAction } from './attemptAction';

export {
visitStudy,
Expand All @@ -21,4 +22,5 @@ export {
getTMTVModalityUnit,
clearAllAnnotations,
scrollVolumeViewport,
attemptAction,
};
Loading

0 comments on commit b8e8bbe

Please sign in to comment.