2022-07-27 18:39:04 +02:00
|
|
|
import React from 'react';
|
|
|
|
|
import * as cornerstone from '@cornerstonejs/core';
|
|
|
|
|
import * as cornerstoneTools from '@cornerstonejs/tools';
|
|
|
|
|
import {
|
|
|
|
|
Enums as cs3DEnums,
|
|
|
|
|
imageLoadPoolManager,
|
|
|
|
|
imageRetrievalPoolManager,
|
|
|
|
|
} from '@cornerstonejs/core';
|
|
|
|
|
import { Enums as cs3DToolsEnums } from '@cornerstonejs/tools';
|
2024-05-08 18:12:49 +02:00
|
|
|
import { Types } from '@ohif/core';
|
2024-10-17 15:36:24 +02:00
|
|
|
import Enums from './enums';
|
2023-02-10 22:46:09 +01:00
|
|
|
|
2022-11-16 20:19:52 +01:00
|
|
|
import init from './init';
|
feat(RT): add dicom RT support via volume viewports (#3310)
* feat: initial RT support
* make the segmentation service work with representation data
* feat: make segmentation service work with representations
* fix rtss vis
* fix: rt hydration
* fix the rendering of rt names
* fix imports
* refactor: Modify status and click handling for hydration of RTStructures
Modify status and click handling for hydration of RTStructures by renaming `onPillClick` to `onStatusClick` in `OHIFCornerstoneRTViewport.tsx` and `_getStatusComponent.tsx` files. Also, update initial segmentation configurations in `PanelSegmentation.tsx` and simplify configuration changes and values for segmentation service in `SegmentationService.ts`. Finally, remove console debug in `CornerstoneViewportService.ts`.
* wip for highlighting contours
* refactor rt displayset code
* review code update
* update cornerstone dependencies
* refactor: Update license year, version number, and minor code cleanup
This commit updates the license year in several files, updates the version number in package.json, and contains minor code cleanup in two files.
* add bulkdataURI retrieve for RT
* fix package version
* apply review comments
* apply review comments
* apply review comments
* feat(panels): refactor and streamline segmentation configuration and inputs
Rewrote state hooks and streamlined the configuration input for `PanelSegmentation` to be more verbose and reusable. Included several new input types, including the `InputRange` component which now shows a fixed floating value based on the step provided. The `SegmentationConfig` component now works with dynamic values controlled by `initialConfig`. These changes should improve function usability and make the code more maintainable going forward.
* fix various bugs
* fix contour delete by upgrade cs3d version
* feat(viewport, inputNumber, segmentationConfig, orthanc): Implement minimum and maximum values for input number components, and useBulkDataURI for Orthanc configuration. Compare measurement view planes with absolute viewport view planes in Cornerstone viewport.
* update yarn lock
2023-04-26 18:21:08 +02:00
|
|
|
import getCustomizationModule from './getCustomizationModule';
|
2023-03-22 22:45:28 +01:00
|
|
|
import getCommandsModule from './commandsModule';
|
2022-09-21 05:40:26 +02:00
|
|
|
import getHangingProtocolModule from './getHangingProtocolModule';
|
2024-03-27 21:01:32 +01:00
|
|
|
import getToolbarModule from './getToolbarModule';
|
2022-07-27 18:39:04 +02:00
|
|
|
import ToolGroupService from './services/ToolGroupService';
|
|
|
|
|
import SyncGroupService from './services/SyncGroupService';
|
2022-11-16 20:19:52 +01:00
|
|
|
import SegmentationService from './services/SegmentationService';
|
|
|
|
|
import CornerstoneCacheService from './services/CornerstoneCacheService';
|
2023-04-18 17:17:50 +02:00
|
|
|
import CornerstoneViewportService from './services/ViewportService/CornerstoneViewportService';
|
2024-04-02 15:35:30 +02:00
|
|
|
import ColorbarService from './services/ColorbarService';
|
2023-04-18 17:17:50 +02:00
|
|
|
import * as CornerstoneExtensionTypes from './types';
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2022-07-27 18:39:04 +02:00
|
|
|
import { toolNames } from './initCornerstoneTools';
|
2024-06-07 22:02:36 +02:00
|
|
|
import { getEnabledElement, reset as enabledElementReset, setEnabledElement } from './state';
|
2022-07-27 18:39:04 +02:00
|
|
|
import dicomLoaderService from './utils/dicomLoaderService';
|
2023-05-11 16:01:33 +02:00
|
|
|
import getActiveViewportEnabledElement from './utils/getActiveViewportEnabledElement';
|
2022-07-27 18:39:04 +02:00
|
|
|
|
|
|
|
|
import { id } from './id';
|
2023-02-17 22:44:21 +01:00
|
|
|
import { measurementMappingUtils } from './utils/measurementServiceMappings';
|
2023-04-28 02:53:52 +02:00
|
|
|
import type { PublicViewportOptions } from './services/ViewportService/Viewport';
|
2023-11-21 15:05:25 +01:00
|
|
|
import ImageOverlayViewerTool from './tools/ImageOverlayViewerTool';
|
2024-04-02 15:35:30 +02:00
|
|
|
import ViewportActionCornersService from './services/ViewportActionCornersService/ViewportActionCornersService';
|
|
|
|
|
import { ViewportActionCornersProvider } from './contextProviders/ViewportActionCornersProvider';
|
2024-06-07 22:02:36 +02:00
|
|
|
import getSOPInstanceAttributes from './utils/measurementServiceMappings/utils/getSOPInstanceAttributes';
|
|
|
|
|
import { findNearbyToolData } from './utils/findNearbyToolData';
|
2024-06-21 17:22:05 +02:00
|
|
|
import { createFrameViewSynchronizer } from './synchronizers/frameViewSynchronizer';
|
2024-08-15 20:36:53 +02:00
|
|
|
import { getSopClassHandlerModule } from './getSopClassHandlerModule';
|
2024-11-06 13:15:27 +01:00
|
|
|
import { getDynamicVolumeInfo } from '@cornerstonejs/core/utilities';
|
|
|
|
|
import {
|
|
|
|
|
useLutPresentationStore,
|
|
|
|
|
usePositionPresentationStore,
|
|
|
|
|
useSegmentationPresentationStore,
|
|
|
|
|
useSynchronizersStore,
|
|
|
|
|
} from './stores';
|
2024-11-28 19:22:40 +01:00
|
|
|
import { useToggleOneUpViewportGridStore } from '@ohif/extension-default';
|
2024-11-06 13:15:27 +01:00
|
|
|
import { useActiveViewportSegmentationRepresentations } from './hooks/useActiveViewportSegmentationRepresentations';
|
|
|
|
|
import { useMeasurements } from './hooks/useMeasurements';
|
|
|
|
|
import getPanelModule from './getPanelModule';
|
|
|
|
|
import PanelSegmentation from './panels/PanelSegmentation';
|
|
|
|
|
import PanelMeasurement from './panels/PanelMeasurement';
|
|
|
|
|
import DicomUpload from './components/DicomUpload/DicomUpload';
|
|
|
|
|
import { useSegmentations } from './hooks/useSegmentations';
|
2025-01-10 04:01:42 +01:00
|
|
|
import { StudySummaryFromMetadata } from './components/StudySummaryFromMetadata';
|
2025-02-25 22:25:52 +01:00
|
|
|
import utils from './utils';
|
2024-04-10 05:57:34 +02:00
|
|
|
|
2024-07-05 18:33:07 +02:00
|
|
|
const { imageRetrieveMetadataProvider } = cornerstone.utilities;
|
2022-07-27 18:39:04 +02:00
|
|
|
|
|
|
|
|
const Component = React.lazy(() => {
|
2023-09-01 22:19:39 +02:00
|
|
|
return import(/* webpackPrefetch: true */ './Viewport/OHIFCornerstoneViewport');
|
2022-07-27 18:39:04 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const OHIFCornerstoneViewport = props => {
|
|
|
|
|
return (
|
|
|
|
|
<React.Suspense fallback={<div>Loading...</div>}>
|
|
|
|
|
<Component {...props} />
|
|
|
|
|
</React.Suspense>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2024-07-05 18:33:07 +02:00
|
|
|
const stackRetrieveOptions = {
|
|
|
|
|
retrieveOptions: {
|
|
|
|
|
single: {
|
|
|
|
|
streaming: true,
|
|
|
|
|
decodeLevel: 1,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
2022-07-27 18:39:04 +02:00
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
2023-02-10 22:46:09 +01:00
|
|
|
const cornerstoneExtension: Types.Extensions.Extension = {
|
2022-07-27 18:39:04 +02:00
|
|
|
/**
|
|
|
|
|
* Only required property. Should be a unique value across all extensions.
|
|
|
|
|
*/
|
|
|
|
|
id,
|
|
|
|
|
|
2024-05-08 18:12:49 +02:00
|
|
|
onModeEnter: ({ servicesManager }: withAppTypes): void => {
|
2024-04-18 03:59:47 +02:00
|
|
|
const { cornerstoneViewportService, toolbarService, segmentationService } =
|
|
|
|
|
servicesManager.services;
|
|
|
|
|
toolbarService.registerEventForToolbarUpdate(cornerstoneViewportService, [
|
|
|
|
|
cornerstoneViewportService.EVENTS.VIEWPORT_DATA_CHANGED,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
toolbarService.registerEventForToolbarUpdate(segmentationService, [
|
|
|
|
|
segmentationService.EVENTS.SEGMENTATION_REMOVED,
|
2024-11-06 13:15:27 +01:00
|
|
|
segmentationService.EVENTS.SEGMENTATION_MODIFIED,
|
2024-04-18 03:59:47 +02:00
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
toolbarService.registerEventForToolbarUpdate(cornerstone.eventTarget, [
|
|
|
|
|
cornerstoneTools.Enums.Events.TOOL_ACTIVATED,
|
|
|
|
|
]);
|
2024-07-05 18:33:07 +02:00
|
|
|
|
|
|
|
|
// Configure the interleaved/HTJ2K loader
|
|
|
|
|
imageRetrieveMetadataProvider.clear();
|
|
|
|
|
// The default volume interleaved options are to interleave the
|
|
|
|
|
// image retrieve, but don't perform progressive loading per image
|
|
|
|
|
// This interleaves images and replicates them for low-resolution depth volume
|
|
|
|
|
// reconstruction, which progressively improves
|
|
|
|
|
imageRetrieveMetadataProvider.add(
|
|
|
|
|
'volume',
|
|
|
|
|
cornerstone.ProgressiveRetrieveImages.interleavedRetrieveStages
|
|
|
|
|
);
|
|
|
|
|
// The default stack loading option is to progressive load HTJ2K images
|
|
|
|
|
// There are other possible options, but these need more thought about
|
|
|
|
|
// how to define them.
|
|
|
|
|
imageRetrieveMetadataProvider.add('stack', stackRetrieveOptions);
|
2024-04-18 03:59:47 +02:00
|
|
|
},
|
2024-11-06 13:15:27 +01:00
|
|
|
getPanelModule,
|
2024-05-08 18:12:49 +02:00
|
|
|
onModeExit: ({ servicesManager }: withAppTypes): void => {
|
2024-11-06 13:15:27 +01:00
|
|
|
const { cineService, segmentationService } = servicesManager.services;
|
2022-07-27 18:39:04 +02:00
|
|
|
// Empty out the image load and retrieval pools to prevent memory leaks
|
|
|
|
|
// on the mode exits
|
|
|
|
|
Object.values(cs3DEnums.RequestType).forEach(type => {
|
|
|
|
|
imageLoadPoolManager.clearRequestStack(type);
|
|
|
|
|
imageRetrievalPoolManager.clearRequestStack(type);
|
|
|
|
|
});
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-04-16 17:04:48 +02:00
|
|
|
cineService.setIsCineEnabled(false);
|
|
|
|
|
|
2022-11-16 20:19:52 +01:00
|
|
|
enabledElementReset();
|
2024-11-06 13:15:27 +01:00
|
|
|
|
|
|
|
|
useLutPresentationStore.getState().clearLutPresentationStore();
|
|
|
|
|
usePositionPresentationStore.getState().clearPositionPresentationStore();
|
|
|
|
|
useSynchronizersStore.getState().clearSynchronizersStore();
|
|
|
|
|
useToggleOneUpViewportGridStore.getState().clearToggleOneUpViewportGridStore();
|
|
|
|
|
useSegmentationPresentationStore.getState().clearSegmentationPresentationStore();
|
|
|
|
|
segmentationService.removeAllSegmentations();
|
2022-07-27 18:39:04 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
2023-02-17 22:44:21 +01:00
|
|
|
* Register the Cornerstone 3D services and set them up for use.
|
2022-07-27 18:39:04 +02:00
|
|
|
*
|
2023-02-17 22:44:21 +01:00
|
|
|
* @param configuration.csToolsConfig - Passed directly to `initCornerstoneTools`
|
2022-07-27 18:39:04 +02:00
|
|
|
*/
|
2023-09-01 22:19:39 +02:00
|
|
|
preRegistration: function (props: Types.Extensions.ExtensionParams): Promise<void> {
|
2024-04-02 15:35:30 +02:00
|
|
|
const { servicesManager, serviceProvidersManager } = props;
|
2023-04-18 17:17:50 +02:00
|
|
|
servicesManager.registerService(CornerstoneViewportService.REGISTRATION);
|
|
|
|
|
servicesManager.registerService(ToolGroupService.REGISTRATION);
|
|
|
|
|
servicesManager.registerService(SyncGroupService.REGISTRATION);
|
|
|
|
|
servicesManager.registerService(SegmentationService.REGISTRATION);
|
|
|
|
|
servicesManager.registerService(CornerstoneCacheService.REGISTRATION);
|
2024-04-02 15:35:30 +02:00
|
|
|
servicesManager.registerService(ViewportActionCornersService.REGISTRATION);
|
|
|
|
|
servicesManager.registerService(ColorbarService.REGISTRATION);
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-04-02 15:35:30 +02:00
|
|
|
serviceProvidersManager.registerProvider(
|
|
|
|
|
ViewportActionCornersService.REGISTRATION.name,
|
|
|
|
|
ViewportActionCornersProvider
|
|
|
|
|
);
|
2024-06-21 17:22:05 +02:00
|
|
|
|
2025-01-29 19:36:52 +01:00
|
|
|
const { syncGroupService } = servicesManager.services;
|
2024-06-21 17:22:05 +02:00
|
|
|
syncGroupService.registerCustomSynchronizer('frameview', createFrameViewSynchronizer);
|
2025-01-23 20:24:13 +01:00
|
|
|
|
2023-03-22 22:45:28 +01:00
|
|
|
return init.call(this, props);
|
2022-07-27 18:39:04 +02:00
|
|
|
},
|
2024-03-27 21:01:32 +01:00
|
|
|
getToolbarModule,
|
2022-09-21 05:40:26 +02:00
|
|
|
getHangingProtocolModule,
|
2022-07-27 18:39:04 +02:00
|
|
|
getViewportModule({ servicesManager, commandsManager }) {
|
|
|
|
|
const ExtendedOHIFCornerstoneViewport = props => {
|
|
|
|
|
// const onNewImageHandler = jumpData => {
|
|
|
|
|
// commandsManager.runCommand('jumpToImage', jumpData);
|
|
|
|
|
// };
|
2024-05-08 18:12:49 +02:00
|
|
|
const { toolbarService } = servicesManager.services;
|
2022-07-27 18:39:04 +02:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<OHIFCornerstoneViewport
|
|
|
|
|
{...props}
|
2023-04-25 23:25:10 +02:00
|
|
|
toolbarService={toolbarService}
|
2022-07-27 18:39:04 +02:00
|
|
|
servicesManager={servicesManager}
|
|
|
|
|
commandsManager={commandsManager}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
{
|
|
|
|
|
name: 'cornerstone',
|
|
|
|
|
component: ExtendedOHIFCornerstoneViewport,
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
},
|
2023-03-22 22:45:28 +01:00
|
|
|
getCommandsModule,
|
feat(RT): add dicom RT support via volume viewports (#3310)
* feat: initial RT support
* make the segmentation service work with representation data
* feat: make segmentation service work with representations
* fix rtss vis
* fix: rt hydration
* fix the rendering of rt names
* fix imports
* refactor: Modify status and click handling for hydration of RTStructures
Modify status and click handling for hydration of RTStructures by renaming `onPillClick` to `onStatusClick` in `OHIFCornerstoneRTViewport.tsx` and `_getStatusComponent.tsx` files. Also, update initial segmentation configurations in `PanelSegmentation.tsx` and simplify configuration changes and values for segmentation service in `SegmentationService.ts`. Finally, remove console debug in `CornerstoneViewportService.ts`.
* wip for highlighting contours
* refactor rt displayset code
* review code update
* update cornerstone dependencies
* refactor: Update license year, version number, and minor code cleanup
This commit updates the license year in several files, updates the version number in package.json, and contains minor code cleanup in two files.
* add bulkdataURI retrieve for RT
* fix package version
* apply review comments
* apply review comments
* apply review comments
* feat(panels): refactor and streamline segmentation configuration and inputs
Rewrote state hooks and streamlined the configuration input for `PanelSegmentation` to be more verbose and reusable. Included several new input types, including the `InputRange` component which now shows a fixed floating value based on the step provided. The `SegmentationConfig` component now works with dynamic values controlled by `initialConfig`. These changes should improve function usability and make the code more maintainable going forward.
* fix various bugs
* fix contour delete by upgrade cs3d version
* feat(viewport, inputNumber, segmentationConfig, orthanc): Implement minimum and maximum values for input number components, and useBulkDataURI for Orthanc configuration. Compare measurement view planes with absolute viewport view planes in Cornerstone viewport.
* update yarn lock
2023-04-26 18:21:08 +02:00
|
|
|
getCustomizationModule,
|
2022-07-27 18:39:04 +02:00
|
|
|
getUtilityModule({ servicesManager }) {
|
|
|
|
|
return [
|
|
|
|
|
{
|
|
|
|
|
name: 'common',
|
|
|
|
|
exports: {
|
|
|
|
|
getCornerstoneLibraries: () => {
|
|
|
|
|
return { cornerstone, cornerstoneTools };
|
|
|
|
|
},
|
|
|
|
|
getEnabledElement,
|
|
|
|
|
dicomLoaderService,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'core',
|
|
|
|
|
exports: {
|
|
|
|
|
Enums: cs3DEnums,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'tools',
|
|
|
|
|
exports: {
|
|
|
|
|
toolNames,
|
|
|
|
|
Enums: cs3DToolsEnums,
|
|
|
|
|
},
|
|
|
|
|
},
|
2024-04-10 05:57:34 +02:00
|
|
|
{
|
|
|
|
|
name: 'volumeLoader',
|
|
|
|
|
exports: {
|
|
|
|
|
getDynamicVolumeInfo,
|
|
|
|
|
},
|
|
|
|
|
},
|
2022-07-27 18:39:04 +02:00
|
|
|
];
|
|
|
|
|
},
|
2024-08-15 20:36:53 +02:00
|
|
|
getSopClassHandlerModule,
|
2022-07-27 18:39:04 +02:00
|
|
|
};
|
|
|
|
|
|
2023-03-22 17:44:52 +01:00
|
|
|
export type { PublicViewportOptions };
|
2023-09-01 22:19:39 +02:00
|
|
|
export {
|
|
|
|
|
measurementMappingUtils,
|
2023-09-22 16:23:44 +02:00
|
|
|
CornerstoneExtensionTypes as Types,
|
2023-09-01 22:19:39 +02:00
|
|
|
toolNames,
|
|
|
|
|
getActiveViewportEnabledElement,
|
2024-06-07 22:02:36 +02:00
|
|
|
setEnabledElement,
|
|
|
|
|
findNearbyToolData,
|
|
|
|
|
getEnabledElement,
|
2023-11-21 15:05:25 +01:00
|
|
|
ImageOverlayViewerTool,
|
2024-06-07 22:02:36 +02:00
|
|
|
getSOPInstanceAttributes,
|
2024-07-24 22:40:28 +02:00
|
|
|
dicomLoaderService,
|
2024-11-06 13:15:27 +01:00
|
|
|
// Export all stores
|
|
|
|
|
useLutPresentationStore,
|
|
|
|
|
usePositionPresentationStore,
|
|
|
|
|
useSegmentationPresentationStore,
|
|
|
|
|
useSynchronizersStore,
|
2024-10-17 15:36:24 +02:00
|
|
|
Enums,
|
2024-11-06 13:15:27 +01:00
|
|
|
useMeasurements,
|
|
|
|
|
useActiveViewportSegmentationRepresentations,
|
|
|
|
|
useSegmentations,
|
|
|
|
|
PanelSegmentation,
|
|
|
|
|
PanelMeasurement,
|
|
|
|
|
DicomUpload,
|
2025-01-10 04:01:42 +01:00
|
|
|
StudySummaryFromMetadata,
|
2025-02-25 22:25:52 +01:00
|
|
|
utils,
|
2023-09-01 22:19:39 +02:00
|
|
|
};
|
2022-07-27 18:39:04 +02:00
|
|
|
export default cornerstoneExtension;
|