Skip to content

Commit

Permalink
fix(viewport-webworker-segmentation): Resolve issues with viewport de…
Browse files Browse the repository at this point in the history
…tection, webworker termination, and segmentation panel layout change (OHIF#4059)
  • Loading branch information
sedghi authored and thanh-nguyen-dang committed Apr 30, 2024
1 parent 7549fda commit 44b91a5
Show file tree
Hide file tree
Showing 15 changed files with 71 additions and 51 deletions.
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": "^1.70.10",
"@cornerstonejs/core": "^1.70.10",
"@cornerstonejs/adapters": "^1.70.12",
"@cornerstonejs/core": "^1.70.12",
"@kitware/vtk.js": "30.3.3",
"react-color": "^2.19.3"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ export default function PanelSegmentation({
};

const onSegmentationAdd = async () => {
commandsManager.runCommand('createEmptySegmentationForViewport');
commandsManager.runCommand('createEmptySegmentationForViewport', {
viewportId: viewportGridService.getActiveViewportId(),
});
};

const onSegmentationClick = (segmentationId: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ function OHIFCornerstoneSEGViewport(props) {
displaySetService,
toolGroupService,
segmentationService,
uiNotificationService,
customizationService,
viewportActionCornersService,
} = servicesManager.services;
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": "^1.70.10",
"@cornerstonejs/core": "^1.70.10",
"@cornerstonejs/tools": "^1.70.10",
"@cornerstonejs/adapters": "^1.70.12",
"@cornerstonejs/core": "^1.70.12",
"@cornerstonejs/tools": "^1.70.12",
"classnames": "^2.3.2"
}
}
6 changes: 3 additions & 3 deletions extensions/cornerstone-dynamic-volume/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
},
"dependencies": {
"@babel/runtime": "^7.20.13",
"@cornerstonejs/core": "^1.70.10",
"@cornerstonejs/streaming-image-volume-loader": "^1.70.10",
"@cornerstonejs/tools": "^1.70.10",
"@cornerstonejs/core": "^1.70.12",
"@cornerstonejs/streaming-image-volume-loader": "^1.70.12",
"@cornerstonejs/tools": "^1.70.12",
"classnames": "^2.3.2"
}
}
10 changes: 5 additions & 5 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.2",
"@cornerstonejs/codec-openjph": "^2.4.2",
"@cornerstonejs/dicom-image-loader": "^1.70.10",
"@cornerstonejs/dicom-image-loader": "^1.70.12",
"@icr/polyseg-wasm": "^0.4.0",
"@ohif/core": "3.8.0-beta.88",
"@ohif/ui": "3.8.0-beta.88",
Expand All @@ -55,10 +55,10 @@
},
"dependencies": {
"@babel/runtime": "^7.20.13",
"@cornerstonejs/adapters": "^1.70.10",
"@cornerstonejs/core": "^1.70.10",
"@cornerstonejs/streaming-image-volume-loader": "^1.70.10",
"@cornerstonejs/tools": "^1.70.10",
"@cornerstonejs/adapters": "^1.70.12",
"@cornerstonejs/core": "^1.70.12",
"@cornerstonejs/streaming-image-volume-loader": "^1.70.12",
"@cornerstonejs/tools": "^1.70.12",
"@icr/polyseg-wasm": "^0.4.0",
"@kitware/vtk.js": "30.3.3",
"html2canvas": "^1.4.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const OHIFCornerstoneViewport = React.memo(props => {
// Since we only have support for dynamic data in volume viewports, we should
// handle this case here and set the viewportType to volume if any of the
// displaySets are dynamic volumes
viewportOptions.viewportType = displaySets.some(ds => ds.isDynamicVolume)
viewportOptions.viewportType = displaySets.some(ds => ds.isDynamicVolume && ds.isReconstructable)
? 'volume'
: viewportOptions.viewportType;

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": "^1.70.10",
"@cornerstonejs/tools": "^1.70.10",
"@cornerstonejs/core": "^1.70.12",
"@cornerstonejs/tools": "^1.70.12",
"@ohif/core": "3.8.0-beta.88",
"@ohif/extension-cornerstone-dicom-sr": "3.8.0-beta.88",
"@ohif/ui": "3.8.0-beta.88",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default function PanelRoiThresholdSegmentation({ servicesManager, command
}
};

eventTarget.addEventListenerDebounced(Enums.Events.SEGMENTATION_DATA_MODIFIED, callback, 300);
eventTarget.addEventListenerDebounced(Enums.Events.SEGMENTATION_DATA_MODIFIED, callback, 250);

return () => {
eventTarget.removeEventListenerDebounced(Enums.Events.SEGMENTATION_DATA_MODIFIED, callback);
Expand Down
20 changes: 19 additions & 1 deletion extensions/tmtv/src/commandsModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,28 @@ const commandsModule = ({ servicesManager, commandsManager, extensionManager })
metadata: referencedVolume.metadata,
};

// metadata in annotations has enabledElement which is not serializable
// we need to remove it
// Todo: we should probably have a sanitization function for this
const annotationsToSend = annotations.map(annotation => {
return {
...annotation,
metadata: {
...annotation.metadata,
enabledElement: {
...annotation.metadata.enabledElement,
viewport: null,
renderingEngine: null,
element: null,
},
},
};
});

const suvPeak = await workerManager.executeTask('suv-peak-worker', 'calculateSuvPeak', {
labelmapProps,
referenceVolumeProps,
annotations,
annotations: annotationsToSend,
segmentIndex,
});

Expand Down
2 changes: 1 addition & 1 deletion platform/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@cornerstonejs/codec-libjpeg-turbo-8bit": "^1.2.2",
"@cornerstonejs/codec-openjpeg": "^1.2.2",
"@cornerstonejs/codec-openjph": "^2.4.5",
"@cornerstonejs/dicom-image-loader": "^1.70.10",
"@cornerstonejs/dicom-image-loader": "^1.70.12",
"@emotion/serialize": "^1.1.3",
"@ohif/core": "3.8.0-beta.88",
"@ohif/extension-cornerstone": "3.8.0-beta.88",
Expand Down
5 changes: 2 additions & 3 deletions platform/app/src/routes/WorkList/WorkList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { utils, hotkeys, ServicesManager } from '@ohif/core';
import {
Icon,
StudyListExpandedRow,
LegacyButton,
EmptyStudies,
StudyListTable,
StudyListPagination,
Expand Down Expand Up @@ -526,7 +525,7 @@ function WorkList({
customizationService.get('ohif.dataSourceConfigurationComponent') ?? {};

return (
<div className="flex h-screen flex-col bg-black ">
<div className="flex h-screen flex-col bg-black">
<Header
isSticky
menuOptions={menuOptions}
Expand All @@ -535,7 +534,7 @@ function WorkList({
showPatientInfo={PatientInfoVisibility.DISABLED}
/>
<InvestigationalUseDialog dialogConfiguration={appConfig?.investigationalUseDialog} />
<div className="ohif-scrollbar ohif-scrollbar-stable-gutter flex grow flex-col overflow-y-auto">
<div className="ohif-scrollbar ohif-scrollbar-stable-gutter flex grow flex-col overflow-y-auto sm:px-5">
<StudyListFilter
numOfStudies={pageNumber * resultsPerPage > 100 ? 101 : numOfStudies}
filtersMeta={filtersMeta}
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.2",
"@cornerstonejs/codec-openjph": "^2.4.2",
"@cornerstonejs/dicom-image-loader": "^1.70.10",
"@cornerstonejs/dicom-image-loader": "^1.70.12",
"@ohif/ui": "3.8.0-beta.88",
"cornerstone-math": "0.1.9",
"dicom-parser": "^1.8.21"
Expand Down
6 changes: 4 additions & 2 deletions platform/ui/src/contextProviders/ViewportGridProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,10 @@ export function ViewportGridProvider({ children, service }) {

// if it is not part of the hanging protocol layout, we should remove the toolGroupId
// and viewportType from the viewportOptions so that it doesn't
// inherit the hanging protocol layout options
if (!state.isHangingProtocolLayout) {
// inherit the hanging protocol layout options, only when
// the viewport options is not provided (e.g., when drag and drop)
// otherwise, programmatically set options should be preserved
if (!updatedViewport.viewportOptions && !state.isHangingProtocolLayout) {
viewportOptions = {
viewportId: viewportOptions.viewportId,
};
Expand Down
48 changes: 24 additions & 24 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1497,13 +1497,13 @@
resolved "https://registry.yarnpkg.com/@colors/colors/-/colors-1.5.0.tgz#bb504579c1cae923e6576a4f5da43d25f97bdbd9"
integrity sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==

"@cornerstonejs/adapters@^1.70.10":
version "1.70.10"
resolved "https://registry.yarnpkg.com/@cornerstonejs/adapters/-/adapters-1.70.10.tgz#5b8113a6a7c0d8677d72d97761530e3e7f91e118"
integrity sha512-OTYDg64SjrmCGEt1VDM27iaUOXi+v7WZaoJI5CfwXOA3cHG9AAv8lRaCtvUhIMKXce7HZuYdgKh/zizvrnVPow==
"@cornerstonejs/adapters@^1.70.12":
version "1.70.12"
resolved "https://registry.yarnpkg.com/@cornerstonejs/adapters/-/adapters-1.70.12.tgz#6556cb511840a6d10cc8eabbf7c408a5e07f3d33"
integrity sha512-XeBCpgW8S7WgTbFqq5oH3S4P5reVD9hXF10yPnEVpSdXygEFuFz4CG00RgVUEt7OT2gBNS18AZSLUqpZajmvlA==
dependencies:
"@babel/runtime-corejs2" "^7.17.8"
"@cornerstonejs/tools" "^1.70.10"
"@cornerstonejs/tools" "^1.70.12"
buffer "^6.0.3"
dcmjs "^0.29.8"
gl-matrix "^3.4.3"
Expand Down Expand Up @@ -1550,45 +1550,45 @@
resolved "https://registry.yarnpkg.com/@cornerstonejs/codec-openjph/-/codec-openjph-2.4.5.tgz#8690b61a86fa53ef38a70eee9d665a79229517c0"
integrity sha512-MZCUy8VG0VG5Nl1l58+g+kH3LujAzLYTfJqkwpWI2gjSrGXnP6lgwyy4GmPRZWVoS40/B1LDNALK905cNWm+sg==

"@cornerstonejs/core@^1.70.10":
version "1.70.10"
resolved "https://registry.yarnpkg.com/@cornerstonejs/core/-/core-1.70.10.tgz#8485ad15cd07e784a07892c2d2246bc6e2d5d5fe"
integrity sha512-c9wkgDGKpGt0VEdILLAIn5ZRTqoofsGrWAzj+8h0zogdVY9yQ1PIP2WW7xEbuUcJ/m1RFpapiwqMFU6UEXNNBA==
"@cornerstonejs/core@^1.70.12":
version "1.70.12"
resolved "https://registry.yarnpkg.com/@cornerstonejs/core/-/core-1.70.12.tgz#51bbb966603439bec84aced69a664d04b13f7071"
integrity sha512-rGnmpEuLUruc9TcHpFBlEuCJPxufb0r9I5wbhh4VUhSUcyVgRA5gyImuny2pt8W4yhN3DCLE9LpNX9dah1/O0A==
dependencies:
"@kitware/vtk.js" "30.3.3"
comlink "^4.4.1"
detect-gpu "^5.0.22"
gl-matrix "^3.4.3"
lodash.clonedeep "4.5.0"

"@cornerstonejs/dicom-image-loader@^1.70.10":
version "1.70.10"
resolved "https://registry.yarnpkg.com/@cornerstonejs/dicom-image-loader/-/dicom-image-loader-1.70.10.tgz#29de339e969e370b07fbb229724094b924cf5469"
integrity sha512-4/J4xU3C1Qk8KAQaQdF0duaehfGFX5z47ucU3rXqvN44+qHZrK/iPeGVORhJmErlB9qTY++K8uAZbqo/E65Aiw==
"@cornerstonejs/dicom-image-loader@^1.70.12":
version "1.70.12"
resolved "https://registry.yarnpkg.com/@cornerstonejs/dicom-image-loader/-/dicom-image-loader-1.70.12.tgz#376b2ac1d6e36f1aaf2e2acd0f90f3b5d1a510b3"
integrity sha512-OBcP+QqhBHim9LsPrhBg9w5SkkY88YYgnI1elw2PzOu2thMm7Em2CgHDf0VlrNEvStovkvaqFdo6sawP3QD5HA==
dependencies:
"@cornerstonejs/codec-charls" "^1.2.3"
"@cornerstonejs/codec-libjpeg-turbo-8bit" "^1.2.2"
"@cornerstonejs/codec-openjpeg" "^1.2.2"
"@cornerstonejs/codec-openjph" "^2.4.5"
"@cornerstonejs/core" "^1.70.10"
"@cornerstonejs/core" "^1.70.12"
dicom-parser "^1.8.9"
pako "^2.0.4"
uuid "^9.0.0"

"@cornerstonejs/streaming-image-volume-loader@^1.70.10":
version "1.70.10"
resolved "https://registry.yarnpkg.com/@cornerstonejs/streaming-image-volume-loader/-/streaming-image-volume-loader-1.70.10.tgz#e548e82b1014517efd686c294e161a15b66b6e1e"
integrity sha512-Rg7v0WDjGNjV+DPXLj1LLSXV/6kBq+RxRBxLVfKnA3onEFRuPxqnMUYY9uxG7Edr5RLaGlnBCr4V4tvFzzYYmA==
"@cornerstonejs/streaming-image-volume-loader@^1.70.12":
version "1.70.12"
resolved "https://registry.yarnpkg.com/@cornerstonejs/streaming-image-volume-loader/-/streaming-image-volume-loader-1.70.12.tgz#f3ca840ec003db4fd7b336568627a39c5462244c"
integrity sha512-U6lUOfUduZKl2VeAikcAw5sDUrZoWiCCS4c4dI67lPZLdIREdbJYHf+cG8EovsaN0nvm1gGvYfD5R47TojQUyw==
dependencies:
"@cornerstonejs/core" "^1.70.10"
"@cornerstonejs/core" "^1.70.12"
comlink "^4.4.1"

"@cornerstonejs/tools@^1.70.10":
version "1.70.10"
resolved "https://registry.yarnpkg.com/@cornerstonejs/tools/-/tools-1.70.10.tgz#9b24b17dfb5ba48556df7643bee01f79b6378672"
integrity sha512-GmwhfB/DzEc86cur2pHvlLp/FCvhG7WlNe0dJWLNRPA/fgPt+BPVBwrMf4a6934r4N7WCzwOJjcnUpiwDjT+MQ==
"@cornerstonejs/tools@^1.70.12":
version "1.70.12"
resolved "https://registry.yarnpkg.com/@cornerstonejs/tools/-/tools-1.70.12.tgz#6f1c7c82bf5b84f10588222564d270ffb2cfca7a"
integrity sha512-UKWoA/dLvhH5F1KnR/dZ454OL6m8npubGYse0f6BEfushqvN+INNKgj9zwPLXvfgyibwaz1SC6iIduUvIQMudg==
dependencies:
"@cornerstonejs/core" "^1.70.10"
"@cornerstonejs/core" "^1.70.12"
"@icr/polyseg-wasm" "0.4.0"
"@types/offscreencanvas" "2019.7.3"
comlink "^4.4.1"
Expand Down

0 comments on commit 44b91a5

Please sign in to comment.