feat(segmentation): Enhance Segmentation with New AI and Once Click Tools (#4910)

This commit is contained in:
Alireza authored and GitHub committed 2025-04-01 14:19:03 -04:00
1 parent 908482d2e0
commit c75a3f3af5
29 files changed
+846 -556

No files matched your search

+4 -2
View File
@@ -42,8 +42,10 @@ export const setToolActiveToolbar = {
const ReferenceLinesListeners = [
{
commandName: 'setSourceViewportForReferenceLinesTool',
context: 'CORNERSTONE',
commandName: 'setViewportForToolConfiguration',
commandOptions: {
toolName: 'ReferenceLines',
},
},
];
+3
View File
@@ -92,11 +92,14 @@ function modeFactory({ modeConfiguration }) {
'SegmentationTools',
]);
toolbarService.createButtonSection('segmentationToolboxUtilitySection', [
'LabelmapSlicePropagation',
'InterpolateLabelmap',
'SegmentBidirectional',
]);
toolbarService.createButtonSection('segmentationToolboxToolsSection', [
'BrushTools',
'MarkerLabelmap',
'RegionSegmentPlus',
'Shapes',
]);
toolbarService.createButtonSection('brushToolsSection', ['Brush', 'Eraser', 'Threshold']);
+9
View File
@@ -27,6 +27,15 @@ function createTools(utilityModule) {
activeStrategy: 'FILL_INSIDE_CIRCLE',
},
},
{
toolName: toolNames.LabelmapSlicePropagation,
},
{
toolName: toolNames.MarkerLabelmap,
},
{
toolName: toolNames.RegionSegmentPlus,
},
{
toolName: 'CircularEraser',
parentTool: 'Brush',
+98
View File
@@ -1,4 +1,5 @@
import type { Button } from '@ohif/core/types';
import { ViewportGridService } from '@ohif/core';
const setToolActiveToolbar = {
commandName: 'setToolActiveToolbar',
@@ -7,6 +8,15 @@ const setToolActiveToolbar = {
},
};
const callbacks = (toolName: string) => [
{
commandName: 'setViewportForToolConfiguration',
commandOptions: {
toolName,
},
},
];
const toolbarButtons: Button[] = [
// sections
{
@@ -322,6 +332,94 @@ const toolbarButtons: Button[] = [
commands: 'runSegmentBidirectional',
},
},
{
id: 'RegionSegmentPlus',
uiType: 'ohif.toolBoxButton',
props: {
icon: 'icon-tool-click-segment',
label: 'One Click Segment',
tooltip: 'One Click Segment',
evaluate: {
name: 'evaluate.cornerstone.segmentation',
toolNames: ['RegionSegmentPlus'],
disabledText: 'Create new segmentation to enable this tool.',
},
commands: 'setToolActiveToolbar',
},
},
{
id: 'LabelmapSlicePropagation',
uiType: 'ohif.toolBoxButton',
props: {
icon: 'icon-labelmap-slice-propagation',
label: 'Labelmap Assist',
tooltip: 'Labelmap Assist Based on Previous / Next Slice Data',
evaluate: [
'evaluate.cornerstoneTool.toggle',
{
name: 'evaluate.cornerstone.hasSegmentation',
},
],
listeners: {
[ViewportGridService.EVENTS.ACTIVE_VIEWPORT_ID_CHANGED]: callbacks(
'LabelmapSlicePropagation'
),
[ViewportGridService.EVENTS.VIEWPORTS_READY]: callbacks('LabelmapSlicePropagation'),
},
commands: 'toggleEnabledDisabledToolbar',
},
},
{
id: 'MarkerLabelmap',
uiType: 'ohif.toolBoxButton',
props: {
icon: 'icon-marker-labelmap',
label: 'Marker Guided Labelmap',
tooltip:
'Use Positive and Negative Points to Guide Labelmap Creation, hit N to move to next slice',
evaluate: [
{
name: 'evaluate.cornerstone.segmentation',
toolNames: ['MarkerLabelmap', 'MarkerInclude', 'MarkerExclude'],
},
],
commands: 'setToolActiveToolbar',
listeners: {
[ViewportGridService.EVENTS.ACTIVE_VIEWPORT_ID_CHANGED]: callbacks('MarkerLabelmap'),
[ViewportGridService.EVENTS.VIEWPORTS_READY]: callbacks('MarkerLabelmap'),
},
options: [
{
name: 'Clear Markers',
type: 'button',
id: 'clear-markers',
commands: 'clearMarkersForMarkerLabelmap',
},
{
name: 'Marker Mode',
type: 'radio',
id: 'marker-mode',
value: 'markerInclude',
values: [
{ value: 'markerInclude', label: 'Include' },
{ value: 'markerExclude', label: 'Exclude' },
],
commands: ({ commandsManager, options }) => {
const markerModeOption = options.find(option => option.id === 'marker-mode');
if (markerModeOption.value === 'markerInclude') {
commandsManager.run('setToolActive', {
toolName: 'MarkerInclude',
});
} else {
commandsManager.run('setToolActive', {
toolName: 'MarkerExclude',
});
}
},
},
],
},
},
{
id: 'Eraser',
uiType: 'ohif.toolBoxButton',