Skip to content

Commit

Permalink
feat(SM): remove SM measurements from measurement panel (OHIF#4022)
Browse files Browse the repository at this point in the history
  • Loading branch information
sedghi authored and thanh-nguyen-dang committed Apr 30, 2024
1 parent c12d8fb commit b64f7f5
Show file tree
Hide file tree
Showing 21 changed files with 106 additions and 85 deletions.
25 changes: 0 additions & 25 deletions .codecov.yml

This file was deleted.

4 changes: 2 additions & 2 deletions extensions/cornerstone-dicom-seg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
},
"dependencies": {
"@babel/runtime": "^7.20.13",
"@cornerstonejs/adapters": "^1.70.0",
"@cornerstonejs/core": "^1.70.0",
"@cornerstonejs/adapters": "^1.70.5",
"@cornerstonejs/core": "^1.70.5",
"@kitware/vtk.js": "30.3.1",
"react-color": "^2.19.3"
}
Expand Down
6 changes: 3 additions & 3 deletions extensions/cornerstone-dicom-sr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
},
"dependencies": {
"@babel/runtime": "^7.20.13",
"@cornerstonejs/adapters": "^1.70.0",
"@cornerstonejs/core": "^1.70.0",
"@cornerstonejs/tools": "^1.70.0",
"@cornerstonejs/adapters": "^1.70.5",
"@cornerstonejs/core": "^1.70.5",
"@cornerstonejs/tools": "^1.70.5",
"classnames": "^2.3.2"
}
}
6 changes: 3 additions & 3 deletions extensions/cornerstone-dynamic-volume/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
},
"dependencies": {
"@babel/runtime": "^7.20.13",
"@cornerstonejs/core": "^1.70.0",
"@cornerstonejs/streaming-image-volume-loader": "^1.70.0",
"@cornerstonejs/tools": "^1.70.0",
"@cornerstonejs/core": "^1.70.5",
"@cornerstonejs/streaming-image-volume-loader": "^1.70.5",
"@cornerstonejs/tools": "^1.70.5",
"classnames": "^2.3.2"
}
}
10 changes: 5 additions & 5 deletions extensions/cornerstone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@cornerstonejs/codec-libjpeg-turbo-8bit": "^1.2.2",
"@cornerstonejs/codec-openjpeg": "^1.2.2",
"@cornerstonejs/codec-openjph": "^2.4.2",
"@cornerstonejs/dicom-image-loader": "^1.70.0",
"@cornerstonejs/dicom-image-loader": "^1.70.5",
"@icr/polyseg-wasm": "^0.4.0",
"@ohif/core": "3.8.0-beta.78",
"@ohif/ui": "3.8.0-beta.78",
Expand All @@ -55,10 +55,10 @@
},
"dependencies": {
"@babel/runtime": "^7.20.13",
"@cornerstonejs/adapters": "^1.70.0",
"@cornerstonejs/core": "^1.70.0",
"@cornerstonejs/streaming-image-volume-loader": "^1.70.0",
"@cornerstonejs/tools": "^1.70.0",
"@cornerstonejs/adapters": "^1.70.5",
"@cornerstonejs/core": "^1.70.5",
"@cornerstonejs/streaming-image-volume-loader": "^1.70.5",
"@cornerstonejs/tools": "^1.70.5",
"@icr/polyseg-wasm": "^0.4.0",
"@kitware/vtk.js": "30.3.1",
"html2canvas": "^1.4.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
utilities as csUtils,
} from '@cornerstonejs/core';
import { MeasurementService } from '@ohif/core';
import { Notification, useViewportDialog, Types as UITypes, AllInOneMenu } from '@ohif/ui';
import { Notification, useViewportDialog, AllInOneMenu } from '@ohif/ui';
import { IStackViewport, IVolumeViewport } from '@cornerstonejs/core/dist/esm/types';

import { setEnabledElement } from '../state';
Expand Down Expand Up @@ -114,7 +114,6 @@ const OHIFCornerstoneViewport = React.memo(props => {
// of the imageData in the OHIFCornerstoneViewport. This prop is used
// to set the initial state of the viewport's first image to render
initialImageIndex,
onReady,
} = props;

const viewportId = viewportOptions.viewportId;
Expand Down Expand Up @@ -142,7 +141,6 @@ const OHIFCornerstoneViewport = React.memo(props => {
viewportGridService,
stateSyncService,
viewportActionCornersService,
customizationService,
} = servicesManager.services as CornerstoneServices;

const [viewportDialogState] = useViewportDialog();
Expand Down Expand Up @@ -203,7 +201,6 @@ const OHIFCornerstoneViewport = React.memo(props => {

if (onElementEnabled) {
onElementEnabled(evt);
onReady?.(evt);
}
},
[viewportId, onElementEnabled, toolGroupService]
Expand Down
8 changes: 5 additions & 3 deletions extensions/cornerstone/src/commandsModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,16 +275,16 @@ function commandsModule({

actions.setViewportWindowLevel({ ...props, viewportId });
},
setToolEnabled: ({ toolName, toggle }) => {
setToolEnabled: ({ toolName, toggle, toolGroupId }) => {
const { viewports } = viewportGridService.getState();

if (!viewports.size) {
return;
}

const toolGroup = toolGroupService.getToolGroup(null);
const toolGroup = toolGroupService.getToolGroup(toolGroupId ?? null);

if (!toolGroup) {
if (!toolGroup || !toolGroup.hasTool(toolName)) {
return;
}

Expand All @@ -293,6 +293,8 @@ function commandsModule({
// Toggle the tool's state only if the toggle is true
if (toggle) {
toolIsEnabled ? toolGroup.setToolDisabled(toolName) : toolGroup.setToolEnabled(toolName);
} else {
toolGroup.setToolEnabled(toolName);
}

const renderingEngine = cornerstoneViewportService.getRenderingEngine();
Expand Down
1 change: 0 additions & 1 deletion extensions/cornerstone/src/init.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
utilities as csUtilities,
Enums as csEnums,
} from '@cornerstonejs/core';
import { utilities } from '@cornerstonejs/tools';
import {
cornerstoneStreamingImageVolumeLoader,
cornerstoneStreamingDynamicImageVolumeLoader,
Expand Down
3 changes: 3 additions & 0 deletions extensions/cornerstone/src/initCornerstoneTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
PlanarFreehandROITool,
SplineROITool,
LivewireContourTool,
OrientationMarkerTool,
} from '@cornerstonejs/tools';

import CalibrationLineTool from './tools/CalibrationLineTool';
Expand Down Expand Up @@ -80,6 +81,7 @@ export default function initCornerstoneTools(configuration = {}) {
addTool(PlanarFreehandROITool);
addTool(SplineROITool);
addTool(LivewireContourTool);
addTool(OrientationMarkerTool);

// Modify annotation tools to use dashed lines on SR
const annotationStyle = {
Expand Down Expand Up @@ -132,6 +134,7 @@ const toolNames = {
SplineROI: SplineROITool.toolName,
LivewireContour: LivewireContourTool.toolName,
PlanarFreehandROI: PlanarFreehandROITool.toolName,
OrientationMarker: OrientationMarkerTool.toolName,
};

export { toolNames };
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
import { ServicesManager, ExtensionManager, CommandsManager, DicomMetadataStore } from '@ohif/core';
import { MeasurementTable, Icon, ButtonGroup, Button } from '@ohif/ui';
import { MeasurementTable } from '@ohif/ui';
import { withTranslation, WithTranslation } from 'react-i18next';
import { EVENTS as MicroscopyEvents } from '../../services/MicroscopyService';
import dcmjs from 'dcmjs';
import styles from '../../utils/styles';
import callInputDialog from '../../utils/callInputDialog';
import constructSR from '../../utils/constructSR';
import { saveByteArray } from '../../utils/saveByteArray';
Expand Down Expand Up @@ -286,6 +285,11 @@ function MicroscopyPanel(props: IMicroscopyPanelProps) {
props.commandsManager.runCommand('setLabel', { uid }, 'MICROSCOPY');
};

const onMeasurementDeleteHandler = ({ uid, isActive }: { uid: string; isActive: boolean }) => {
const roiAnnotation = microscopyService.getAnnotation(uid);
microscopyService.removeAnnotation(roiAnnotation);
};

// Convert ROI annotations managed by microscopyService into our
// own format for display
const data = roiAnnotations.map((roiAnnotation, index) => {
Expand Down Expand Up @@ -322,8 +326,6 @@ function MicroscopyPanel(props: IMicroscopyPanelProps) {
};
});

const disabled = data.length === 0;

return (
<>
<div
Expand All @@ -336,6 +338,7 @@ function MicroscopyPanel(props: IMicroscopyPanelProps) {
data={data}
onClick={onMeasurementItemClickHandler}
onEdit={onMeasurementItemEditHandler}
onDelete={onMeasurementDeleteHandler}
/>
</div>
</>
Expand Down
4 changes: 2 additions & 2 deletions extensions/measurement-tracking/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"start": "yarn run dev"
},
"peerDependencies": {
"@cornerstonejs/core": "^1.70.0",
"@cornerstonejs/tools": "^1.70.0",
"@cornerstonejs/core": "^1.70.5",
"@cornerstonejs/tools": "^1.70.5",
"@ohif/core": "3.8.0-beta.78",
"@ohif/extension-cornerstone-dicom-sr": "3.8.0-beta.78",
"@ohif/ui": "3.8.0-beta.78",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import { Icon, ActionButtons } from '@ohif/ui';
import { useTranslation } from 'react-i18next';
export default function PanelRoiThresholdSegmentation({ servicesManager, commandsManager }) {
const { segmentationService } = servicesManager.services;
const { segmentationService, uiNotificationService } = servicesManager.services;
const { t } = useTranslation('PanelSUVExport');

const [segmentations, setSegmentations] = useState(() => segmentationService.getSegmentations());
Expand Down Expand Up @@ -36,6 +36,24 @@ export default function PanelRoiThresholdSegmentation({ servicesManager, command
const tmtvValue = segmentations?.[0]?.cachedStats?.tmtv?.value || null;
const config = segmentations?.[0]?.cachedStats?.tmtv?.config || {};

segmentations.forEach(segmentation => {
const { cachedStats } = segmentation;
if (!cachedStats) {
return;
}

// segment 1
const suvPeak = cachedStats?.['1']?.suvPeak?.suvPeak;

if (Number.isNaN(suvPeak)) {
uiNotificationService.show({
title: 'Unable to calculate SUV Peak',
message: 'The resulting threshold is not big enough.',
type: 'warning',
});
}
});

const actions = [
{
label: 'Export CSV',
Expand Down
14 changes: 14 additions & 0 deletions modes/tmtv/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function modeFactory({ modeConfiguration }) {
customizationService,
hangingProtocolService,
displaySetService,
viewportGridService,
} = servicesManager.services;

const utilityModule = extensionManager.getModuleEntry(
Expand Down Expand Up @@ -111,6 +112,19 @@ function modeFactory({ modeConfiguration }) {
},
]);

// This is a hack and we need to find a better way to enable
// some tools that require the viewport to be ready
const { unsubscribe: unsub1 } = viewportGridService.subscribe(
viewportGridService.EVENTS.VIEWPORTS_READY,
() => {
commandsManager.run('setToolEnabled', {
toolName: 'OrientationMarker',
toolGroupId: 'mipToolGroup',
});
unsub1();
}
);

// For the hanging protocol we need to decide on the window level
// based on whether the SUV is corrected or not, hence we can't hard
// code the window level in the hanging protocol but we add a custom
Expand Down
12 changes: 11 additions & 1 deletion modes/tmtv/src/initToolGroups.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,17 @@ function _initToolGroups(toolNames, Enums, toolGroupService, commandsManager, mo
bindings: [{ mouseButton: Enums.MouseBindings.Primary }],
},
],
enabled: [{ toolName: toolNames.SegmentationDisplay }],
enabled: [
{ toolName: toolNames.SegmentationDisplay },
{
toolName: toolNames.OrientationMarker,
configuration: {
orientationWidget: {
viewportCorner: 'BOTTOM_LEFT',
},
},
},
],
};

toolGroupService.createToolGroupAndAddTools(toolGroupIds.MIP, mipTools);
Expand Down
2 changes: 1 addition & 1 deletion platform/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@cornerstonejs/codec-libjpeg-turbo-8bit": "^1.2.2",
"@cornerstonejs/codec-openjpeg": "^1.2.2",
"@cornerstonejs/codec-openjph": "^2.4.5",
"@cornerstonejs/dicom-image-loader": "^1.70.0",
"@cornerstonejs/dicom-image-loader": "^1.70.5",
"@emotion/serialize": "^1.1.3",
"@ohif/core": "3.8.0-beta.78",
"@ohif/extension-cornerstone": "3.8.0-beta.78",
Expand Down
2 changes: 1 addition & 1 deletion platform/app/src/components/ViewportGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ function ViewerViewportGrid(props) {
viewportOptions={viewportOptions}
displaySetOptions={displaySetOptions}
needsRerendering={displaySetsNeedsRerendering}
onReady={() => {
onElementEnabled={() => {
viewportGridService.setViewportIsReady(viewportId, true);
}}
/>
Expand Down
2 changes: 1 addition & 1 deletion platform/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@cornerstonejs/codec-libjpeg-turbo-8bit": "^1.2.2",
"@cornerstonejs/codec-openjpeg": "^1.2.2",
"@cornerstonejs/codec-openjph": "^2.4.2",
"@cornerstonejs/dicom-image-loader": "^1.70.0",
"@cornerstonejs/dicom-image-loader": "^1.70.5",
"@ohif/ui": "3.8.0-beta.78",
"cornerstone-math": "0.1.9",
"dicom-parser": "^1.8.21"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import React from 'react';
import { ServicesManager } from '@ohif/core';
import PropTypes from 'prop-types';
import { useTranslation } from 'react-i18next';
import { annotation as CsAnnotation } from '@cornerstonejs/tools';

import MeasurementItem from './MeasurementItem';

const MeasurementTable = ({ data, title, onClick, onEdit, servicesManager }) => {
const MeasurementTable = ({ data, title, onClick, onEdit, onDelete, servicesManager }) => {
servicesManager = servicesManager as ServicesManager;
const { customizationService, measurementService } = servicesManager.services;
const { t } = useTranslation('MeasurementTable');
Expand All @@ -20,6 +19,7 @@ const MeasurementTable = ({ data, title, onClick, onEdit, servicesManager }) =>

const onMeasurementDeleteHandler = ({ uid }) => {
const measurement = measurementService.getMeasurement(uid);
onDelete?.({ uid });
measurementService.remove(
uid,
{
Expand Down
2 changes: 1 addition & 1 deletion platform/ui/src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ export {
ViewportOverlay,
WindowLevel,
WindowLevelMenuItem,
MeasurementItem,
InputDoubleRange,
LabellingFlow,
HeaderPatientInfo,
Expand All @@ -197,5 +198,4 @@ export {
ToolSettings,
Toolbox,
InvestigationalUseDialog,
MeasurementItem,
};
2 changes: 1 addition & 1 deletion platform/ui/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ export {
WindowLevelMenuItem,
ImageScrollbar,
ViewportOverlay,
MeasurementItem,
LabellingFlow,
HeaderPatientInfo,
ToolSettings,
Toolbox,
InvestigationalUseDialog,
MeasurementItem,
LayoutPreset,
} from './components';

Expand Down
Loading

0 comments on commit b64f7f5

Please sign in to comment.