2022-11-16 20:19:52 +01:00
|
|
|
import {
|
|
|
|
|
cache,
|
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
|
|
|
Enums as csEnums,
|
2023-03-22 17:44:52 +01:00
|
|
|
eventTarget,
|
2024-11-06 13:15:27 +01:00
|
|
|
geometryLoader,
|
|
|
|
|
getEnabledElementByViewportId,
|
|
|
|
|
imageLoader,
|
|
|
|
|
Types as csTypes,
|
2022-11-16 20:19:52 +01:00
|
|
|
utilities as csUtils,
|
2024-12-20 14:12:58 +01:00
|
|
|
metaData,
|
2022-11-16 20:19:52 +01:00
|
|
|
} from '@cornerstonejs/core';
|
2023-03-22 17:44:52 +01:00
|
|
|
import {
|
|
|
|
|
Enums as csToolsEnums,
|
|
|
|
|
segmentation as cstSegmentation,
|
|
|
|
|
Types as cstTypes,
|
|
|
|
|
} from '@cornerstonejs/tools';
|
2024-11-06 13:15:27 +01:00
|
|
|
import { PubSubService, Types as OHIFTypes } from '@ohif/core';
|
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 { easeInOutBell, reverseEaseInOutBell } from '../../utils/transitions';
|
|
|
|
|
import { mapROIContoursToRTStructData } from './RTSTRUCT/mapROIContoursToRTStructData';
|
2024-11-06 13:15:27 +01:00
|
|
|
import { SegmentationRepresentations } from '@cornerstonejs/tools/enums';
|
|
|
|
|
import { addColorLUT } from '@cornerstonejs/tools/segmentation/addColorLUT';
|
|
|
|
|
import { getNextColorLUTIndex } from '@cornerstonejs/tools/segmentation/getNextColorLUTIndex';
|
|
|
|
|
import { Segment } from '@cornerstonejs/tools/types/SegmentationStateTypes';
|
|
|
|
|
import { ContourStyle, LabelmapStyle, SurfaceStyle } from '@cornerstonejs/tools/types';
|
|
|
|
|
import { ViewportType } from '@cornerstonejs/core/enums';
|
|
|
|
|
import { SegmentationPresentation, SegmentationPresentationItem } from '../../types/Presentation';
|
|
|
|
|
import { updateLabelmapSegmentationImageReferences } from '@cornerstonejs/tools/segmentation/updateLabelmapSegmentationImageReferences';
|
|
|
|
|
import { triggerSegmentationRepresentationModified } from '@cornerstonejs/tools/segmentation/triggerSegmentationEvents';
|
|
|
|
|
import { convertStackToVolumeLabelmap } from '@cornerstonejs/tools/segmentation/helpers/convertStackToVolumeLabelmap';
|
|
|
|
|
import { getLabelmapImageIds } from '@cornerstonejs/tools/segmentation';
|
2022-11-16 20:19:52 +01:00
|
|
|
|
|
|
|
|
const LABELMAP = csToolsEnums.SegmentationRepresentations.Labelmap;
|
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
|
|
|
const CONTOUR = csToolsEnums.SegmentationRepresentations.Contour;
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
export type SegmentRepresentation = {
|
|
|
|
|
segmentIndex: number;
|
|
|
|
|
color: csTypes.Color;
|
|
|
|
|
opacity: number;
|
|
|
|
|
visible: boolean;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type SegmentationData = cstTypes.Segmentation;
|
|
|
|
|
|
|
|
|
|
export type SegmentationRepresentation = cstTypes.SegmentationRepresentation & {
|
|
|
|
|
viewportId: string;
|
|
|
|
|
id: string;
|
|
|
|
|
label: string;
|
|
|
|
|
styles: cstTypes.RepresentationStyle;
|
|
|
|
|
segments: {
|
|
|
|
|
[key: number]: SegmentRepresentation;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type SegmentationInfo = {
|
|
|
|
|
segmentation: SegmentationData;
|
|
|
|
|
representation?: SegmentationRepresentation;
|
|
|
|
|
};
|
|
|
|
|
|
2022-11-16 20:19:52 +01:00
|
|
|
const EVENTS = {
|
2024-11-06 13:15:27 +01:00
|
|
|
SEGMENTATION_MODIFIED: 'event::segmentation_modified',
|
|
|
|
|
// fired when the segmentation is added
|
2022-11-16 20:19:52 +01:00
|
|
|
SEGMENTATION_ADDED: 'event::segmentation_added',
|
2024-11-06 13:15:27 +01:00
|
|
|
//
|
|
|
|
|
SEGMENTATION_DATA_MODIFIED: 'event::segmentation_data_modified',
|
2022-11-16 20:19:52 +01:00
|
|
|
// fired when the segmentation is removed
|
|
|
|
|
SEGMENTATION_REMOVED: 'event::segmentation_removed',
|
2024-11-06 13:15:27 +01:00
|
|
|
//
|
|
|
|
|
// fired when segmentation representation is added
|
|
|
|
|
SEGMENTATION_REPRESENTATION_MODIFIED: 'event::segmentation_representation_modified',
|
|
|
|
|
// fired when segmentation representation is removed
|
|
|
|
|
SEGMENTATION_REPRESENTATION_REMOVED: 'event::segmentation_representation_removed',
|
|
|
|
|
//
|
|
|
|
|
// LOADING EVENTS
|
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
|
|
|
// fired when the active segment is loaded in SEG or RTSTRUCT
|
|
|
|
|
SEGMENT_LOADING_COMPLETE: 'event::segment_loading_complete',
|
2023-10-12 23:09:44 +02:00
|
|
|
// loading completed for all segments
|
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
|
|
|
SEGMENTATION_LOADING_COMPLETE: 'event::segmentation_loading_complete',
|
2022-11-16 20:19:52 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const VALUE_TYPES = {};
|
|
|
|
|
|
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
|
|
|
const VOLUME_LOADER_SCHEME = 'cornerstoneStreamingImageVolume';
|
|
|
|
|
|
2023-04-18 17:17:50 +02:00
|
|
|
class SegmentationService extends PubSubService {
|
|
|
|
|
static REGISTRATION = {
|
|
|
|
|
name: 'segmentationService',
|
|
|
|
|
altName: 'SegmentationService',
|
2024-11-06 13:15:27 +01:00
|
|
|
create: ({ servicesManager }: OHIFTypes.Extensions.ExtensionParams): SegmentationService => {
|
2023-04-18 17:17:50 +02:00
|
|
|
return new SegmentationService({ servicesManager });
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
private _segmentationIdToColorLUTIndexMap: Map<string, number>;
|
2024-05-08 18:12:49 +02:00
|
|
|
readonly servicesManager: AppTypes.ServicesManager;
|
2022-11-16 20:19:52 +01:00
|
|
|
highlightIntervalId = null;
|
|
|
|
|
readonly EVENTS = EVENTS;
|
|
|
|
|
|
|
|
|
|
constructor({ servicesManager }) {
|
2023-04-18 17:17:50 +02:00
|
|
|
super(EVENTS);
|
2024-11-06 13:15:27 +01:00
|
|
|
|
|
|
|
|
this._segmentationIdToColorLUTIndexMap = new Map();
|
2022-11-16 20:19:52 +01:00
|
|
|
|
|
|
|
|
this.servicesManager = servicesManager;
|
2024-11-11 20:28:34 +01:00
|
|
|
}
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-11 20:28:34 +01:00
|
|
|
public onModeEnter(): void {
|
2022-11-16 20:19:52 +01:00
|
|
|
this._initSegmentationService();
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-11 20:28:34 +01:00
|
|
|
public onModeExit(): void {
|
|
|
|
|
this.destroy();
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-16 20:19:52 +01:00
|
|
|
/**
|
2024-11-06 13:15:27 +01:00
|
|
|
* Retrieves a segmentation by its ID.
|
|
|
|
|
*
|
|
|
|
|
* @param segmentationId - The unique identifier of the segmentation to retrieve.
|
|
|
|
|
* @returns The segmentation object if found, or undefined if not found.
|
|
|
|
|
*
|
|
|
|
|
* @remarks
|
|
|
|
|
* This method directly accesses the cornerstone tools segmentation state to fetch
|
|
|
|
|
* the segmentation data. It's useful when you need to access specific properties
|
|
|
|
|
* or perform operations on a particular segmentation.
|
2022-11-16 20:19:52 +01:00
|
|
|
*/
|
2024-11-06 13:15:27 +01:00
|
|
|
public getSegmentation(segmentationId: string): cstTypes.Segmentation | undefined {
|
|
|
|
|
return cstSegmentation.state.getSegmentation(segmentationId);
|
2022-11-16 20:19:52 +01:00
|
|
|
}
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
/**
|
|
|
|
|
* Retrieves all segmentations from the cornerstone tools segmentation state.
|
|
|
|
|
*
|
|
|
|
|
* @returns An array of all segmentations currently stored in the state
|
|
|
|
|
*
|
|
|
|
|
* @remarks
|
|
|
|
|
* This is a convenience method that directly accesses the cornerstone tools
|
|
|
|
|
* segmentation state to get all available segmentations. It returns the raw
|
|
|
|
|
* segmentation objects without any additional processing or filtering.
|
|
|
|
|
*/
|
|
|
|
|
public getSegmentations(): cstTypes.Segmentation[] | [] {
|
|
|
|
|
return cstSegmentation.state.getSegmentations();
|
|
|
|
|
}
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
public getPresentation(viewportId: string): SegmentationPresentation {
|
|
|
|
|
const segmentationPresentations: SegmentationPresentation = [];
|
|
|
|
|
const segmentationsMap = new Map<string, SegmentationPresentationItem>();
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
const representations = this.getSegmentationRepresentations(viewportId);
|
|
|
|
|
for (const representation of representations) {
|
|
|
|
|
const { segmentationId } = representation;
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
if (!representation) {
|
|
|
|
|
continue;
|
2022-11-16 20:19:52 +01:00
|
|
|
}
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
const { type } = representation;
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
segmentationsMap.set(segmentationId, {
|
|
|
|
|
segmentationId,
|
|
|
|
|
type,
|
|
|
|
|
hydrated: true,
|
|
|
|
|
config: representation.config || {},
|
|
|
|
|
});
|
|
|
|
|
}
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
// Check inside the removedDisplaySetAndRepresentationMaps to see if any of the representations are not hydrated
|
|
|
|
|
// const hydrationMap = this._segmentationRepresentationHydrationMaps.get(presentationId);
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
// if (hydrationMap) {
|
|
|
|
|
// hydrationMap.forEach(rep => {
|
|
|
|
|
// segmentationsMap.set(rep.segmentationId, {
|
|
|
|
|
// segmentationId: rep.segmentationId,
|
|
|
|
|
// type: rep.type,
|
|
|
|
|
// hydrated: rep.hydrated,
|
|
|
|
|
// config: rep.config || {},
|
|
|
|
|
// });
|
|
|
|
|
// });
|
|
|
|
|
// }
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
// // Convert the Map to an array
|
|
|
|
|
segmentationPresentations.push(...segmentationsMap.values());
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
return segmentationPresentations;
|
2022-11-16 20:19:52 +01:00
|
|
|
}
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
public getRepresentationsForSegmentation(
|
|
|
|
|
segmentationId: string
|
|
|
|
|
): { viewportId: string; representations: any[] }[] {
|
|
|
|
|
const representations =
|
|
|
|
|
cstSegmentation.state.getSegmentationRepresentationsBySegmentationId(segmentationId);
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
return representations;
|
2022-11-16 20:19:52 +01:00
|
|
|
}
|
|
|
|
|
|
2023-09-22 16:23:44 +02:00
|
|
|
/**
|
2024-11-06 13:15:27 +01:00
|
|
|
* Retrieves segmentation representations (labelmap, contour, surface) based on specified criteria.
|
|
|
|
|
*
|
|
|
|
|
* @param viewportId - The ID of the viewport.
|
|
|
|
|
* @param specifier - An object containing optional `segmentationId` and `type` to filter the representations.
|
|
|
|
|
* @returns An array of `SegmentationRepresentation` matching the criteria, or an empty array if none are found.
|
|
|
|
|
*
|
|
|
|
|
* @remarks
|
|
|
|
|
* This method filters the segmentation representations according to the provided `specifier`:
|
|
|
|
|
* - **No `segmentationId` or `type` provided**: Returns all representations associated with the given `viewportId`.
|
|
|
|
|
* - **Only `segmentationId` provided**: Returns all representations with that `segmentationId`, regardless of `viewportId`.
|
|
|
|
|
* - **Only `type` provided**: Returns all representations of that `type` associated with the given `viewportId`.
|
|
|
|
|
* - **Both `segmentationId` and `type` provided**: Returns representations matching both criteria, regardless of `viewportId`.
|
2023-09-22 16:23:44 +02:00
|
|
|
*/
|
2024-11-06 13:15:27 +01:00
|
|
|
public getSegmentationRepresentations(
|
|
|
|
|
viewportId: string,
|
|
|
|
|
specifier: {
|
|
|
|
|
segmentationId?: string;
|
|
|
|
|
type?: SegmentationRepresentations;
|
|
|
|
|
} = {}
|
|
|
|
|
): SegmentationRepresentation[] {
|
|
|
|
|
// Get all representations for the viewportId
|
|
|
|
|
const representations = cstSegmentation.state.getSegmentationRepresentations(
|
|
|
|
|
viewportId,
|
|
|
|
|
specifier
|
2022-11-16 20:19:52 +01:00
|
|
|
);
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
// Map to our SegmentationRepresentation type
|
|
|
|
|
const ohifRepresentations = representations.map(repr =>
|
|
|
|
|
this._toOHIFSegmentationRepresentation(viewportId, repr)
|
2022-11-16 20:19:52 +01:00
|
|
|
);
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
return ohifRepresentations;
|
2022-11-16 20:19:52 +01:00
|
|
|
}
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
public destroy = () => {
|
|
|
|
|
eventTarget.removeEventListener(
|
|
|
|
|
csToolsEnums.Events.SEGMENTATION_MODIFIED,
|
|
|
|
|
this._onSegmentationModifiedFromSource
|
|
|
|
|
);
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
eventTarget.removeEventListener(
|
|
|
|
|
csToolsEnums.Events.SEGMENTATION_REMOVED,
|
|
|
|
|
this._onSegmentationModifiedFromSource
|
|
|
|
|
);
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
eventTarget.removeEventListener(
|
|
|
|
|
csToolsEnums.Events.SEGMENTATION_DATA_MODIFIED,
|
|
|
|
|
this._onSegmentationDataModifiedFromSource
|
|
|
|
|
);
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
eventTarget.removeEventListener(
|
|
|
|
|
csToolsEnums.Events.SEGMENTATION_REPRESENTATION_ADDED,
|
|
|
|
|
this._onSegmentationModifiedFromSource
|
|
|
|
|
);
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
eventTarget.removeEventListener(
|
|
|
|
|
csToolsEnums.Events.SEGMENTATION_ADDED,
|
|
|
|
|
this._onSegmentationAddedFromSource
|
2022-11-16 20:19:52 +01:00
|
|
|
);
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
this.listeners = {};
|
|
|
|
|
};
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
public async addSegmentationRepresentation(
|
|
|
|
|
viewportId: string,
|
|
|
|
|
{
|
|
|
|
|
segmentationId,
|
|
|
|
|
type,
|
|
|
|
|
suppressEvents = false,
|
|
|
|
|
}: {
|
|
|
|
|
segmentationId: string;
|
|
|
|
|
type?: csToolsEnums.SegmentationRepresentations;
|
|
|
|
|
suppressEvents?: boolean;
|
|
|
|
|
}
|
|
|
|
|
): Promise<void> {
|
|
|
|
|
const segmentation = this.getSegmentation(segmentationId);
|
|
|
|
|
const csViewport = this.getAndValidateViewport(viewportId);
|
|
|
|
|
const colorLUTIndex = this._segmentationIdToColorLUTIndexMap.get(segmentationId);
|
2023-10-10 19:21:17 +02:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
const defaultRepresentationType = csToolsEnums.SegmentationRepresentations.Labelmap;
|
|
|
|
|
let representationTypeToUse = type || defaultRepresentationType;
|
|
|
|
|
let isConverted = false;
|
2023-10-10 19:21:17 +02:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
if (type === csToolsEnums.SegmentationRepresentations.Labelmap) {
|
|
|
|
|
const { isVolumeViewport, isVolumeSegmentation } = this.determineViewportAndSegmentationType(
|
|
|
|
|
csViewport,
|
|
|
|
|
segmentation
|
|
|
|
|
);
|
2023-10-10 19:21:17 +02:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
({ representationTypeToUse, isConverted } = await this.handleViewportConversion(
|
|
|
|
|
isVolumeViewport,
|
|
|
|
|
isVolumeSegmentation,
|
|
|
|
|
csViewport,
|
|
|
|
|
segmentation,
|
|
|
|
|
viewportId,
|
|
|
|
|
segmentationId,
|
|
|
|
|
representationTypeToUse
|
|
|
|
|
));
|
2023-10-10 19:21:17 +02:00
|
|
|
}
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
await this._addSegmentationRepresentation(
|
|
|
|
|
viewportId,
|
|
|
|
|
segmentationId,
|
|
|
|
|
representationTypeToUse,
|
|
|
|
|
colorLUTIndex,
|
|
|
|
|
isConverted
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (!suppressEvents) {
|
|
|
|
|
this._broadcastEvent(this.EVENTS.SEGMENTATION_REPRESENTATION_MODIFIED, { segmentationId });
|
|
|
|
|
}
|
2023-10-10 19:21:17 +02:00
|
|
|
}
|
|
|
|
|
|
2022-11-16 20:19:52 +01:00
|
|
|
/**
|
2024-11-06 13:15:27 +01:00
|
|
|
* Creates an labelmap segmentation for a given display set
|
2022-11-16 20:19:52 +01:00
|
|
|
*
|
2024-11-06 13:15:27 +01:00
|
|
|
* @param displaySet - The display set to create the segmentation for.
|
|
|
|
|
* @param options - Optional parameters for creating the segmentation.
|
|
|
|
|
* @param options.segmentationId - Custom segmentation ID. If not provided, a UUID will be generated.
|
|
|
|
|
* @param options.FrameOfReferenceUID - Frame of reference UID for the segmentation.
|
|
|
|
|
* @param options.label - Label for the segmentation.
|
|
|
|
|
* @returns A promise that resolves to the created segmentation ID.
|
2022-11-16 20:19:52 +01:00
|
|
|
*/
|
2024-11-06 13:15:27 +01:00
|
|
|
public async createLabelmapForDisplaySet(
|
|
|
|
|
displaySet: AppTypes.DisplaySet,
|
|
|
|
|
options?: {
|
|
|
|
|
segmentationId?: string;
|
|
|
|
|
segments?: { [segmentIndex: number]: Partial<cstTypes.Segment> };
|
|
|
|
|
FrameOfReferenceUID?: string;
|
|
|
|
|
label?: string;
|
|
|
|
|
}
|
|
|
|
|
): Promise<string> {
|
|
|
|
|
// Todo: random does not makes sense, make this better, like
|
|
|
|
|
// labelmap 1, 2, 3 etc
|
|
|
|
|
const segmentationId = options?.segmentationId ?? `${csUtils.uuidv4()}`;
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
const isDynamicVolume = displaySet.isDynamicVolume;
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
let referenceImageIds = displaySet.imageIds;
|
|
|
|
|
if (isDynamicVolume) {
|
|
|
|
|
// get the middle timepoint for referenceImageIds
|
|
|
|
|
const timePoints = displaySet.dynamicVolumeInfo.timePoints;
|
|
|
|
|
const middleTimePoint = timePoints[Math.floor(timePoints.length / 2)];
|
|
|
|
|
referenceImageIds = middleTimePoint;
|
2022-11-16 20:19:52 +01:00
|
|
|
}
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
const derivedImages = await imageLoader.createAndCacheDerivedLabelmapImages(referenceImageIds);
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
const segs = this.getSegmentations();
|
|
|
|
|
const label = options.label || `Segmentation ${segs.length + 1}`;
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
const segImageIds = derivedImages.map(image => image.imageId);
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
const segmentationPublicInput: cstTypes.SegmentationPublicInput = {
|
2022-11-16 20:19:52 +01:00
|
|
|
segmentationId,
|
2024-11-06 13:15:27 +01:00
|
|
|
representation: {
|
|
|
|
|
type: LABELMAP,
|
|
|
|
|
data: {
|
|
|
|
|
imageIds: segImageIds,
|
|
|
|
|
referencedVolumeId: this._getVolumeIdForDisplaySet(displaySet),
|
|
|
|
|
referencedImageIds: referenceImageIds,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
config: {
|
|
|
|
|
label,
|
|
|
|
|
segments:
|
|
|
|
|
options.segments && Object.keys(options.segments).length > 0
|
|
|
|
|
? options.segments
|
|
|
|
|
: {
|
2024-12-20 14:12:58 +01:00
|
|
|
1: {
|
|
|
|
|
label: 'Segment 1',
|
|
|
|
|
active: true,
|
2024-11-06 13:15:27 +01:00
|
|
|
},
|
2024-12-20 14:12:58 +01:00
|
|
|
},
|
2024-11-06 13:15:27 +01:00
|
|
|
cachedStats: {
|
|
|
|
|
info: `S${displaySet.SeriesNumber}: ${displaySet.SeriesDescription}`,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
this.addOrUpdateSegmentation(segmentationPublicInput);
|
|
|
|
|
return segmentationId;
|
2022-11-16 20:19:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async createSegmentationForSEGDisplaySet(
|
|
|
|
|
segDisplaySet,
|
2024-11-06 13:15:27 +01:00
|
|
|
options: {
|
|
|
|
|
segmentationId?: string;
|
|
|
|
|
type: SegmentationRepresentations;
|
|
|
|
|
} = {
|
2024-12-20 14:12:58 +01:00
|
|
|
type: LABELMAP,
|
|
|
|
|
}
|
2022-11-16 20:19:52 +01:00
|
|
|
): Promise<string> {
|
2024-11-06 13:15:27 +01:00
|
|
|
const { type } = options;
|
|
|
|
|
let { segmentationId } = options;
|
|
|
|
|
const { labelmapBufferArray } = segDisplaySet;
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
if (type !== LABELMAP) {
|
|
|
|
|
throw new Error('Only labelmap type is supported for SEG display sets right now');
|
|
|
|
|
}
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
if (!labelmapBufferArray) {
|
|
|
|
|
throw new Error('SEG reading failed');
|
2022-11-16 20:19:52 +01:00
|
|
|
}
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
segmentationId = segmentationId ?? segDisplaySet.displaySetInstanceUID;
|
|
|
|
|
const referencedDisplaySetInstanceUID = segDisplaySet.referencedDisplaySetInstanceUID;
|
|
|
|
|
const referencedDisplaySet = this.servicesManager.services.displaySetService.getDisplaySetByUID(
|
|
|
|
|
referencedDisplaySetInstanceUID
|
|
|
|
|
);
|
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
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
const images = referencedDisplaySet.instances;
|
|
|
|
|
|
|
|
|
|
if (!images.length) {
|
|
|
|
|
throw new Error('No instances were provided for the referenced display set of the SEG');
|
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
|
|
|
}
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
const imageIds = images.map(image => image.imageId);
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
const derivedSegmentationImages = await imageLoader.createAndCacheDerivedLabelmapImages(
|
|
|
|
|
imageIds as string[]
|
|
|
|
|
);
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-12-20 14:12:58 +01:00
|
|
|
segDisplaySet.images = derivedSegmentationImages.map(image => ({
|
|
|
|
|
...image,
|
|
|
|
|
...metaData.get('instance', image.referencedImageId),
|
|
|
|
|
}));
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2023-08-08 20:39:31 +02:00
|
|
|
const segmentsInfo = segDisplaySet.segMetadata.data;
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
const segments: { [segmentIndex: string]: cstTypes.Segment } = {};
|
|
|
|
|
const colorLUT = [];
|
|
|
|
|
|
|
|
|
|
segmentsInfo.forEach((segmentInfo, index) => {
|
|
|
|
|
if (index === 0) {
|
|
|
|
|
colorLUT.push([0, 0, 0, 0]);
|
2023-08-08 20:39:31 +02:00
|
|
|
return;
|
2022-11-16 20:19:52 +01:00
|
|
|
}
|
|
|
|
|
|
2023-08-08 20:39:31 +02:00
|
|
|
const {
|
|
|
|
|
SegmentedPropertyCategoryCodeSequence,
|
|
|
|
|
SegmentNumber,
|
|
|
|
|
SegmentLabel,
|
|
|
|
|
SegmentAlgorithmType,
|
|
|
|
|
SegmentAlgorithmName,
|
|
|
|
|
SegmentedPropertyTypeCodeSequence,
|
|
|
|
|
rgba,
|
|
|
|
|
} = segmentInfo;
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
colorLUT.push(rgba);
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
const segmentIndex = Number(SegmentNumber);
|
|
|
|
|
|
2024-12-06 03:39:13 +01:00
|
|
|
const centroid = segDisplaySet.centroids?.get(index);
|
|
|
|
|
const imageCentroidXYZ = centroid?.image || { x: 0, y: 0, z: 0 };
|
|
|
|
|
const worldCentroidXYZ = centroid?.world || { x: 0, y: 0, z: 0 };
|
2024-11-06 13:15:27 +01:00
|
|
|
|
|
|
|
|
segments[segmentIndex] = {
|
|
|
|
|
segmentIndex,
|
2023-08-08 20:39:31 +02:00
|
|
|
label: SegmentLabel || `Segment ${SegmentNumber}`,
|
2024-11-06 13:15:27 +01:00
|
|
|
locked: false,
|
|
|
|
|
active: false,
|
|
|
|
|
cachedStats: {
|
|
|
|
|
center: {
|
|
|
|
|
image: [imageCentroidXYZ.x, imageCentroidXYZ.y, imageCentroidXYZ.z],
|
|
|
|
|
world: [worldCentroidXYZ.x, worldCentroidXYZ.y, worldCentroidXYZ.z],
|
|
|
|
|
},
|
|
|
|
|
modifiedTime: segDisplaySet.SeriesDate,
|
|
|
|
|
category: SegmentedPropertyCategoryCodeSequence
|
|
|
|
|
? SegmentedPropertyCategoryCodeSequence.CodeMeaning
|
|
|
|
|
: '',
|
|
|
|
|
type: SegmentedPropertyTypeCodeSequence
|
|
|
|
|
? SegmentedPropertyTypeCodeSequence.CodeMeaning
|
|
|
|
|
: '',
|
|
|
|
|
algorithmType: SegmentAlgorithmType,
|
|
|
|
|
algorithmName: SegmentAlgorithmName,
|
|
|
|
|
},
|
2022-11-16 20:19:52 +01:00
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
// get next color lut index
|
|
|
|
|
const colorLUTIndex = getNextColorLUTIndex();
|
|
|
|
|
addColorLUT(colorLUT, colorLUTIndex);
|
|
|
|
|
this._segmentationIdToColorLUTIndexMap.set(segmentationId, colorLUTIndex);
|
2023-08-08 20:39:31 +02:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
// now we need to chop the volume array into chunks and set the scalar data for each derived segmentation image
|
|
|
|
|
const volumeScalarData = new Uint8Array(labelmapBufferArray[0]);
|
|
|
|
|
|
|
|
|
|
// We should parse the segmentation as separate slices to support overlapping segments.
|
|
|
|
|
// This parsing should occur in the CornerstoneJS library adapters.
|
|
|
|
|
// For now, we use the volume returned from the library and chop it here.
|
2024-12-17 18:34:13 +01:00
|
|
|
let firstSegmentedSliceImageId = null;
|
2024-11-06 13:15:27 +01:00
|
|
|
for (let i = 0; i < derivedSegmentationImages.length; i++) {
|
|
|
|
|
const voxelManager = derivedSegmentationImages[i]
|
|
|
|
|
.voxelManager as csTypes.IVoxelManager<number>;
|
|
|
|
|
const scalarData = voxelManager.getScalarData();
|
2024-12-17 18:34:13 +01:00
|
|
|
const sliceData = volumeScalarData.slice(i * scalarData.length, (i + 1) * scalarData.length);
|
|
|
|
|
scalarData.set(sliceData);
|
2024-11-06 13:15:27 +01:00
|
|
|
voxelManager.setScalarData(scalarData);
|
2024-12-17 18:34:13 +01:00
|
|
|
|
|
|
|
|
// Check if this slice has any non-zero voxels and we haven't found one yet
|
|
|
|
|
if (!firstSegmentedSliceImageId && sliceData.some(value => value !== 0)) {
|
|
|
|
|
firstSegmentedSliceImageId = derivedSegmentationImages[i].referencedImageId;
|
|
|
|
|
}
|
2024-11-06 13:15:27 +01:00
|
|
|
}
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-12-17 18:34:13 +01:00
|
|
|
// assign the first non zero voxel image id to the segDisplaySet
|
|
|
|
|
segDisplaySet.firstSegmentedSliceImageId = firstSegmentedSliceImageId;
|
|
|
|
|
|
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
|
|
|
this._broadcastEvent(EVENTS.SEGMENTATION_LOADING_COMPLETE, {
|
2022-11-16 20:19:52 +01:00
|
|
|
segmentationId,
|
|
|
|
|
segDisplaySet,
|
|
|
|
|
});
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
const seg: cstTypes.SegmentationPublicInput = {
|
|
|
|
|
segmentationId,
|
|
|
|
|
representation: {
|
|
|
|
|
type: LABELMAP,
|
|
|
|
|
data: {
|
|
|
|
|
imageIds: derivedSegmentationImages.map(image => image.imageId),
|
|
|
|
|
referencedVolumeId: this._getVolumeIdForDisplaySet(referencedDisplaySet),
|
|
|
|
|
referencedImageIds: imageIds as string[],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
config: {
|
|
|
|
|
label: segDisplaySet.SeriesDescription,
|
|
|
|
|
segments,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
segDisplaySet.isLoaded = true;
|
|
|
|
|
|
|
|
|
|
this.addOrUpdateSegmentation(seg);
|
|
|
|
|
|
|
|
|
|
return segmentationId;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async createSegmentationForRTDisplaySet(
|
|
|
|
|
rtDisplaySet,
|
2024-11-06 13:15:27 +01:00
|
|
|
options: {
|
|
|
|
|
segmentationId?: string;
|
|
|
|
|
type: SegmentationRepresentations;
|
|
|
|
|
} = {
|
2024-12-20 14:12:58 +01:00
|
|
|
type: CONTOUR,
|
|
|
|
|
}
|
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
|
|
|
): Promise<string> {
|
2024-11-06 13:15:27 +01:00
|
|
|
const { type } = options;
|
|
|
|
|
let { segmentationId } = options;
|
|
|
|
|
|
|
|
|
|
// Currently, only contour representation is supported for RT display
|
|
|
|
|
if (type !== CONTOUR) {
|
|
|
|
|
throw new Error('Only contour type is supported for RT display sets right now');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Assign segmentationId if not provided
|
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
|
|
|
segmentationId = segmentationId ?? rtDisplaySet.displaySetInstanceUID;
|
|
|
|
|
const { structureSet } = rtDisplaySet;
|
|
|
|
|
|
|
|
|
|
if (!structureSet) {
|
|
|
|
|
throw new Error(
|
2024-11-06 13:15:27 +01:00
|
|
|
'To create the contours from RT displaySet, the displaySet should be loaded first. You can perform rtDisplaySet.load() before calling this method.'
|
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
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const rtDisplaySetUID = rtDisplaySet.displaySetInstanceUID;
|
2024-12-17 18:34:13 +01:00
|
|
|
const referencedDisplaySet = this.servicesManager.services.displaySetService.getDisplaySetByUID(
|
|
|
|
|
rtDisplaySet.referencedDisplaySetInstanceUID
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const referencedImageIdsWithGeometry = Array.from(structureSet.ReferencedSOPInstanceUIDsSet);
|
|
|
|
|
|
|
|
|
|
const referencedImageIds = referencedDisplaySet.instances.map(image => image.imageId);
|
|
|
|
|
// find the first image id that contains a referenced SOP instance UID
|
|
|
|
|
const firstSegmentedSliceImageId = referencedImageIds.find(imageId =>
|
|
|
|
|
referencedImageIdsWithGeometry.some(referencedId => imageId.includes(referencedId))
|
|
|
|
|
);
|
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
|
|
|
|
2024-12-17 18:34:13 +01:00
|
|
|
rtDisplaySet.firstSegmentedSliceImageId = firstSegmentedSliceImageId;
|
2024-11-06 13:15:27 +01:00
|
|
|
// Map ROI contours to RT Struct Data
|
2023-09-01 22:19:39 +02:00
|
|
|
const allRTStructData = mapROIContoursToRTStructData(structureSet, rtDisplaySetUID);
|
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
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
// Sort by segmentIndex for consistency
|
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
|
|
|
allRTStructData.sort((a, b) => a.segmentIndex - b.segmentIndex);
|
|
|
|
|
|
|
|
|
|
const geometryIds = allRTStructData.map(({ geometryId }) => geometryId);
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
// Initialize SegmentationPublicInput similar to SEG function
|
|
|
|
|
const segmentation: cstTypes.SegmentationPublicInput = {
|
|
|
|
|
segmentationId,
|
|
|
|
|
representation: {
|
|
|
|
|
type: CONTOUR,
|
|
|
|
|
data: {
|
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
|
|
|
geometryIds,
|
|
|
|
|
},
|
|
|
|
|
},
|
2024-11-06 13:15:27 +01:00
|
|
|
config: {
|
|
|
|
|
label: rtDisplaySet.SeriesDescription,
|
|
|
|
|
},
|
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
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (!structureSet.ROIContours?.length) {
|
|
|
|
|
throw new Error(
|
|
|
|
|
'The structureSet does not contain any ROIContours. Please ensure the structureSet is loaded first.'
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-11-06 13:15:27 +01:00
|
|
|
|
|
|
|
|
const segments: { [segmentIndex: string]: cstTypes.Segment } = {};
|
|
|
|
|
let segmentsCachedStats = {};
|
|
|
|
|
|
|
|
|
|
// Process each segment similarly to the SEG function
|
|
|
|
|
for (const rtStructData of allRTStructData) {
|
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
|
|
|
const { data, id, color, segmentIndex, geometryId } = rtStructData;
|
|
|
|
|
|
2023-06-19 15:01:23 +02:00
|
|
|
try {
|
2023-09-01 22:19:39 +02:00
|
|
|
const geometry = await geometryLoader.createAndCacheGeometry(geometryId, {
|
|
|
|
|
geometryData: {
|
|
|
|
|
data,
|
|
|
|
|
id,
|
|
|
|
|
color,
|
|
|
|
|
frameOfReferenceUID: structureSet.frameOfReferenceUID,
|
|
|
|
|
segmentIndex,
|
|
|
|
|
},
|
|
|
|
|
type: csEnums.GeometryType.CONTOUR,
|
|
|
|
|
});
|
2023-06-19 15:01:23 +02:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
const contourSet = geometry.data as csTypes.IContourSet;
|
|
|
|
|
const centroid = contourSet.centroid;
|
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
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
segmentsCachedStats = {
|
2023-06-19 15:01:23 +02:00
|
|
|
center: { world: centroid },
|
2024-11-06 13:15:27 +01:00
|
|
|
modifiedTime: rtDisplaySet.SeriesDate, // Using SeriesDate as modifiedTime
|
2023-06-19 15:01:23 +02:00
|
|
|
};
|
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
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
segments[segmentIndex] = {
|
2023-06-19 15:01:23 +02:00
|
|
|
label: id,
|
|
|
|
|
segmentIndex,
|
2024-11-06 13:15:27 +01:00
|
|
|
cachedStats: segmentsCachedStats,
|
|
|
|
|
locked: false,
|
|
|
|
|
active: false,
|
2023-06-19 15:01:23 +02:00
|
|
|
};
|
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
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
// Broadcast segment loading progress
|
2023-06-19 15:01:23 +02:00
|
|
|
const numInitialized = Object.keys(segmentsCachedStats).length;
|
2023-09-01 22:19:39 +02:00
|
|
|
const percentComplete = Math.round((numInitialized / allRTStructData.length) * 100);
|
2023-06-19 15:01:23 +02:00
|
|
|
this._broadcastEvent(EVENTS.SEGMENT_LOADING_COMPLETE, {
|
|
|
|
|
percentComplete,
|
|
|
|
|
numSegments: allRTStructData.length,
|
|
|
|
|
});
|
|
|
|
|
} catch (e) {
|
2024-11-06 13:15:27 +01:00
|
|
|
console.warn(`Error initializing contour for segment ${segmentIndex}:`, e);
|
|
|
|
|
continue; // Continue processing other segments even if one fails
|
2023-06-19 15:01:23 +02:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
// Assign processed segments to segmentation config
|
|
|
|
|
segmentation.config.segments = segments;
|
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
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
// Broadcast segmentation loading complete event
|
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
|
|
|
this._broadcastEvent(EVENTS.SEGMENTATION_LOADING_COMPLETE, {
|
|
|
|
|
segmentationId,
|
|
|
|
|
rtDisplaySet,
|
|
|
|
|
});
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
// Mark the RT display set as loaded
|
|
|
|
|
rtDisplaySet.isLoaded = true;
|
|
|
|
|
|
|
|
|
|
// Add or update the segmentation in the state
|
|
|
|
|
this.addOrUpdateSegmentation(segmentation);
|
|
|
|
|
|
|
|
|
|
return segmentationId;
|
2022-11-16 20:19:52 +01:00
|
|
|
}
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
/**
|
|
|
|
|
* Adds or updates a segmentation in the state
|
|
|
|
|
* @param segmentationId - The ID of the segmentation to add or update
|
|
|
|
|
* @param data - The data to add or update the segmentation with
|
|
|
|
|
*
|
|
|
|
|
* @remarks
|
|
|
|
|
* This method handles the addition or update of a segmentation in the state.
|
|
|
|
|
* If the segmentation already exists, it updates the existing segmentation.
|
|
|
|
|
* If the segmentation does not exist, it adds a new segmentation.
|
|
|
|
|
*/
|
|
|
|
|
public addOrUpdateSegmentation(
|
|
|
|
|
data: cstTypes.SegmentationPublicInput | Partial<cstTypes.Segmentation>
|
|
|
|
|
) {
|
|
|
|
|
const segmentationId = data.segmentationId;
|
|
|
|
|
const existingSegmentation = cstSegmentation.state.getSegmentation(segmentationId);
|
2023-09-22 16:23:44 +02:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
if (existingSegmentation) {
|
|
|
|
|
// Update the existing segmentation
|
|
|
|
|
this.updateSegmentationInSource(segmentationId, data as Partial<cstTypes.Segmentation>);
|
|
|
|
|
} else {
|
|
|
|
|
// Add a new segmentation
|
|
|
|
|
this.addSegmentationToSource(data as cstTypes.SegmentationPublicInput);
|
2023-09-22 16:23:44 +02:00
|
|
|
}
|
2024-11-06 13:15:27 +01:00
|
|
|
}
|
2023-09-22 16:23:44 +02:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
public setActiveSegmentation(viewportId: string, segmentationId: string): void {
|
|
|
|
|
cstSegmentation.activeSegmentation.setActiveSegmentation(viewportId, segmentationId);
|
|
|
|
|
}
|
2023-09-22 16:23:44 +02:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
/**
|
|
|
|
|
* Gets the active segmentation for a viewport
|
|
|
|
|
* @param viewportId - The ID of the viewport to get the active segmentation for
|
|
|
|
|
* @returns The active segmentation object, or null if no segmentation is active
|
|
|
|
|
*
|
|
|
|
|
* @remarks
|
|
|
|
|
* This method retrieves the currently active segmentation for the specified viewport.
|
|
|
|
|
* The active segmentation is the one that is currently selected for editing operations.
|
|
|
|
|
* Returns null if no segmentation is active in the viewport.
|
|
|
|
|
*/
|
|
|
|
|
public getActiveSegmentation(viewportId: string): cstTypes.Segmentation | null {
|
|
|
|
|
return cstSegmentation.activeSegmentation.getActiveSegmentation(viewportId);
|
|
|
|
|
}
|
2023-09-22 16:23:44 +02:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
/**
|
|
|
|
|
* Gets the active segment from the active segmentation in a viewport
|
|
|
|
|
* @param viewportId - The ID of the viewport to get the active segment from
|
|
|
|
|
* @returns The active segment object, or undefined if no segment is active
|
|
|
|
|
*
|
|
|
|
|
* @remarks
|
|
|
|
|
* This method retrieves the currently active segment from the active segmentation
|
|
|
|
|
* in the specified viewport. The active segment is the one that is currently
|
|
|
|
|
* selected for editing operations. Returns undefined if no segment is active or
|
|
|
|
|
* if there is no active segmentation.
|
|
|
|
|
*/
|
|
|
|
|
public getActiveSegment(viewportId: string): cstTypes.Segment | undefined {
|
|
|
|
|
const activeSegmentation = this.getActiveSegmentation(viewportId);
|
2023-09-22 16:23:44 +02:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
if (!activeSegmentation) {
|
|
|
|
|
return;
|
2023-09-22 16:23:44 +02:00
|
|
|
}
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
const { segments } = activeSegmentation;
|
2023-09-22 16:23:44 +02:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
let activeSegment;
|
|
|
|
|
for (const segment of Object.values(segments)) {
|
|
|
|
|
if (segment.active) {
|
|
|
|
|
activeSegment = segment;
|
|
|
|
|
break;
|
2023-09-22 16:23:44 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
return activeSegment;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public hasCustomStyles(specifier: {
|
|
|
|
|
viewportId: string;
|
|
|
|
|
segmentationId: string;
|
|
|
|
|
type: SegmentationRepresentations;
|
|
|
|
|
}): boolean {
|
|
|
|
|
return cstSegmentation.config.style.hasCustomStyle(specifier);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public getStyle = (specifier: {
|
|
|
|
|
viewportId: string;
|
|
|
|
|
segmentationId: string;
|
|
|
|
|
type: SegmentationRepresentations;
|
|
|
|
|
segmentIndex?: number;
|
|
|
|
|
}) => {
|
|
|
|
|
const style = cstSegmentation.config.style.getStyle(specifier);
|
|
|
|
|
|
|
|
|
|
return style;
|
2023-09-22 16:23:44 +02:00
|
|
|
};
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
public setStyle = (
|
|
|
|
|
specifier: {
|
|
|
|
|
type: SegmentationRepresentations;
|
|
|
|
|
viewportId?: string;
|
|
|
|
|
segmentationId?: string;
|
|
|
|
|
segmentIndex?: number;
|
|
|
|
|
},
|
|
|
|
|
style: LabelmapStyle | ContourStyle | SurfaceStyle
|
|
|
|
|
) => {
|
|
|
|
|
cstSegmentation.config.style.setStyle(specifier, style);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public resetToGlobalStyle = () => {
|
|
|
|
|
cstSegmentation.config.style.resetToGlobalStyle();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds a new segment to the specified segmentation.
|
|
|
|
|
* @param segmentationId - The ID of the segmentation to add the segment to.
|
|
|
|
|
* @param viewportId: The ID of the viewport to add the segment to, it is used to get the representation, if it is not
|
|
|
|
|
* provided, the first available representation for the segmentationId will be used.
|
|
|
|
|
* @param config - An object containing the configuration options for the new segment.
|
|
|
|
|
* - segmentIndex: (optional) The index of the segment to add. If not provided, the next available index will be used.
|
|
|
|
|
* - properties: (optional) An object containing the properties of the new segment.
|
|
|
|
|
* - label: (optional) The label of the new segment. If not provided, a default label will be used.
|
|
|
|
|
* - color: (optional) The color of the new segment in RGB format. If not provided, a default color will be used.
|
|
|
|
|
* - visibility: (optional) Whether the new segment should be visible. If not provided, the segment will be visible by default.
|
|
|
|
|
* - isLocked: (optional) Whether the new segment should be locked for editing. If not provided, the segment will not be locked by default.
|
|
|
|
|
* - active: (optional) Whether the new segment should be the active segment to be edited. If not provided, the segment will not be active by default.
|
|
|
|
|
*/
|
|
|
|
|
public addSegment(
|
2022-11-16 20:19:52 +01:00
|
|
|
segmentationId: string,
|
2024-11-06 13:15:27 +01:00
|
|
|
config: {
|
|
|
|
|
segmentIndex?: number;
|
|
|
|
|
label?: string;
|
|
|
|
|
isLocked?: boolean;
|
|
|
|
|
active?: boolean;
|
|
|
|
|
color?: csTypes.Color; // Add color type
|
|
|
|
|
visibility?: boolean; // Add visibility option
|
|
|
|
|
} = {}
|
2022-11-16 20:19:52 +01:00
|
|
|
): void {
|
2024-11-06 13:15:27 +01:00
|
|
|
if (config?.segmentIndex === 0) {
|
|
|
|
|
throw new Error('Segment index 0 is reserved for "no label"');
|
|
|
|
|
}
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
const csSegmentation = this.getCornerstoneSegmentation(segmentationId);
|
|
|
|
|
|
|
|
|
|
let segmentIndex = config.segmentIndex;
|
|
|
|
|
if (!segmentIndex) {
|
|
|
|
|
// grab the next available segment index based on the object keys,
|
|
|
|
|
// so basically get the highest segment index value + 1
|
|
|
|
|
segmentIndex = Math.max(...Object.keys(csSegmentation.segments).map(Number)) + 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// update the segmentation
|
|
|
|
|
if (!config.label) {
|
|
|
|
|
config.label = `Segment ${segmentIndex}`;
|
2023-09-22 16:23:44 +02:00
|
|
|
}
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
const currentSegments = csSegmentation.segments;
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
cstSegmentation.updateSegmentations([
|
|
|
|
|
{
|
|
|
|
|
segmentationId,
|
|
|
|
|
payload: {
|
|
|
|
|
segments: {
|
|
|
|
|
...currentSegments,
|
|
|
|
|
[segmentIndex]: {
|
|
|
|
|
...currentSegments[segmentIndex],
|
|
|
|
|
segmentIndex,
|
|
|
|
|
cachedStats: {},
|
|
|
|
|
locked: false,
|
|
|
|
|
...config,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
]);
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
this.setActiveSegment(segmentationId, segmentIndex);
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
// Apply additional configurations
|
|
|
|
|
if (config.isLocked !== undefined) {
|
|
|
|
|
this._setSegmentLockedStatus(segmentationId, segmentIndex, config.isLocked);
|
2022-11-16 20:19:52 +01:00
|
|
|
}
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
// Get all viewports that have this segmentation
|
|
|
|
|
const viewportIds = this.getViewportIdsWithSegmentation(segmentationId);
|
|
|
|
|
|
|
|
|
|
viewportIds.forEach(viewportId => {
|
|
|
|
|
// Set color if provided
|
|
|
|
|
if (config.color !== undefined) {
|
|
|
|
|
this.setSegmentColor(viewportId, segmentationId, segmentIndex, config.color);
|
2022-11-16 20:19:52 +01:00
|
|
|
}
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
// Set visibility if provided
|
|
|
|
|
if (config.visibility !== undefined) {
|
|
|
|
|
this.setSegmentVisibility(viewportId, segmentationId, segmentIndex, config.visibility);
|
2022-11-16 20:19:52 +01:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
/**
|
|
|
|
|
* Removes a segment from a segmentation and updates the active segment index if necessary.
|
|
|
|
|
*
|
|
|
|
|
* @param segmentationId - The ID of the segmentation containing the segment to remove.
|
|
|
|
|
* @param segmentIndex - The index of the segment to remove.
|
|
|
|
|
*
|
|
|
|
|
* @remarks
|
|
|
|
|
* This method performs the following actions:
|
|
|
|
|
* 1. Clears the segment value in the Cornerstone segmentation.
|
|
|
|
|
* 2. Updates all related segmentation representations to remove the segment.
|
|
|
|
|
* 3. If the removed segment was the active segment, it updates the active segment index.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public removeSegment(segmentationId: string, segmentIndex: number): void {
|
|
|
|
|
cstSegmentation.removeSegment(segmentationId, segmentIndex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public setSegmentVisibility(
|
|
|
|
|
viewportId: string,
|
2022-11-16 20:19:52 +01:00
|
|
|
segmentationId: string,
|
|
|
|
|
segmentIndex: number,
|
2024-11-06 13:15:27 +01:00
|
|
|
isVisible: boolean,
|
|
|
|
|
type?: SegmentationRepresentations
|
2022-11-16 20:19:52 +01:00
|
|
|
): void {
|
2024-11-06 13:15:27 +01:00
|
|
|
this._setSegmentVisibility(viewportId, segmentationId, segmentIndex, isVisible, type);
|
|
|
|
|
}
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
/**
|
|
|
|
|
* Sets the locked status of a segment in a segmentation.
|
|
|
|
|
*
|
|
|
|
|
* @param segmentationId - The ID of the segmentation containing the segment.
|
|
|
|
|
* @param segmentIndex - The index of the segment to set the locked status for.
|
|
|
|
|
* @param isLocked - The new locked status of the segment.
|
|
|
|
|
*
|
|
|
|
|
* @remarks
|
|
|
|
|
* This method updates the locked status of a specific segment within a segmentation.
|
|
|
|
|
* A locked segment cannot be modified or edited.
|
|
|
|
|
*/
|
|
|
|
|
public setSegmentLocked(segmentationId: string, segmentIndex: number, isLocked: boolean): void {
|
|
|
|
|
this._setSegmentLockedStatus(segmentationId, segmentIndex, isLocked);
|
|
|
|
|
}
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
/**
|
|
|
|
|
* Toggles the locked state of a segment in a segmentation.
|
|
|
|
|
* @param segmentationId - The ID of the segmentation.
|
|
|
|
|
* @param segmentIndex - The index of the segment to toggle.
|
|
|
|
|
*/
|
|
|
|
|
public toggleSegmentLocked(segmentationId: string, segmentIndex: number): void {
|
|
|
|
|
const isLocked = cstSegmentation.segmentLocking.isSegmentIndexLocked(
|
2022-11-16 20:19:52 +01:00
|
|
|
segmentationId,
|
2024-11-06 13:15:27 +01:00
|
|
|
segmentIndex
|
2022-11-16 20:19:52 +01:00
|
|
|
);
|
2024-11-06 13:15:27 +01:00
|
|
|
this._setSegmentLockedStatus(segmentationId, segmentIndex, !isLocked);
|
|
|
|
|
}
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
public toggleSegmentVisibility(
|
|
|
|
|
viewportId: string,
|
|
|
|
|
segmentationId: string,
|
|
|
|
|
segmentIndex: number,
|
|
|
|
|
type: SegmentationRepresentations
|
|
|
|
|
): void {
|
|
|
|
|
const isVisible = cstSegmentation.config.visibility.getSegmentIndexVisibility(
|
|
|
|
|
viewportId,
|
|
|
|
|
{
|
|
|
|
|
segmentationId,
|
|
|
|
|
type,
|
|
|
|
|
},
|
|
|
|
|
segmentIndex
|
|
|
|
|
);
|
|
|
|
|
this._setSegmentVisibility(viewportId, segmentationId, segmentIndex, !isVisible, type);
|
|
|
|
|
}
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
/**
|
|
|
|
|
* Sets the color of a specific segment in a segmentation.
|
|
|
|
|
*
|
|
|
|
|
* @param viewportId - The ID of the viewport containing the segmentation
|
|
|
|
|
* @param segmentationId - The ID of the segmentation containing the segment
|
|
|
|
|
* @param segmentIndex - The index of the segment to set the color for
|
|
|
|
|
* @param color - The new color to apply to the segment as an array of RGBA values
|
|
|
|
|
*
|
|
|
|
|
* @remarks
|
|
|
|
|
* This method updates the color of a specific segment within a segmentation.
|
|
|
|
|
* The color parameter should be an array of 4 numbers representing RGBA values.
|
|
|
|
|
*/
|
|
|
|
|
public setSegmentColor(
|
|
|
|
|
viewportId: string,
|
|
|
|
|
segmentationId: string,
|
|
|
|
|
segmentIndex: number,
|
|
|
|
|
color: csTypes.Color
|
|
|
|
|
): void {
|
|
|
|
|
cstSegmentation.config.color.setSegmentIndexColor(
|
|
|
|
|
viewportId,
|
|
|
|
|
segmentationId,
|
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
|
|
|
segmentIndex,
|
2024-11-06 13:15:27 +01:00
|
|
|
color
|
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
|
|
|
);
|
2022-11-16 20:19:52 +01:00
|
|
|
}
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
/**
|
|
|
|
|
* Gets the current color of a specific segment in a segmentation.
|
|
|
|
|
*
|
|
|
|
|
* @param viewportId - The ID of the viewport containing the segmentation
|
|
|
|
|
* @param segmentationId - The ID of the segmentation containing the segment
|
|
|
|
|
* @param segmentIndex - The index of the segment to get the color for
|
|
|
|
|
* @returns An array of 4 numbers representing the RGBA color values of the segment
|
|
|
|
|
*
|
|
|
|
|
* @remarks
|
|
|
|
|
* This method retrieves the current color of a specific segment within a segmentation.
|
|
|
|
|
* The returned color is an array of 4 numbers representing RGBA values.
|
|
|
|
|
*/
|
|
|
|
|
public getSegmentColor(viewportId: string, segmentationId: string, segmentIndex: number) {
|
|
|
|
|
return cstSegmentation.config.color.getSegmentIndexColor(
|
|
|
|
|
viewportId,
|
|
|
|
|
segmentationId,
|
|
|
|
|
segmentIndex
|
|
|
|
|
);
|
|
|
|
|
}
|
2023-05-12 21:04:19 +02:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
/**
|
|
|
|
|
* Gets the labelmap volume for a segmentation
|
|
|
|
|
* @param segmentationId - The ID of the segmentation to get the labelmap volume for
|
|
|
|
|
* @returns The labelmap volume for the segmentation, or null if not found
|
|
|
|
|
*
|
|
|
|
|
* @remarks
|
|
|
|
|
* This method retrieves the labelmap volume data for a specific segmentation.
|
|
|
|
|
* The labelmap volume contains the actual segmentation data in the form of a 3D volume.
|
|
|
|
|
* Returns null if the segmentation does not have valid labelmap volume data.
|
|
|
|
|
*/
|
|
|
|
|
public getLabelmapVolume(segmentationId: string) {
|
|
|
|
|
const csSegmentation = cstSegmentation.state.getSegmentation(segmentationId);
|
|
|
|
|
const labelmapData = csSegmentation.representationData[
|
|
|
|
|
SegmentationRepresentations.Labelmap
|
|
|
|
|
] as cstTypes.LabelmapToolOperationDataVolume;
|
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
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
if (!labelmapData || !labelmapData.volumeId) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
const { volumeId } = labelmapData;
|
|
|
|
|
const labelmapVolume = cache.getVolume(volumeId);
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
return labelmapVolume;
|
|
|
|
|
}
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
/**
|
|
|
|
|
* Sets the label for a specific segment in a segmentation
|
|
|
|
|
* @param segmentationId - The ID of the segmentation containing the segment
|
|
|
|
|
* @param segmentIndex - The index of the segment to set the label for
|
|
|
|
|
* @param label - The new label to apply to the segment
|
|
|
|
|
*
|
|
|
|
|
* @remarks
|
|
|
|
|
* This method updates the text label of a specific segment within a segmentation.
|
|
|
|
|
* The label is used to identify and describe the segment in the UI.
|
|
|
|
|
*/
|
|
|
|
|
public setSegmentLabel(segmentationId: string, segmentIndex: number, label: string) {
|
|
|
|
|
this._setSegmentLabel(segmentationId, segmentIndex, label);
|
|
|
|
|
}
|
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
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
/**
|
|
|
|
|
* Sets the active segment for a segmentation
|
|
|
|
|
* @param segmentationId - The ID of the segmentation containing the segment
|
|
|
|
|
* @param segmentIndex - The index of the segment to set as active
|
|
|
|
|
*
|
|
|
|
|
* @remarks
|
|
|
|
|
* This method updates which segment is considered "active" within a segmentation.
|
|
|
|
|
* The active segment is typically highlighted and available for editing operations.
|
|
|
|
|
*/
|
|
|
|
|
public setActiveSegment(segmentationId: string, segmentIndex: number): void {
|
|
|
|
|
this._setActiveSegment(segmentationId, segmentIndex);
|
|
|
|
|
}
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
/**
|
|
|
|
|
* Controls whether inactive segmentations should be rendered in a viewport
|
|
|
|
|
* @param viewportId - The ID of the viewport to update
|
|
|
|
|
* @param renderInactive - Whether inactive segmentations should be rendered
|
|
|
|
|
*
|
|
|
|
|
* @remarks
|
|
|
|
|
* This method configures if segmentations that are not currently active
|
|
|
|
|
* should still be visible in the specified viewport. This can be useful
|
|
|
|
|
* for comparing or viewing multiple segmentations simultaneously.
|
|
|
|
|
*/
|
|
|
|
|
public setRenderInactiveSegmentations(viewportId: string, renderInactive: boolean): void {
|
|
|
|
|
cstSegmentation.config.style.setRenderInactiveSegmentations(viewportId, renderInactive);
|
|
|
|
|
}
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
/**
|
|
|
|
|
* Gets whether inactive segmentations are being rendered for a viewport
|
|
|
|
|
* @param viewportId - The ID of the viewport to check
|
|
|
|
|
* @returns boolean indicating if inactive segmentations are rendered
|
|
|
|
|
*
|
|
|
|
|
* @remarks
|
|
|
|
|
* This method retrieves the current rendering state for inactive segmentations
|
|
|
|
|
* in the specified viewport. Returns true if inactive segmentations are visible.
|
|
|
|
|
*/
|
|
|
|
|
public getRenderInactiveSegmentations(viewportId: string): boolean {
|
|
|
|
|
return cstSegmentation.config.style.getRenderInactiveSegmentations(viewportId);
|
|
|
|
|
}
|
2022-11-16 20:19:52 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Toggles the visibility of a segmentation in the state, and broadcasts the event.
|
|
|
|
|
* Note: this method does not update the segmentation state in the source. It only
|
|
|
|
|
* updates the state, and there should be separate listeners for that.
|
|
|
|
|
* @param ids segmentation ids
|
|
|
|
|
*/
|
2024-11-06 13:15:27 +01:00
|
|
|
public toggleSegmentationRepresentationVisibility = (
|
|
|
|
|
viewportId: string,
|
|
|
|
|
{ segmentationId, type }: { segmentationId: string; type: SegmentationRepresentations }
|
|
|
|
|
): void => {
|
|
|
|
|
this._toggleSegmentationRepresentationVisibility(viewportId, segmentationId, type);
|
2022-11-16 20:19:52 +01:00
|
|
|
};
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
public getViewportIdsWithSegmentation = (segmentationId: string): string[] => {
|
|
|
|
|
const viewportIds = cstSegmentation.state.getViewportIdsWithSegmentation(segmentationId);
|
|
|
|
|
return viewportIds;
|
|
|
|
|
};
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
/**
|
|
|
|
|
* Clears segmentation representations from the viewport.
|
|
|
|
|
* Unlike removeSegmentationRepresentations, this doesn't update
|
|
|
|
|
* removed display set and representation maps.
|
|
|
|
|
* We track removed segmentations manually to avoid re-adding them
|
|
|
|
|
* when the display set is added again.
|
|
|
|
|
* @param viewportId - The viewport ID to clear segmentation representations from.
|
|
|
|
|
*/
|
|
|
|
|
public clearSegmentationRepresentations(viewportId: string): void {
|
|
|
|
|
this.removeSegmentationRepresentations(viewportId);
|
|
|
|
|
}
|
2024-05-21 22:43:47 +02:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
/**
|
|
|
|
|
* Completely removes a segmentation from the state
|
|
|
|
|
* @param segmentationId - The ID of the segmentation to remove.
|
|
|
|
|
*/
|
|
|
|
|
public remove(segmentationId: string): void {
|
|
|
|
|
cstSegmentation.state.removeSegmentation(segmentationId);
|
|
|
|
|
}
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
public removeAllSegmentations(): void {
|
|
|
|
|
cstSegmentation.state.removeAllSegmentations();
|
|
|
|
|
}
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
/**
|
|
|
|
|
* It removes the segmentation representations from the viewport.
|
|
|
|
|
* @param viewportId - The viewport id to remove the segmentation representations from.
|
|
|
|
|
* @param specifier - The specifier to remove the segmentation representations.
|
|
|
|
|
*
|
|
|
|
|
* @remarks
|
|
|
|
|
* If no specifier is provided, all segmentation representations for the viewport are removed.
|
|
|
|
|
* If a segmentationId specifier is provided, only the segmentation representation with the specified segmentationId and type are removed.
|
|
|
|
|
* If a type specifier is provided, only the segmentation representation with the specified type are removed.
|
|
|
|
|
* If both a segmentationId and type specifier are provided, only the segmentation representation with the specified segmentationId and type are removed.
|
|
|
|
|
*/
|
|
|
|
|
public removeSegmentationRepresentations(
|
|
|
|
|
viewportId: string,
|
|
|
|
|
specifier: {
|
|
|
|
|
segmentationId?: string;
|
|
|
|
|
type?: SegmentationRepresentations;
|
|
|
|
|
} = {}
|
|
|
|
|
): void {
|
|
|
|
|
cstSegmentation.removeSegmentationRepresentations(viewportId, specifier);
|
|
|
|
|
}
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
public jumpToSegmentCenter(
|
|
|
|
|
segmentationId: string,
|
|
|
|
|
segmentIndex: number,
|
|
|
|
|
viewportId?: string,
|
|
|
|
|
highlightAlpha = 0.9,
|
|
|
|
|
highlightSegment = true,
|
|
|
|
|
animationLength = 750,
|
|
|
|
|
highlightHideOthers = false,
|
|
|
|
|
highlightFunctionType = 'ease-in-out' // todo: make animation functions configurable from outside
|
|
|
|
|
): void {
|
|
|
|
|
const center = this._getSegmentCenter(segmentationId, segmentIndex);
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
if (!center) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
const { world } = center as { world: csTypes.Point3 };
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
// need to find which viewports are displaying the segmentation
|
|
|
|
|
const viewportIds = viewportId
|
|
|
|
|
? [viewportId]
|
|
|
|
|
: this.getViewportIdsWithSegmentation(segmentationId);
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
viewportIds.forEach(viewportId => {
|
|
|
|
|
const { viewport } = getEnabledElementByViewportId(viewportId);
|
|
|
|
|
viewport.jumpToWorld(world);
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
highlightSegment &&
|
|
|
|
|
this.highlightSegment(
|
2022-11-16 20:19:52 +01:00
|
|
|
segmentationId,
|
|
|
|
|
segmentIndex,
|
2024-11-06 13:15:27 +01:00
|
|
|
viewportId,
|
|
|
|
|
highlightAlpha,
|
|
|
|
|
animationLength,
|
|
|
|
|
highlightHideOthers
|
2022-11-16 20:19:52 +01:00
|
|
|
);
|
2024-11-06 13:15:27 +01:00
|
|
|
});
|
|
|
|
|
}
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
public highlightSegment(
|
|
|
|
|
segmentationId: string,
|
|
|
|
|
segmentIndex: number,
|
|
|
|
|
viewportId?: string,
|
|
|
|
|
alpha = 0.9,
|
|
|
|
|
animationLength = 750,
|
|
|
|
|
hideOthers = true,
|
|
|
|
|
highlightFunctionType = 'ease-in-out'
|
|
|
|
|
): void {
|
|
|
|
|
if (this.highlightIntervalId) {
|
|
|
|
|
clearInterval(this.highlightIntervalId);
|
2022-11-16 20:19:52 +01:00
|
|
|
}
|
2023-09-22 16:23:44 +02:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
const csSegmentation = this.getCornerstoneSegmentation(segmentationId);
|
|
|
|
|
|
|
|
|
|
const viewportIds = viewportId
|
|
|
|
|
? [viewportId]
|
|
|
|
|
: this.getViewportIdsWithSegmentation(segmentationId);
|
|
|
|
|
|
|
|
|
|
viewportIds.forEach(viewportId => {
|
|
|
|
|
const segmentationRepresentation = this.getSegmentationRepresentations(viewportId, {
|
|
|
|
|
segmentationId,
|
2023-09-22 16:23:44 +02:00
|
|
|
});
|
2024-11-06 13:15:27 +01:00
|
|
|
|
|
|
|
|
const representation = segmentationRepresentation[0];
|
|
|
|
|
const { type } = representation;
|
|
|
|
|
const segments = csSegmentation.segments;
|
|
|
|
|
|
|
|
|
|
const highlightFn =
|
|
|
|
|
type === LABELMAP ? this._highlightLabelmap.bind(this) : this._highlightContour.bind(this);
|
|
|
|
|
|
|
|
|
|
const adjustedAlpha = type === LABELMAP ? alpha : 1 - alpha;
|
|
|
|
|
|
|
|
|
|
highlightFn(
|
|
|
|
|
segmentIndex,
|
|
|
|
|
adjustedAlpha,
|
|
|
|
|
hideOthers,
|
|
|
|
|
segments,
|
|
|
|
|
viewportId,
|
|
|
|
|
animationLength,
|
|
|
|
|
representation
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private getAndValidateViewport(viewportId: string) {
|
|
|
|
|
const csViewport =
|
|
|
|
|
this.servicesManager.services.cornerstoneViewportService.getCornerstoneViewport(viewportId);
|
|
|
|
|
if (!csViewport) {
|
|
|
|
|
throw new Error(`Viewport with id ${viewportId} not found.`);
|
2023-09-22 16:23:44 +02:00
|
|
|
}
|
2024-11-06 13:15:27 +01:00
|
|
|
return csViewport;
|
|
|
|
|
}
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
/**
|
|
|
|
|
* Sets the visibility of a segmentation representation.
|
|
|
|
|
*
|
|
|
|
|
* @param viewportId - The ID of the viewport.
|
|
|
|
|
* @param segmentationId - The ID of the segmentation.
|
|
|
|
|
* @param isVisible - The new visibility state.
|
|
|
|
|
*/
|
|
|
|
|
private _setSegmentationRepresentationVisibility(
|
|
|
|
|
viewportId: string,
|
2022-11-16 20:19:52 +01:00
|
|
|
segmentationId: string,
|
2024-11-06 13:15:27 +01:00
|
|
|
type: SegmentationRepresentations,
|
|
|
|
|
isVisible: boolean
|
|
|
|
|
): void {
|
|
|
|
|
const representations = this.getSegmentationRepresentations(viewportId, {
|
|
|
|
|
segmentationId,
|
|
|
|
|
type,
|
|
|
|
|
});
|
|
|
|
|
const representation = representations[0];
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
if (!representation) {
|
|
|
|
|
console.debug(
|
|
|
|
|
'No segmentation representation found for the given viewportId and segmentationId'
|
|
|
|
|
);
|
|
|
|
|
return;
|
2022-11-16 20:19:52 +01:00
|
|
|
}
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
cstSegmentation.config.visibility.setSegmentationRepresentationVisibility(
|
|
|
|
|
viewportId,
|
|
|
|
|
{
|
|
|
|
|
segmentationId,
|
|
|
|
|
type,
|
|
|
|
|
},
|
|
|
|
|
isVisible
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private determineViewportAndSegmentationType(csViewport, segmentation) {
|
|
|
|
|
const isVolumeViewport =
|
|
|
|
|
csViewport.type === ViewportType.ORTHOGRAPHIC || csViewport.type === ViewportType.VOLUME_3D;
|
|
|
|
|
const isVolumeSegmentation = 'volumeId' in segmentation.representationData[LABELMAP];
|
|
|
|
|
return { isVolumeViewport, isVolumeSegmentation };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async handleViewportConversion(
|
|
|
|
|
isVolumeViewport: boolean,
|
|
|
|
|
isVolumeSegmentation: boolean,
|
|
|
|
|
csViewport: csTypes.IViewport,
|
|
|
|
|
segmentation: cstTypes.Segmentation,
|
|
|
|
|
viewportId: string,
|
|
|
|
|
segmentationId: string,
|
|
|
|
|
representationType: csToolsEnums.SegmentationRepresentations
|
|
|
|
|
) {
|
|
|
|
|
let representationTypeToUse = representationType;
|
|
|
|
|
let isConverted = false;
|
|
|
|
|
|
|
|
|
|
const handler = isVolumeViewport ? this.handleVolumeViewportCase : this.handleStackViewportCase;
|
|
|
|
|
|
|
|
|
|
({ representationTypeToUse, isConverted } = await handler.apply(this, [
|
|
|
|
|
csViewport,
|
|
|
|
|
segmentation,
|
|
|
|
|
isVolumeSegmentation,
|
|
|
|
|
viewportId,
|
2022-11-16 20:19:52 +01:00
|
|
|
segmentationId,
|
2024-11-06 13:15:27 +01:00
|
|
|
]));
|
|
|
|
|
|
|
|
|
|
return { representationTypeToUse, isConverted };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async handleVolumeViewportCase(csViewport, segmentation, isVolumeSegmentation) {
|
|
|
|
|
if (csViewport.type === ViewportType.VOLUME_3D) {
|
|
|
|
|
return { representationTypeToUse: SegmentationRepresentations.Surface, isConverted: false };
|
|
|
|
|
} else {
|
|
|
|
|
await this.handleVolumeViewport(
|
|
|
|
|
csViewport as csTypes.IVolumeViewport,
|
|
|
|
|
segmentation,
|
|
|
|
|
isVolumeSegmentation
|
|
|
|
|
);
|
|
|
|
|
return { representationTypeToUse: SegmentationRepresentations.Labelmap, isConverted: false };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async handleStackViewportCase(
|
|
|
|
|
csViewport: csTypes.IViewport,
|
|
|
|
|
segmentation: cstTypes.Segmentation,
|
|
|
|
|
isVolumeSegmentation: boolean,
|
|
|
|
|
viewportId: string,
|
|
|
|
|
segmentationId: string
|
|
|
|
|
): Promise<{ representationTypeToUse: SegmentationRepresentations; isConverted: boolean }> {
|
|
|
|
|
if (isVolumeSegmentation) {
|
|
|
|
|
const isConverted = await this.convertStackToVolumeViewport(csViewport);
|
|
|
|
|
return { representationTypeToUse: SegmentationRepresentations.Labelmap, isConverted };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (updateLabelmapSegmentationImageReferences(viewportId, segmentationId)) {
|
|
|
|
|
return { representationTypeToUse: SegmentationRepresentations.Labelmap, isConverted: false };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const isConverted = await this.attemptStackToVolumeConversion(
|
|
|
|
|
csViewport as csTypes.IStackViewport,
|
|
|
|
|
segmentation,
|
|
|
|
|
viewportId,
|
|
|
|
|
segmentationId
|
2022-11-16 20:19:52 +01:00
|
|
|
);
|
2024-11-06 13:15:27 +01:00
|
|
|
|
|
|
|
|
return { representationTypeToUse: SegmentationRepresentations.Labelmap, isConverted };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async _addSegmentationRepresentation(
|
|
|
|
|
viewportId: string,
|
|
|
|
|
segmentationId: string,
|
|
|
|
|
representationType: csToolsEnums.SegmentationRepresentations,
|
|
|
|
|
colorLUTIndex: number,
|
|
|
|
|
isConverted: boolean
|
|
|
|
|
): Promise<void> {
|
|
|
|
|
const representation = {
|
|
|
|
|
type: representationType,
|
2022-11-16 20:19:52 +01:00
|
|
|
segmentationId,
|
2024-11-06 13:15:27 +01:00
|
|
|
config: { colorLUTOrIndex: colorLUTIndex },
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const addRepresentation = () =>
|
|
|
|
|
cstSegmentation.addSegmentationRepresentations(viewportId, [representation]);
|
|
|
|
|
|
|
|
|
|
if (isConverted) {
|
|
|
|
|
const { viewportGridService } = this.servicesManager.services;
|
|
|
|
|
await new Promise<void>(resolve => {
|
|
|
|
|
const { unsubscribe } = viewportGridService.subscribe(
|
|
|
|
|
viewportGridService.EVENTS.GRID_STATE_CHANGED,
|
|
|
|
|
() => {
|
|
|
|
|
addRepresentation();
|
|
|
|
|
unsubscribe();
|
|
|
|
|
resolve();
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
addRepresentation();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private async handleVolumeViewport(
|
|
|
|
|
viewport: csTypes.IVolumeViewport,
|
|
|
|
|
segmentation: SegmentationData,
|
|
|
|
|
isVolumeSegmentation: boolean
|
|
|
|
|
): Promise<void> {
|
|
|
|
|
if (isVolumeSegmentation) {
|
|
|
|
|
return; // Volume Labelmap on Volume Viewport is natively supported
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const frameOfReferenceUID = viewport.getFrameOfReferenceUID();
|
|
|
|
|
const imageIds = getLabelmapImageIds(segmentation.segmentationId);
|
|
|
|
|
const segImage = cache.getImage(imageIds[0]);
|
|
|
|
|
|
|
|
|
|
if (segImage?.FrameOfReferenceUID === frameOfReferenceUID) {
|
|
|
|
|
await convertStackToVolumeLabelmap(segmentation);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async convertStackToVolumeViewport(viewport: csTypes.IViewport): Promise<boolean> {
|
|
|
|
|
const { viewportGridService, cornerstoneViewportService } = this.servicesManager.services;
|
|
|
|
|
const state = viewportGridService.getState();
|
|
|
|
|
const gridViewport = state.viewports.get(viewport.id);
|
|
|
|
|
|
|
|
|
|
const prevViewPresentation = viewport.getViewPresentation();
|
|
|
|
|
const prevViewReference = viewport.getViewReference();
|
|
|
|
|
const stackViewport = cornerstoneViewportService.getCornerstoneViewport(viewport.id);
|
|
|
|
|
const { element } = stackViewport;
|
|
|
|
|
|
|
|
|
|
const volumeViewportNewVolumeHandler = () => {
|
|
|
|
|
const volumeViewport = cornerstoneViewportService.getCornerstoneViewport(viewport.id);
|
|
|
|
|
volumeViewport.setViewPresentation(prevViewPresentation);
|
|
|
|
|
volumeViewport.setViewReference(prevViewReference);
|
|
|
|
|
volumeViewport.render();
|
|
|
|
|
|
|
|
|
|
element.removeEventListener(
|
|
|
|
|
csEnums.Events.VOLUME_VIEWPORT_NEW_VOLUME,
|
|
|
|
|
volumeViewportNewVolumeHandler
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
element.addEventListener(
|
|
|
|
|
csEnums.Events.VOLUME_VIEWPORT_NEW_VOLUME,
|
|
|
|
|
volumeViewportNewVolumeHandler
|
2022-11-16 20:19:52 +01:00
|
|
|
);
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
viewportGridService.setDisplaySetsForViewport({
|
|
|
|
|
viewportId: viewport.id,
|
|
|
|
|
displaySetInstanceUIDs: gridViewport.displaySetInstanceUIDs,
|
|
|
|
|
viewportOptions: {
|
|
|
|
|
...gridViewport.viewportOptions,
|
|
|
|
|
viewportType: ViewportType.ORTHOGRAPHIC,
|
|
|
|
|
},
|
2022-11-16 20:19:52 +01:00
|
|
|
});
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
private async attemptStackToVolumeConversion(
|
|
|
|
|
viewport: csTypes.IStackViewport,
|
|
|
|
|
segmentation: SegmentationData,
|
|
|
|
|
viewportId: string,
|
|
|
|
|
segmentationId: string
|
|
|
|
|
): Promise<boolean> {
|
|
|
|
|
const imageIds = getLabelmapImageIds(segmentation.segmentationId);
|
|
|
|
|
const frameOfReferenceUID = viewport.getFrameOfReferenceUID();
|
|
|
|
|
const segImage = cache.getImage(imageIds[0]);
|
|
|
|
|
|
2024-11-11 20:28:34 +01:00
|
|
|
if (
|
|
|
|
|
segImage?.FrameOfReferenceUID &&
|
|
|
|
|
frameOfReferenceUID &&
|
|
|
|
|
segImage.FrameOfReferenceUID === frameOfReferenceUID
|
|
|
|
|
) {
|
2024-11-06 13:15:27 +01:00
|
|
|
const isConverted = await this.convertStackToVolumeViewport(viewport);
|
|
|
|
|
triggerSegmentationRepresentationModified(
|
|
|
|
|
viewportId,
|
|
|
|
|
segmentationId,
|
|
|
|
|
SegmentationRepresentations.Labelmap
|
|
|
|
|
);
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
return isConverted;
|
2022-11-16 20:19:52 +01:00
|
|
|
}
|
2024-11-06 13:15:27 +01:00
|
|
|
}
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
private addSegmentationToSource(segmentationPublicInput: cstTypes.SegmentationPublicInput) {
|
|
|
|
|
cstSegmentation.addSegmentations([segmentationPublicInput]);
|
|
|
|
|
}
|
2023-08-16 18:51:26 +02:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
private updateSegmentationInSource(
|
|
|
|
|
segmentationId: string,
|
|
|
|
|
payload: Partial<cstTypes.Segmentation>
|
|
|
|
|
) {
|
|
|
|
|
cstSegmentation.updateSegmentations([{ segmentationId, payload }]);
|
|
|
|
|
}
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
private _toOHIFSegmentationRepresentation(
|
|
|
|
|
viewportId: string,
|
|
|
|
|
csRepresentation: cstTypes.SegmentationRepresentation
|
|
|
|
|
): SegmentationRepresentation {
|
|
|
|
|
const { segmentationId, type, active, visible } = csRepresentation;
|
|
|
|
|
const { colorLUTIndex } = csRepresentation;
|
2023-09-22 16:23:44 +02:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
const segmentsRepresentations: { [segmentIndex: number]: SegmentRepresentation } = {};
|
|
|
|
|
|
|
|
|
|
const segmentation = cstSegmentation.state.getSegmentation(segmentationId);
|
|
|
|
|
|
|
|
|
|
if (!segmentation) {
|
|
|
|
|
throw new Error(`Segmentation with ID ${segmentationId} not found.`);
|
2023-09-22 16:23:44 +02:00
|
|
|
}
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
const segmentIds = Object.keys(segmentation.segments);
|
|
|
|
|
|
|
|
|
|
for (const segmentId of segmentIds) {
|
|
|
|
|
const segmentIndex = parseInt(segmentId, 10);
|
|
|
|
|
|
|
|
|
|
const color = cstSegmentation.config.color.getSegmentIndexColor(
|
|
|
|
|
viewportId,
|
|
|
|
|
segmentationId,
|
|
|
|
|
segmentIndex
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const isVisible = cstSegmentation.config.visibility.getSegmentIndexVisibility(
|
|
|
|
|
viewportId,
|
|
|
|
|
{
|
|
|
|
|
segmentationId,
|
|
|
|
|
type,
|
|
|
|
|
},
|
|
|
|
|
segmentIndex
|
|
|
|
|
);
|
2024-04-18 03:59:47 +02:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
segmentsRepresentations[segmentIndex] = {
|
|
|
|
|
color,
|
|
|
|
|
segmentIndex,
|
|
|
|
|
opacity: color[3],
|
|
|
|
|
visible: isVisible,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const styles = cstSegmentation.config.style.getStyle({
|
|
|
|
|
viewportId,
|
|
|
|
|
segmentationId,
|
|
|
|
|
type,
|
2024-04-18 03:59:47 +02:00
|
|
|
});
|
2024-11-06 13:15:27 +01:00
|
|
|
|
|
|
|
|
const id = `${segmentationId}-${type}-${viewportId}`;
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
id: id,
|
|
|
|
|
segmentationId,
|
|
|
|
|
label: segmentation.label,
|
|
|
|
|
active,
|
|
|
|
|
type,
|
|
|
|
|
visible,
|
|
|
|
|
segments: segmentsRepresentations,
|
|
|
|
|
styles,
|
|
|
|
|
viewportId,
|
|
|
|
|
colorLUTIndex,
|
|
|
|
|
config: {},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private _initSegmentationService() {
|
|
|
|
|
eventTarget.addEventListener(
|
|
|
|
|
csToolsEnums.Events.SEGMENTATION_MODIFIED,
|
|
|
|
|
this._onSegmentationModifiedFromSource
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
eventTarget.addEventListener(
|
|
|
|
|
csToolsEnums.Events.SEGMENTATION_REMOVED,
|
|
|
|
|
this._onSegmentationModifiedFromSource
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
eventTarget.addEventListener(
|
|
|
|
|
csToolsEnums.Events.SEGMENTATION_DATA_MODIFIED,
|
|
|
|
|
this._onSegmentationDataModifiedFromSource
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
eventTarget.addEventListener(
|
|
|
|
|
csToolsEnums.Events.SEGMENTATION_REPRESENTATION_MODIFIED,
|
|
|
|
|
this._onSegmentationRepresentationModifiedFromSource
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
eventTarget.addEventListener(
|
|
|
|
|
csToolsEnums.Events.SEGMENTATION_REPRESENTATION_ADDED,
|
|
|
|
|
this._onSegmentationRepresentationModifiedFromSource
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
eventTarget.addEventListener(
|
|
|
|
|
csToolsEnums.Events.SEGMENTATION_REPRESENTATION_REMOVED,
|
|
|
|
|
this._onSegmentationRepresentationModifiedFromSource
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
eventTarget.addEventListener(
|
|
|
|
|
csToolsEnums.Events.SEGMENTATION_ADDED,
|
|
|
|
|
this._onSegmentationAddedFromSource
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private getCornerstoneSegmentation(segmentationId: string) {
|
|
|
|
|
return cstSegmentation.state.getSegmentation(segmentationId);
|
2023-08-16 18:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
private _highlightLabelmap(
|
|
|
|
|
segmentIndex: number,
|
|
|
|
|
alpha: number,
|
|
|
|
|
hideOthers: boolean,
|
|
|
|
|
segments: Segment[],
|
2024-11-06 13:15:27 +01:00
|
|
|
viewportId: string,
|
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
|
|
|
animationLength: number,
|
2024-11-06 13:15:27 +01:00
|
|
|
representation: cstTypes.SegmentationRepresentation
|
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
|
|
|
) {
|
2024-11-06 13:15:27 +01:00
|
|
|
const { segmentationId } = representation;
|
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
|
|
|
const newSegmentSpecificConfig = {
|
2024-11-06 13:15:27 +01:00
|
|
|
fillAlpha: alpha,
|
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
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (hideOthers) {
|
2024-11-06 13:15:27 +01:00
|
|
|
throw new Error('hideOthers is not working right now');
|
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
|
|
|
for (let i = 0; i < segments.length; i++) {
|
|
|
|
|
if (i !== segmentIndex) {
|
|
|
|
|
newSegmentSpecificConfig[i] = {
|
2024-11-06 13:15:27 +01:00
|
|
|
fillAlpha: 0,
|
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
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
const { fillAlpha } = this.getStyle({
|
|
|
|
|
viewportId,
|
|
|
|
|
segmentationId,
|
|
|
|
|
type: LABELMAP,
|
|
|
|
|
segmentIndex,
|
|
|
|
|
}) as cstTypes.LabelmapStyle;
|
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
|
|
|
|
2023-05-15 14:23:13 +02:00
|
|
|
let startTime: number = null;
|
|
|
|
|
const animation = (timestamp: number) => {
|
|
|
|
|
if (startTime === null) {
|
|
|
|
|
startTime = timestamp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const elapsed = timestamp - startTime;
|
|
|
|
|
const progress = Math.min(elapsed / animationLength, 1);
|
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
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
cstSegmentation.config.style.setStyle(
|
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
|
|
|
{
|
2024-11-06 13:15:27 +01:00
|
|
|
segmentationId,
|
|
|
|
|
segmentIndex,
|
|
|
|
|
type: LABELMAP,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
fillAlpha: easeInOutBell(progress, fillAlpha),
|
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
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
2023-05-15 14:23:13 +02:00
|
|
|
if (progress < 1) {
|
|
|
|
|
requestAnimationFrame(animation);
|
|
|
|
|
} else {
|
2024-11-06 13:15:27 +01:00
|
|
|
cstSegmentation.config.style.setStyle(
|
|
|
|
|
{
|
|
|
|
|
segmentationId,
|
|
|
|
|
segmentIndex,
|
|
|
|
|
type: LABELMAP,
|
|
|
|
|
},
|
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
|
|
|
{}
|
|
|
|
|
);
|
|
|
|
|
}
|
2023-05-15 14:23:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
requestAnimationFrame(animation);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private _highlightContour(
|
|
|
|
|
segmentIndex: number,
|
|
|
|
|
alpha: number,
|
|
|
|
|
hideOthers: boolean,
|
|
|
|
|
segments: Segment[],
|
2024-11-06 13:15:27 +01:00
|
|
|
viewportId: string,
|
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
|
|
|
animationLength: number,
|
2024-11-06 13:15:27 +01:00
|
|
|
representation: cstTypes.SegmentationRepresentation
|
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
|
|
|
) {
|
2024-11-06 13:15:27 +01:00
|
|
|
const { segmentationId } = representation;
|
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
|
|
|
const startTime = performance.now();
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
const prevStyle = cstSegmentation.config.style.getStyle({
|
|
|
|
|
viewportId,
|
|
|
|
|
segmentationId,
|
|
|
|
|
type: CONTOUR,
|
|
|
|
|
segmentIndex,
|
|
|
|
|
}) as ContourStyle;
|
|
|
|
|
|
|
|
|
|
const prevOutlineWidth = prevStyle.outlineWidth;
|
|
|
|
|
// make this configurable
|
|
|
|
|
const baseline = Math.max(prevOutlineWidth * 3.5, 5);
|
|
|
|
|
|
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
|
|
|
const animate = (currentTime: number) => {
|
|
|
|
|
const progress = (currentTime - startTime) / animationLength;
|
|
|
|
|
if (progress >= 1) {
|
2024-11-06 13:15:27 +01:00
|
|
|
cstSegmentation.config.style.setStyle(
|
|
|
|
|
{
|
|
|
|
|
segmentationId,
|
|
|
|
|
segmentIndex,
|
|
|
|
|
type: CONTOUR,
|
|
|
|
|
},
|
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
|
|
|
{}
|
|
|
|
|
);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
const reversedProgress = reverseEaseInOutBell(progress, baseline);
|
|
|
|
|
|
|
|
|
|
cstSegmentation.config.style.setStyle(
|
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
|
|
|
{
|
2024-11-06 13:15:27 +01:00
|
|
|
segmentationId,
|
|
|
|
|
segmentIndex,
|
|
|
|
|
type: CONTOUR,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
outlineWidth: reversedProgress,
|
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
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
requestAnimationFrame(animate);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
requestAnimationFrame(animate);
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
private _toggleSegmentationRepresentationVisibility = (
|
|
|
|
|
viewportId: string,
|
|
|
|
|
segmentationId: string,
|
|
|
|
|
type: SegmentationRepresentations
|
|
|
|
|
): void => {
|
|
|
|
|
const representations = this.getSegmentationRepresentations(viewportId, {
|
|
|
|
|
segmentationId,
|
|
|
|
|
type,
|
|
|
|
|
});
|
|
|
|
|
const representation = representations[0];
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
const segmentsHidden = cstSegmentation.config.visibility.getHiddenSegmentIndices(viewportId, {
|
|
|
|
|
segmentationId,
|
|
|
|
|
type: representation.type,
|
|
|
|
|
});
|
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
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
const currentVisibility = segmentsHidden.size === 0;
|
|
|
|
|
this._setSegmentationRepresentationVisibility(
|
|
|
|
|
viewportId,
|
|
|
|
|
segmentationId,
|
|
|
|
|
representation.type,
|
|
|
|
|
!currentVisibility
|
|
|
|
|
);
|
|
|
|
|
};
|
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
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
private _setActiveSegment(segmentationId: string, segmentIndex: number) {
|
|
|
|
|
cstSegmentation.segmentIndex.setActiveSegmentIndex(segmentationId, segmentIndex);
|
2022-11-16 20:19:52 +01:00
|
|
|
}
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
private _getVolumeIdForDisplaySet(displaySet) {
|
|
|
|
|
const volumeLoaderSchema = displaySet.volumeLoaderSchema ?? VOLUME_LOADER_SCHEME;
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
return `${volumeLoaderSchema}:${displaySet.displaySetInstanceUID}`;
|
|
|
|
|
}
|
2022-11-16 20:19:52 +01:00
|
|
|
|
|
|
|
|
private _getSegmentCenter(segmentationId, segmentIndex) {
|
|
|
|
|
const segmentation = this.getSegmentation(segmentationId);
|
|
|
|
|
|
|
|
|
|
if (!segmentation) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
const { segments } = segmentation;
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
const { cachedStats } = segments[segmentIndex];
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
if (!cachedStats) {
|
2022-11-16 20:19:52 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
const { center } = cachedStats;
|
2022-11-16 20:19:52 +01:00
|
|
|
|
|
|
|
|
return center;
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
private _setSegmentLockedStatus(segmentationId: string, segmentIndex: number, isLocked: boolean) {
|
2023-09-01 22:19:39 +02:00
|
|
|
cstSegmentation.segmentLocking.setSegmentIndexLocked(segmentationId, segmentIndex, isLocked);
|
2022-11-16 20:19:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private _setSegmentVisibility(
|
2024-11-06 13:15:27 +01:00
|
|
|
viewportId: string,
|
2022-11-16 20:19:52 +01:00
|
|
|
segmentationId: string,
|
|
|
|
|
segmentIndex: number,
|
|
|
|
|
isVisible: boolean,
|
2024-11-06 13:15:27 +01:00
|
|
|
type?: SegmentationRepresentations
|
2022-11-16 20:19:52 +01:00
|
|
|
) {
|
2024-11-06 13:15:27 +01:00
|
|
|
cstSegmentation.config.visibility.setSegmentIndexVisibility(
|
|
|
|
|
viewportId,
|
|
|
|
|
{
|
|
|
|
|
segmentationId,
|
|
|
|
|
type,
|
|
|
|
|
},
|
2022-11-16 20:19:52 +01:00
|
|
|
segmentIndex,
|
|
|
|
|
isVisible
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
private _setSegmentLabel(segmentationId: string, segmentIndex: number, segmentLabel: string) {
|
|
|
|
|
const segmentation = this.getCornerstoneSegmentation(segmentationId);
|
|
|
|
|
const { segments } = segmentation;
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
segments[segmentIndex].label = segmentLabel;
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
cstSegmentation.updateSegmentations([
|
|
|
|
|
{
|
|
|
|
|
segmentationId,
|
|
|
|
|
payload: {
|
|
|
|
|
segments,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
]);
|
2022-11-16 20:19:52 +01:00
|
|
|
}
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
private _onSegmentationDataModifiedFromSource = evt => {
|
2022-11-16 20:19:52 +01:00
|
|
|
const { segmentationId } = evt.detail;
|
|
|
|
|
this._broadcastEvent(this.EVENTS.SEGMENTATION_DATA_MODIFIED, {
|
2024-11-06 13:15:27 +01:00
|
|
|
segmentationId,
|
2022-11-16 20:19:52 +01:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
private _onSegmentationRepresentationModifiedFromSource = evt => {
|
|
|
|
|
const { segmentationId, viewportId } = evt.detail;
|
|
|
|
|
this._broadcastEvent(this.EVENTS.SEGMENTATION_REPRESENTATION_MODIFIED, {
|
2022-11-16 20:19:52 +01:00
|
|
|
segmentationId,
|
2024-11-06 13:15:27 +01:00
|
|
|
viewportId,
|
2022-11-16 20:19:52 +01:00
|
|
|
});
|
2024-11-06 13:15:27 +01:00
|
|
|
};
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
private _onSegmentationModifiedFromSource = (
|
|
|
|
|
evt: cstTypes.EventTypes.SegmentationModifiedEventType
|
|
|
|
|
) => {
|
|
|
|
|
const { segmentationId } = evt.detail;
|
2023-03-22 17:44:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
this._broadcastEvent(this.EVENTS.SEGMENTATION_MODIFIED, {
|
|
|
|
|
segmentationId,
|
2022-11-16 20:19:52 +01:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
private _onSegmentationAddedFromSource = (
|
|
|
|
|
evt: cstTypes.EventTypes.SegmentationAddedEventType
|
|
|
|
|
) => {
|
|
|
|
|
const { segmentationId } = evt.detail;
|
2022-11-16 20:19:52 +01:00
|
|
|
|
2024-11-06 13:15:27 +01:00
|
|
|
this._broadcastEvent(this.EVENTS.SEGMENTATION_ADDED, {
|
|
|
|
|
segmentationId,
|
|
|
|
|
});
|
2022-11-16 20:19:52 +01:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default SegmentationService;
|
|
|
|
|
export { EVENTS, VALUE_TYPES };
|