diff --git a/extensions/dicom-segmentation/src/components/SegmentationPanel/SegmentationPanel.js b/extensions/dicom-segmentation/src/components/SegmentationPanel/SegmentationPanel.js index 324d05da3..256baf142 100644 --- a/extensions/dicom-segmentation/src/components/SegmentationPanel/SegmentationPanel.js +++ b/extensions/dicom-segmentation/src/components/SegmentationPanel/SegmentationPanel.js @@ -36,6 +36,7 @@ const { studyMetadataManager } = utils; * @param {Function} props.onConfigurationChange - Configuration change handler * @param {Function} props.activeContexts - List of active application contexts * @param {Function} props.contexts - List of available application contexts + * @param {Function} props.servicesManager - Services manager * @returns component */ const SegmentationPanel = ({ @@ -50,6 +51,7 @@ const SegmentationPanel = ({ onSelectedSegmentationChange, activeContexts = [], contexts = {}, + servicesManager, }) => { const isVTK = () => activeContexts.includes(contexts.VTK); const isCornerstone = () => activeContexts.includes(contexts.CORNERSTONE); @@ -59,6 +61,9 @@ const SegmentationPanel = ({ * store with context to make these kind of things less blurry. */ const { configuration } = cornerstoneTools.getModule('segmentation'); + if (configuration.segsTolerance === undefined) { + configuration.segsTolerance = 1e-2; + } const DEFAULT_BRUSH_RADIUS = configuration.radius || 10; /* @@ -87,6 +92,25 @@ const SegmentationPanel = ({ return studyMetadata.getFirstImageId(displaySetInstanceUID); }; + const getAllSegDisplaySets = () => { + const { StudyInstanceUID } = getActiveViewport(); + const studyMetadata = studyMetadataManager.get(StudyInstanceUID); + return studyMetadata.getDerivedDatasets({ + Modality: 'SEG', + }); + }; + + const updateSegDisplaySetsTolerance = tolerance => { + const segDisplaySets = getAllSegDisplaySets(); + segDisplaySets.forEach(segDisplaySet => { + // update tol value + segDisplaySet.tolerance = tolerance; + // reset load flags for allowing retry for seg parsing. + segDisplaySet.isLoaded = false; + segDisplaySet.loadError = false; + }); + }; + const getActiveLabelMaps3D = () => { const { labelmaps3D, activeLabelmapIndex } = getBrushStackState(); return labelmaps3D[activeLabelmapIndex]; @@ -598,7 +622,9 @@ const SegmentationPanel = ({ configuration.outlineWidth = newConfiguration.outlineWidth; configuration.fillAlphaInactive = newConfiguration.fillAlphaInactive; configuration.outlineAlphaInactive = newConfiguration.outlineAlphaInactive; + configuration.segsTolerance = newConfiguration.segsTolerance; onConfigurationChange(newConfiguration); + updateSegDisplaySetsTolerance(configuration.segsTolerance); refreshViewports(); }; @@ -647,6 +673,7 @@ const SegmentationPanel = ({ configuration={configuration} onBack={() => setState(state => ({ ...state, showSettings: false }))} onChange={updateConfiguration} + servicesManager={servicesManager} /> ); } else { diff --git a/extensions/dicom-segmentation/src/components/SegmentationSettings/SegmentationSettings.js b/extensions/dicom-segmentation/src/components/SegmentationSettings/SegmentationSettings.js index 3d637b80f..6da70951b 100644 --- a/extensions/dicom-segmentation/src/components/SegmentationSettings/SegmentationSettings.js +++ b/extensions/dicom-segmentation/src/components/SegmentationSettings/SegmentationSettings.js @@ -4,7 +4,7 @@ import { Range } from '@ohif/ui'; import './SegmentationSettings.css'; -const SegmentationSettings = ({ configuration, onBack, onChange, disabledFields = [] }) => { +const SegmentationSettings = ({ configuration, onBack, onChange, servicesManager, disabledFields = [] }) => { const [state, setState] = useState({ renderFill: configuration.renderFill, renderOutline: configuration.renderOutline, @@ -13,7 +13,8 @@ const SegmentationSettings = ({ configuration, onBack, onChange, disabledFields outlineAlpha: configuration.outlineAlpha, outlineWidth: configuration.outlineWidth, fillAlphaInactive: configuration.fillAlphaInactive, - outlineAlphaInactive: configuration.outlineAlphaInactive + outlineAlphaInactive: configuration.outlineAlphaInactive, + segsTolerance: configuration.segsTolerance, }); useEffect(() => { @@ -133,6 +134,40 @@ const SegmentationSettings = ({ configuration, onBack, onChange, disabledFields )} )} +