OHIF with Cornerstone3D 2.0 (#4347)
This commit is contained in:
1 parent
8981a61b8c
commit
7ce7127d7c
803 files changed
+32760
-15893
No files matched your search
@@ -0,0 +1,78 @@
|
||||
import { useEffect, useState, memo } from 'react';
|
||||
|
||||
const MODALITIES_REQUIRING_CINE_AUTO_MOUNT = ['OT', 'US'];
|
||||
|
||||
const ActiveViewportBehavior = memo(
|
||||
({ servicesManager, viewportId }: withAppTypes<{ viewportId: string }>) => {
|
||||
const { displaySetService, cineService, viewportGridService, customizationService } =
|
||||
servicesManager.services;
|
||||
|
||||
const [activeViewportId, setActiveViewportId] = useState(viewportId);
|
||||
|
||||
useEffect(() => {
|
||||
const subscription = viewportGridService.subscribe(
|
||||
viewportGridService.EVENTS.ACTIVE_VIEWPORT_ID_CHANGED,
|
||||
({ viewportId }) => setActiveViewportId(viewportId)
|
||||
);
|
||||
|
||||
return () => subscription.unsubscribe();
|
||||
}, [viewportId, viewportGridService]);
|
||||
|
||||
useEffect(() => {
|
||||
if (cineService.isViewportCineClosed(activeViewportId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const displaySetInstanceUIDs =
|
||||
viewportGridService.getDisplaySetsUIDsForViewport(activeViewportId);
|
||||
|
||||
if (!displaySetInstanceUIDs) {
|
||||
return;
|
||||
}
|
||||
|
||||
const displaySets = displaySetInstanceUIDs.map(uid =>
|
||||
displaySetService.getDisplaySetByUID(uid)
|
||||
);
|
||||
|
||||
if (!displaySets.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
const modalities = displaySets.map(displaySet => displaySet?.Modality);
|
||||
|
||||
const { modalities: sourceModalities } = customizationService.getModeCustomization(
|
||||
'autoCineModalities',
|
||||
{
|
||||
id: 'autoCineModalities',
|
||||
modalities: MODALITIES_REQUIRING_CINE_AUTO_MOUNT,
|
||||
}
|
||||
);
|
||||
|
||||
const requiresCine = modalities.some(modality => sourceModalities.includes(modality));
|
||||
|
||||
if (requiresCine && !cineService.getState().isCineEnabled) {
|
||||
cineService.setIsCineEnabled(true);
|
||||
}
|
||||
}, [
|
||||
activeViewportId,
|
||||
cineService,
|
||||
viewportGridService,
|
||||
displaySetService,
|
||||
customizationService,
|
||||
]);
|
||||
|
||||
return null;
|
||||
},
|
||||
arePropsEqual
|
||||
);
|
||||
|
||||
ActiveViewportBehavior.displayName = 'ActiveViewportBehavior';
|
||||
|
||||
function arePropsEqual(prevProps, nextProps) {
|
||||
return (
|
||||
prevProps.viewportId === nextProps.viewportId &&
|
||||
prevProps.servicesManager === nextProps.servicesManager
|
||||
);
|
||||
}
|
||||
|
||||
export default ActiveViewportBehavior;
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
BaseVolumeViewport,
|
||||
} from '@cornerstonejs/core';
|
||||
import { ToolGroupManager } from '@cornerstonejs/tools';
|
||||
import PropTypes from 'prop-types';
|
||||
import { ViewportDownloadForm } from '@ohif/ui';
|
||||
|
||||
import { getEnabledElement as OHIFgetEnabledElement } from '../state';
|
||||
@@ -22,7 +21,7 @@ const CornerstoneViewportDownloadForm = ({
|
||||
onClose,
|
||||
activeViewportId: activeViewportIdProp,
|
||||
cornerstoneViewportService,
|
||||
}) => {
|
||||
}: withAppTypes) => {
|
||||
const enabledElement = OHIFgetEnabledElement(activeViewportIdProp);
|
||||
const activeViewportElement = enabledElement?.element;
|
||||
const activeViewportEnabledElement = getEnabledElement(activeViewportElement);
|
||||
@@ -246,9 +245,4 @@ const CornerstoneViewportDownloadForm = ({
|
||||
);
|
||||
};
|
||||
|
||||
CornerstoneViewportDownloadForm.propTypes = {
|
||||
onClose: PropTypes.func,
|
||||
activeViewportId: PropTypes.string.isRequired,
|
||||
};
|
||||
|
||||
export default CornerstoneViewportDownloadForm;
|
||||
@@ -1,158 +0,0 @@
|
||||
import React from 'react';
|
||||
import { Input, Dialog, ButtonEnums, LabellingFlow } from '@ohif/ui';
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} data
|
||||
* @param {*} data.text
|
||||
* @param {*} data.label
|
||||
* @param {*} event
|
||||
* @param {*} callback
|
||||
* @param {*} isArrowAnnotateInputDialog
|
||||
* @param {*} dialogConfig
|
||||
* @param {string?} dialogConfig.dialogTitle - title of the input dialog
|
||||
* @param {string?} dialogConfig.inputLabel - show label above the input
|
||||
*/
|
||||
|
||||
function callInputDialog(
|
||||
uiDialogService,
|
||||
data,
|
||||
callback,
|
||||
isArrowAnnotateInputDialog = true,
|
||||
dialogConfig: any = {}
|
||||
) {
|
||||
const dialogId = 'dialog-enter-annotation';
|
||||
const label = data ? (isArrowAnnotateInputDialog ? data.text : data.label) : '';
|
||||
const {
|
||||
dialogTitle = 'Annotation',
|
||||
inputLabel = 'Enter your annotation',
|
||||
validateFunc = value => true,
|
||||
} = dialogConfig;
|
||||
|
||||
const onSubmitHandler = ({ action, value }) => {
|
||||
switch (action.id) {
|
||||
case 'save':
|
||||
if (typeof validateFunc === 'function' && !validateFunc(value.label)) {
|
||||
return;
|
||||
}
|
||||
|
||||
callback(value.label, action.id);
|
||||
break;
|
||||
case 'cancel':
|
||||
callback('', action.id);
|
||||
break;
|
||||
}
|
||||
uiDialogService.dismiss({ id: dialogId });
|
||||
};
|
||||
|
||||
if (uiDialogService) {
|
||||
uiDialogService.create({
|
||||
id: dialogId,
|
||||
centralize: true,
|
||||
isDraggable: false,
|
||||
showOverlay: true,
|
||||
content: Dialog,
|
||||
contentProps: {
|
||||
title: dialogTitle,
|
||||
value: { label },
|
||||
noCloseButton: true,
|
||||
onClose: () => uiDialogService.dismiss({ id: dialogId }),
|
||||
actions: [
|
||||
{ id: 'cancel', text: 'Cancel', type: ButtonEnums.type.secondary },
|
||||
{ id: 'save', text: 'Save', type: ButtonEnums.type.primary },
|
||||
],
|
||||
onSubmit: onSubmitHandler,
|
||||
body: ({ value, setValue }) => {
|
||||
return (
|
||||
<Input
|
||||
autoFocus
|
||||
className="border-primary-main bg-black"
|
||||
type="text"
|
||||
id="annotation"
|
||||
label={inputLabel}
|
||||
labelClassName="text-white text-[14px] leading-[1.2]"
|
||||
value={value.label}
|
||||
onChange={event => {
|
||||
event.persist();
|
||||
setValue(value => ({ ...value, label: event.target.value }));
|
||||
}}
|
||||
onKeyPress={event => {
|
||||
if (event.key === 'Enter') {
|
||||
onSubmitHandler({ value, action: { id: 'save' } });
|
||||
}
|
||||
}}
|
||||
/>
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function callLabelAutocompleteDialog(uiDialogService, callback, dialogConfig, labelConfig) {
|
||||
const exclusive = labelConfig ? labelConfig.exclusive : false;
|
||||
const dropDownItems = labelConfig ? labelConfig.items : [];
|
||||
|
||||
const { validateFunc = value => true } = dialogConfig;
|
||||
|
||||
const labellingDoneCallback = value => {
|
||||
if (typeof value === 'string') {
|
||||
if (typeof validateFunc === 'function' && !validateFunc(value)) {
|
||||
return;
|
||||
}
|
||||
callback(value, 'save');
|
||||
} else {
|
||||
callback('', 'cancel');
|
||||
}
|
||||
uiDialogService.dismiss({ id: 'select-annotation' });
|
||||
};
|
||||
|
||||
uiDialogService.create({
|
||||
id: 'select-annotation',
|
||||
centralize: true,
|
||||
isDraggable: false,
|
||||
showOverlay: true,
|
||||
content: LabellingFlow,
|
||||
contentProps: {
|
||||
labellingDoneCallback: labellingDoneCallback,
|
||||
measurementData: { label: '' },
|
||||
componentClassName: {},
|
||||
labelData: dropDownItems,
|
||||
exclusive: exclusive,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function showLabelAnnotationPopup(measurement, uiDialogService, labelConfig) {
|
||||
const exclusive = labelConfig ? labelConfig.exclusive : false;
|
||||
const dropDownItems = labelConfig ? labelConfig.items : [];
|
||||
return new Promise<Map<any, any>>((resolve, reject) => {
|
||||
const labellingDoneCallback = value => {
|
||||
uiDialogService.dismiss({ id: 'select-annotation' });
|
||||
if (typeof value === 'string') {
|
||||
measurement.label = value;
|
||||
}
|
||||
resolve(measurement);
|
||||
};
|
||||
|
||||
uiDialogService.create({
|
||||
id: 'select-annotation',
|
||||
isDraggable: false,
|
||||
showOverlay: true,
|
||||
content: LabellingFlow,
|
||||
defaultPosition: {
|
||||
x: window.innerWidth / 2,
|
||||
y: window.innerHeight / 2,
|
||||
},
|
||||
contentProps: {
|
||||
labellingDoneCallback: labellingDoneCallback,
|
||||
measurementData: measurement,
|
||||
componentClassName: {},
|
||||
labelData: dropDownItems,
|
||||
exclusive: exclusive,
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export default callInputDialog;
|
||||
@@ -161,7 +161,7 @@ class DicomLoaderService {
|
||||
getDicomDataMethod = fetchIt.bind(this, imageId);
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unsupported image type: ${loaderType} for imageId: ${imageId}`);
|
||||
return;
|
||||
}
|
||||
|
||||
return getDicomDataMethod();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { getEnabledElement } from '@cornerstonejs/core';
|
||||
import { IEnabledElement } from '@cornerstonejs/core/dist/esm/types';
|
||||
import { IEnabledElement } from '@cornerstonejs/core/types';
|
||||
|
||||
import { getEnabledElement as OHIFgetEnabledElement } from '../state';
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ export default function getCornerstoneViewportType(
|
||||
return Enums.ViewportType.VIDEO;
|
||||
}
|
||||
if (lowerViewportType === WHOLESLIDE) {
|
||||
return Enums.ViewportType.WholeSlide;
|
||||
return Enums.ViewportType.WHOLE_SLIDE;
|
||||
}
|
||||
|
||||
if (lowerViewportType === VOLUME || lowerViewportType === ORTHOGRAPHIC) {
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
import { CONSTANTS, utilities } from '@cornerstonejs/core';
|
||||
|
||||
const { MPR_CAMERA_VALUES } = CONSTANTS;
|
||||
|
||||
/**
|
||||
* Determines the viewport orientation (axial, sagittal, or coronal) based on the image orientation patient values.
|
||||
* This is done by comparing the view vectors with predefined MPR camera values.
|
||||
*
|
||||
* @param imageOrientationPatient - Array of 6 numbers representing the image orientation patient values.
|
||||
* The first 3 numbers represent the direction cosines of the first row and the second 3 numbers
|
||||
* represent the direction cosines of the first column.
|
||||
*
|
||||
* @returns The viewport orientation as a string ('axial', 'sagittal', 'coronal') or undefined if
|
||||
* the orientation cannot be determined or if the input is invalid.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const orientation = getViewportOrientationFromImageOrientationPatient([1,0,0,0,1,0]);
|
||||
* console.debug(orientation); // 'axial'
|
||||
* ```
|
||||
*/
|
||||
export const getViewportOrientationFromImageOrientationPatient = (
|
||||
imageOrientationPatient: number[]
|
||||
): string | undefined => {
|
||||
if (!imageOrientationPatient || imageOrientationPatient.length !== 6) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const viewRight = imageOrientationPatient.slice(0, 3);
|
||||
const viewDown = imageOrientationPatient.slice(3, 6);
|
||||
const viewUp = [-viewDown[0], -viewDown[1], -viewDown[2]];
|
||||
|
||||
// Compare vectors with MPR camera values using utilities.isEqual
|
||||
if (
|
||||
utilities.isEqual(viewRight, MPR_CAMERA_VALUES.axial.viewRight) &&
|
||||
utilities.isEqual(viewUp, MPR_CAMERA_VALUES.axial.viewUp)
|
||||
) {
|
||||
return 'axial';
|
||||
}
|
||||
|
||||
if (
|
||||
utilities.isEqual(viewRight, MPR_CAMERA_VALUES.sagittal.viewRight) &&
|
||||
utilities.isEqual(viewUp, MPR_CAMERA_VALUES.sagittal.viewUp)
|
||||
) {
|
||||
return 'sagittal';
|
||||
}
|
||||
|
||||
if (
|
||||
utilities.isEqual(viewRight, MPR_CAMERA_VALUES.coronal.viewRight) &&
|
||||
utilities.isEqual(viewUp, MPR_CAMERA_VALUES.coronal.viewUp)
|
||||
) {
|
||||
return 'coronal';
|
||||
}
|
||||
|
||||
return undefined;
|
||||
};
|
||||
@@ -1,5 +1,7 @@
|
||||
import SUPPORTED_TOOLS from './constants/supportedTools';
|
||||
import { getDisplayUnit } from './utils';
|
||||
import { getIsLocked } from './utils/getIsLocked';
|
||||
import { getIsVisible } from './utils/getIsVisible';
|
||||
import getSOPInstanceAttributes from './utils/getSOPInstanceAttributes';
|
||||
import { utils } from '@ohif/core';
|
||||
|
||||
@@ -19,9 +21,11 @@ const Angle = {
|
||||
getValueTypeFromToolType,
|
||||
customizationService
|
||||
) => {
|
||||
const { annotation, viewportId } = csToolsEventDetail;
|
||||
const { annotation } = csToolsEventDetail;
|
||||
const { metadata, data, annotationUID } = annotation;
|
||||
|
||||
const isLocked = getIsLocked(annotationUID);
|
||||
const isVisible = getIsVisible(annotationUID);
|
||||
if (!metadata || !data) {
|
||||
console.warn('Length tool: Missing metadata or data');
|
||||
return null;
|
||||
@@ -55,7 +59,7 @@ const Angle = {
|
||||
|
||||
const mappedAnnotations = getMappedAnnotations(annotation, displaySetService);
|
||||
|
||||
const displayText = getDisplayText(mappedAnnotations, displaySet, customizationService);
|
||||
const displayText = getDisplayText(mappedAnnotations, displaySet);
|
||||
const getReport = () =>
|
||||
_getReport(mappedAnnotations, points, FrameOfReferenceUID, customizationService);
|
||||
|
||||
@@ -65,6 +69,8 @@ const Angle = {
|
||||
FrameOfReferenceUID,
|
||||
points,
|
||||
textBox,
|
||||
isLocked,
|
||||
isVisible,
|
||||
metadata,
|
||||
referenceSeriesUID: SeriesInstanceUID,
|
||||
referenceStudyUID: StudyInstanceUID,
|
||||
@@ -158,12 +164,15 @@ function _getReport(mappedAnnotations, points, FrameOfReferenceUID, customizatio
|
||||
};
|
||||
}
|
||||
|
||||
function getDisplayText(mappedAnnotations, displaySet, customizationService) {
|
||||
if (!mappedAnnotations || !mappedAnnotations.length) {
|
||||
return '';
|
||||
}
|
||||
function getDisplayText(mappedAnnotations, displaySet) {
|
||||
const displayText = {
|
||||
primary: [],
|
||||
secondary: [],
|
||||
};
|
||||
|
||||
const displayText = [];
|
||||
if (!mappedAnnotations || !mappedAnnotations.length) {
|
||||
return displayText;
|
||||
}
|
||||
|
||||
// Area is the same for all series
|
||||
const { angle, unit, SeriesNumber, SOPInstanceUID, frameNumber } = mappedAnnotations[0];
|
||||
@@ -181,9 +190,9 @@ function getDisplayText(mappedAnnotations, displaySet, customizationService) {
|
||||
return displayText;
|
||||
}
|
||||
const roundedAngle = utils.roundNumber(angle, 2);
|
||||
displayText.push(
|
||||
`${roundedAngle} ${getDisplayUnit(unit)} (S: ${SeriesNumber}${instanceText}${frameText})`
|
||||
);
|
||||
|
||||
displayText.primary.push(`${roundedAngle} ${getDisplayUnit(unit)}`);
|
||||
displayText.secondary.push(`S: ${SeriesNumber}${instanceText}${frameText}`);
|
||||
|
||||
return displayText;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import SUPPORTED_TOOLS from './constants/supportedTools';
|
||||
import { getIsLocked } from './utils/getIsLocked';
|
||||
import getSOPInstanceAttributes from './utils/getSOPInstanceAttributes';
|
||||
|
||||
import { getIsVisible } from './utils/getIsVisible';
|
||||
const Length = {
|
||||
toAnnotation: measurement => {},
|
||||
|
||||
@@ -17,9 +18,11 @@ const Length = {
|
||||
getValueTypeFromToolType,
|
||||
customizationService
|
||||
) => {
|
||||
const { annotation, viewportId } = csToolsEventDetail;
|
||||
const { annotation } = csToolsEventDetail;
|
||||
const { metadata, data, annotationUID } = annotation;
|
||||
|
||||
const isLocked = getIsLocked(annotationUID);
|
||||
const isVisible = getIsVisible(annotationUID);
|
||||
if (!metadata || !data) {
|
||||
console.warn('Length tool: Missing metadata or data');
|
||||
return null;
|
||||
@@ -53,7 +56,7 @@ const Length = {
|
||||
|
||||
const mappedAnnotations = getMappedAnnotations(annotation, displaySetService);
|
||||
|
||||
const displayText = getDisplayText(mappedAnnotations, displaySet, customizationService);
|
||||
const displayText = getDisplayText(mappedAnnotations, displaySet);
|
||||
|
||||
return {
|
||||
uid: annotationUID,
|
||||
@@ -61,6 +64,8 @@ const Length = {
|
||||
FrameOfReferenceUID,
|
||||
points,
|
||||
textBox,
|
||||
isLocked,
|
||||
isVisible,
|
||||
metadata,
|
||||
referenceSeriesUID: SeriesInstanceUID,
|
||||
referenceStudyUID: StudyInstanceUID,
|
||||
@@ -107,15 +112,17 @@ function getMappedAnnotations(annotation, displaySetService) {
|
||||
return annotations;
|
||||
}
|
||||
|
||||
function getDisplayText(mappedAnnotations, displaySet, customizationService) {
|
||||
if (!mappedAnnotations) {
|
||||
return '';
|
||||
function getDisplayText(mappedAnnotations, displaySet) {
|
||||
const displayText = {
|
||||
primary: [],
|
||||
secondary: [],
|
||||
};
|
||||
|
||||
if (!mappedAnnotations || !mappedAnnotations.length) {
|
||||
return displayText;
|
||||
}
|
||||
|
||||
const displayText = [];
|
||||
|
||||
// Area is the same for all series
|
||||
const { SeriesNumber, SOPInstanceUID, frameNumber } = mappedAnnotations[0];
|
||||
const { SeriesNumber, SOPInstanceUID, frameNumber, text } = mappedAnnotations[0];
|
||||
|
||||
const instance = displaySet.instances.find(image => image.SOPInstanceUID === SOPInstanceUID);
|
||||
|
||||
@@ -127,7 +134,13 @@ function getDisplayText(mappedAnnotations, displaySet, customizationService) {
|
||||
const instanceText = InstanceNumber ? ` I: ${InstanceNumber}` : '';
|
||||
const frameText = displaySet.isMultiFrame ? ` F: ${frameNumber}` : '';
|
||||
|
||||
displayText.push(`(S: ${SeriesNumber}${instanceText}${frameText})`);
|
||||
// Add the annotation text to the primary array
|
||||
if (text) {
|
||||
displayText.primary.push(text);
|
||||
}
|
||||
|
||||
// Add the series information to the secondary array
|
||||
displayText.secondary.push(`S: ${SeriesNumber}${instanceText}${frameText}`);
|
||||
|
||||
return displayText;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { annotation } from '@cornerstonejs/tools';
|
||||
|
||||
import SUPPORTED_TOOLS from './constants/supportedTools';
|
||||
import getSOPInstanceAttributes from './utils/getSOPInstanceAttributes';
|
||||
import { utils } from '@ohif/core';
|
||||
import { getDisplayUnit } from './utils';
|
||||
import { getIsLocked } from './utils/getIsLocked';
|
||||
import { getIsVisible } from './utils/getIsVisible';
|
||||
|
||||
const Bidirectional = {
|
||||
toAnnotation: measurement => {},
|
||||
@@ -14,9 +14,12 @@ const Bidirectional = {
|
||||
getValueTypeFromToolType,
|
||||
customizationService
|
||||
) => {
|
||||
const { annotation, viewportId } = csToolsEventDetail;
|
||||
const { annotation } = csToolsEventDetail;
|
||||
const { metadata, data, annotationUID } = annotation;
|
||||
|
||||
const isLocked = getIsLocked(annotationUID);
|
||||
const isVisible = getIsVisible(annotationUID);
|
||||
|
||||
if (!metadata || !data) {
|
||||
console.warn('Length tool: Missing metadata or data');
|
||||
return null;
|
||||
@@ -50,7 +53,7 @@ const Bidirectional = {
|
||||
|
||||
const mappedAnnotations = getMappedAnnotations(annotation, displaySetService);
|
||||
|
||||
const displayText = getDisplayText(mappedAnnotations, displaySet, customizationService);
|
||||
const displayText = getDisplayText(mappedAnnotations, displaySet);
|
||||
const getReport = () =>
|
||||
_getReport(mappedAnnotations, points, FrameOfReferenceUID, customizationService);
|
||||
|
||||
@@ -60,6 +63,8 @@ const Bidirectional = {
|
||||
FrameOfReferenceUID,
|
||||
points,
|
||||
textBox,
|
||||
isLocked,
|
||||
isVisible,
|
||||
metadata,
|
||||
referenceSeriesUID: SeriesInstanceUID,
|
||||
referenceStudyUID: StudyInstanceUID,
|
||||
@@ -153,12 +158,15 @@ function _getReport(mappedAnnotations, points, FrameOfReferenceUID, customizatio
|
||||
};
|
||||
}
|
||||
|
||||
function getDisplayText(mappedAnnotations, displaySet, customizationService) {
|
||||
if (!mappedAnnotations || !mappedAnnotations.length) {
|
||||
return '';
|
||||
}
|
||||
function getDisplayText(mappedAnnotations, displaySet) {
|
||||
const displayText = {
|
||||
primary: [],
|
||||
secondary: [],
|
||||
};
|
||||
|
||||
const displayText = [];
|
||||
if (!mappedAnnotations || !mappedAnnotations.length) {
|
||||
return displayText;
|
||||
}
|
||||
|
||||
// Area is the same for all series
|
||||
const { length, width, unit, SeriesNumber, SOPInstanceUID, frameNumber } = mappedAnnotations[0];
|
||||
@@ -175,10 +183,9 @@ function getDisplayText(mappedAnnotations, displaySet, customizationService) {
|
||||
const instanceText = InstanceNumber ? ` I: ${InstanceNumber}` : '';
|
||||
const frameText = displaySet.isMultiFrame ? ` F: ${frameNumber}` : '';
|
||||
|
||||
displayText.push(
|
||||
`L: ${roundedLength} ${getDisplayUnit(unit)} (S: ${SeriesNumber}${instanceText}${frameText})`
|
||||
);
|
||||
displayText.push(`W: ${roundedWidth} ${getDisplayUnit(unit)}`);
|
||||
displayText.primary.push(`L: ${roundedLength} ${getDisplayUnit(unit)}`);
|
||||
displayText.primary.push(`W: ${roundedWidth} ${getDisplayUnit(unit)}`);
|
||||
displayText.secondary.push(`S: ${SeriesNumber}${instanceText}${frameText}`);
|
||||
|
||||
return displayText;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ import { getDisplayUnit } from './utils';
|
||||
import getSOPInstanceAttributes from './utils/getSOPInstanceAttributes';
|
||||
import { utils } from '@ohif/core';
|
||||
import { getStatisticDisplayString } from './utils/getValueDisplayString';
|
||||
import { getIsLocked } from './utils/getIsLocked';
|
||||
import { getIsVisible } from './utils/getIsVisible';
|
||||
|
||||
const CircleROI = {
|
||||
toAnnotation: measurement => {},
|
||||
@@ -13,9 +15,12 @@ const CircleROI = {
|
||||
getValueTypeFromToolType,
|
||||
customizationService
|
||||
) => {
|
||||
const { annotation, viewportId } = csToolsEventDetail;
|
||||
const { annotation } = csToolsEventDetail;
|
||||
const { metadata, data, annotationUID } = annotation;
|
||||
|
||||
const isLocked = getIsLocked(annotationUID);
|
||||
const isVisible = getIsVisible(annotationUID);
|
||||
|
||||
if (!metadata || !data) {
|
||||
console.warn('Length tool: Missing metadata or data');
|
||||
return null;
|
||||
@@ -49,7 +54,7 @@ const CircleROI = {
|
||||
|
||||
const mappedAnnotations = getMappedAnnotations(annotation, displaySetService);
|
||||
|
||||
const displayText = getDisplayText(mappedAnnotations, displaySet, customizationService);
|
||||
const displayText = getDisplayText(mappedAnnotations, displaySet);
|
||||
const getReport = () =>
|
||||
_getReport(mappedAnnotations, points, FrameOfReferenceUID, customizationService);
|
||||
|
||||
@@ -59,6 +64,8 @@ const CircleROI = {
|
||||
FrameOfReferenceUID,
|
||||
points,
|
||||
textBox,
|
||||
isLocked,
|
||||
isVisible,
|
||||
metadata,
|
||||
referenceSeriesUID: SeriesInstanceUID,
|
||||
referenceStudyUID: StudyInstanceUID,
|
||||
@@ -161,12 +168,15 @@ function _getReport(mappedAnnotations, points, FrameOfReferenceUID, customizatio
|
||||
};
|
||||
}
|
||||
|
||||
function getDisplayText(mappedAnnotations, displaySet, customizationService) {
|
||||
if (!mappedAnnotations || !mappedAnnotations.length) {
|
||||
return '';
|
||||
}
|
||||
function getDisplayText(mappedAnnotations, displaySet) {
|
||||
const displayText = {
|
||||
primary: [],
|
||||
secondary: [],
|
||||
};
|
||||
|
||||
const displayText = [];
|
||||
if (!mappedAnnotations || !mappedAnnotations.length) {
|
||||
return displayText;
|
||||
}
|
||||
|
||||
// Area is the same for all series
|
||||
const { area, SOPInstanceUID, frameNumber, areaUnit } = mappedAnnotations[0];
|
||||
@@ -183,7 +193,7 @@ function getDisplayText(mappedAnnotations, displaySet, customizationService) {
|
||||
|
||||
// Area sometimes becomes undefined if `preventHandleOutsideImage` is off.
|
||||
const roundedArea = utils.roundNumber(area || 0, 2);
|
||||
displayText.push(`${roundedArea} ${getDisplayUnit(areaUnit)}`);
|
||||
displayText.primary.push(`${roundedArea} ${getDisplayUnit(areaUnit)}`);
|
||||
|
||||
// Todo: we need a better UI for displaying all these information
|
||||
mappedAnnotations.forEach(mappedAnnotation => {
|
||||
@@ -191,10 +201,8 @@ function getDisplayText(mappedAnnotations, displaySet, customizationService) {
|
||||
|
||||
const maxStr = getStatisticDisplayString(max, unit, 'max');
|
||||
|
||||
const str = `${maxStr}(S:${SeriesNumber}${instanceText}${frameText})`;
|
||||
if (!displayText.includes(str)) {
|
||||
displayText.push(str);
|
||||
}
|
||||
displayText.primary.push(maxStr);
|
||||
displayText.secondary.push(`S: ${SeriesNumber}${instanceText}${frameText}`);
|
||||
});
|
||||
|
||||
return displayText;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import SUPPORTED_TOOLS from './constants/supportedTools';
|
||||
import { getDisplayUnit } from './utils';
|
||||
import { getIsLocked } from './utils/getIsLocked';
|
||||
import { getIsVisible } from './utils/getIsVisible';
|
||||
import getSOPInstanceAttributes from './utils/getSOPInstanceAttributes';
|
||||
import { utils } from '@ohif/core';
|
||||
|
||||
@@ -19,9 +21,12 @@ const CobbAngle = {
|
||||
getValueTypeFromToolType,
|
||||
customizationService
|
||||
) => {
|
||||
const { annotation, viewportId } = csToolsEventDetail;
|
||||
const { annotation } = csToolsEventDetail;
|
||||
const { metadata, data, annotationUID } = annotation;
|
||||
|
||||
const isLocked = getIsLocked(annotationUID);
|
||||
const isVisible = getIsVisible(annotationUID);
|
||||
|
||||
if (!metadata || !data) {
|
||||
console.warn('Cobb Angle tool: Missing metadata or data');
|
||||
return null;
|
||||
@@ -55,7 +60,7 @@ const CobbAngle = {
|
||||
|
||||
const mappedAnnotations = getMappedAnnotations(annotation, displaySetService);
|
||||
|
||||
const displayText = getDisplayText(mappedAnnotations, displaySet, customizationService);
|
||||
const displayText = getDisplayText(mappedAnnotations, displaySet);
|
||||
const getReport = () =>
|
||||
_getReport(mappedAnnotations, points, FrameOfReferenceUID, customizationService);
|
||||
|
||||
@@ -65,6 +70,8 @@ const CobbAngle = {
|
||||
FrameOfReferenceUID,
|
||||
points,
|
||||
textBox,
|
||||
isLocked,
|
||||
isVisible,
|
||||
metadata,
|
||||
referenceSeriesUID: SeriesInstanceUID,
|
||||
referenceStudyUID: StudyInstanceUID,
|
||||
@@ -158,14 +165,17 @@ function _getReport(mappedAnnotations, points, FrameOfReferenceUID, customizatio
|
||||
};
|
||||
}
|
||||
|
||||
function getDisplayText(mappedAnnotations, displaySet, customizationService) {
|
||||
function getDisplayText(mappedAnnotations, displaySet) {
|
||||
const displayText = {
|
||||
primary: [],
|
||||
secondary: [],
|
||||
};
|
||||
|
||||
if (!mappedAnnotations || !mappedAnnotations.length) {
|
||||
return '';
|
||||
return displayText;
|
||||
}
|
||||
|
||||
const displayText = [];
|
||||
|
||||
// Area is the same for all series
|
||||
// Angle is the same for all series
|
||||
const { angle, unit, SeriesNumber, SOPInstanceUID, frameNumber } = mappedAnnotations[0];
|
||||
|
||||
const instance = displaySet.instances.find(image => image.SOPInstanceUID === SOPInstanceUID);
|
||||
@@ -181,9 +191,9 @@ function getDisplayText(mappedAnnotations, displaySet, customizationService) {
|
||||
return displayText;
|
||||
}
|
||||
const roundedAngle = utils.roundNumber(angle, 2);
|
||||
displayText.push(
|
||||
`${roundedAngle} ${getDisplayUnit(unit)} (S: ${SeriesNumber}${instanceText}${frameText})`
|
||||
);
|
||||
|
||||
displayText.primary.push(`${roundedAngle} ${getDisplayUnit(unit)}`);
|
||||
displayText.secondary.push(`S: ${SeriesNumber}${instanceText}${frameText}`);
|
||||
|
||||
return displayText;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import SUPPORTED_TOOLS from './constants/supportedTools';
|
||||
import { getDisplayUnit } from './utils';
|
||||
import { getIsLocked } from './utils/getIsLocked';
|
||||
import { getIsVisible } from './utils/getIsVisible';
|
||||
import getSOPInstanceAttributes from './utils/getSOPInstanceAttributes';
|
||||
import { utils } from '@ohif/core';
|
||||
import { getStatisticDisplayString } from './utils/getValueDisplayString';
|
||||
@@ -13,9 +15,12 @@ const EllipticalROI = {
|
||||
getValueTypeFromToolType,
|
||||
customizationService
|
||||
) => {
|
||||
const { annotation, viewportId } = csToolsEventDetail;
|
||||
const { annotation } = csToolsEventDetail;
|
||||
const { metadata, data, annotationUID } = annotation;
|
||||
|
||||
const isLocked = getIsLocked(annotationUID);
|
||||
const isVisible = getIsVisible(annotationUID);
|
||||
|
||||
if (!metadata || !data) {
|
||||
console.warn('Length tool: Missing metadata or data');
|
||||
return null;
|
||||
@@ -60,6 +65,8 @@ const EllipticalROI = {
|
||||
points,
|
||||
textBox,
|
||||
metadata,
|
||||
isLocked,
|
||||
isVisible,
|
||||
referenceSeriesUID: SeriesInstanceUID,
|
||||
referenceStudyUID: StudyInstanceUID,
|
||||
referencedImageId,
|
||||
@@ -162,11 +169,14 @@ function _getReport(mappedAnnotations, points, FrameOfReferenceUID, customizatio
|
||||
}
|
||||
|
||||
function getDisplayText(mappedAnnotations, displaySet, customizationService) {
|
||||
if (!mappedAnnotations || !mappedAnnotations.length) {
|
||||
return '';
|
||||
}
|
||||
const displayText = {
|
||||
primary: [],
|
||||
secondary: [],
|
||||
};
|
||||
|
||||
const displayText = [];
|
||||
if (!mappedAnnotations || !mappedAnnotations.length) {
|
||||
return displayText;
|
||||
}
|
||||
|
||||
// Area is the same for all series
|
||||
const { area, SOPInstanceUID, frameNumber, areaUnit } = mappedAnnotations[0];
|
||||
@@ -182,17 +192,15 @@ function getDisplayText(mappedAnnotations, displaySet, customizationService) {
|
||||
const frameText = displaySet.isMultiFrame ? ` F: ${frameNumber}` : '';
|
||||
|
||||
const roundedArea = utils.roundNumber(area, 2);
|
||||
displayText.push(`${roundedArea} ${getDisplayUnit(areaUnit)}`);
|
||||
displayText.primary.push(`${roundedArea} ${getDisplayUnit(areaUnit)}`);
|
||||
|
||||
// Todo: we need a better UI for displaying all these information
|
||||
mappedAnnotations.forEach(mappedAnnotation => {
|
||||
const { unit, max, SeriesNumber } = mappedAnnotation;
|
||||
|
||||
const maxStr = getStatisticDisplayString(max, unit, 'max');
|
||||
const str = `${maxStr}(S:${SeriesNumber}${instanceText}${frameText})`;
|
||||
if (!displayText.includes(str)) {
|
||||
displayText.push(str);
|
||||
}
|
||||
displayText.primary.push(maxStr);
|
||||
displayText.secondary.push(`S: ${SeriesNumber}${instanceText}${frameText}`);
|
||||
});
|
||||
|
||||
return displayText;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import SUPPORTED_TOOLS from './constants/supportedTools';
|
||||
import { getIsLocked } from './utils/getIsLocked';
|
||||
import { getIsVisible } from './utils/getIsVisible';
|
||||
import getSOPInstanceAttributes from './utils/getSOPInstanceAttributes';
|
||||
import { utils } from '@ohif/core';
|
||||
import { config } from '@cornerstonejs/tools/annotation';
|
||||
|
||||
const Length = {
|
||||
toAnnotation: measurement => {},
|
||||
@@ -18,9 +21,17 @@ const Length = {
|
||||
getValueTypeFromToolType,
|
||||
customizationService
|
||||
) => {
|
||||
const { annotation, viewportId } = csToolsEventDetail;
|
||||
const { annotation } = csToolsEventDetail;
|
||||
const { metadata, data, annotationUID } = annotation;
|
||||
|
||||
const isLocked = getIsLocked(annotationUID);
|
||||
const isVisible = getIsVisible(annotationUID);
|
||||
const colorString = config.style.getStyleProperty('color', { annotationUID });
|
||||
|
||||
// color string is like 'rgb(255, 255, 255)' we need them to be in RGBA array [255, 255, 255, 255]
|
||||
// Todo: this should be in a utility
|
||||
// const color = colorString.replace('rgb(', '').replace(')', '').split(',').map(Number);
|
||||
|
||||
if (!metadata || !data) {
|
||||
console.warn('Length tool: Missing metadata or data');
|
||||
return null;
|
||||
@@ -54,7 +65,7 @@ const Length = {
|
||||
|
||||
const mappedAnnotations = getMappedAnnotations(annotation, displaySetService);
|
||||
|
||||
const displayText = getDisplayText(mappedAnnotations, displaySet, customizationService);
|
||||
const displayText = getDisplayText(mappedAnnotations, displaySet);
|
||||
const getReport = () =>
|
||||
_getReport(mappedAnnotations, points, FrameOfReferenceUID, customizationService);
|
||||
|
||||
@@ -64,7 +75,10 @@ const Length = {
|
||||
FrameOfReferenceUID,
|
||||
points,
|
||||
textBox,
|
||||
isLocked,
|
||||
isVisible,
|
||||
metadata,
|
||||
// color,
|
||||
referenceSeriesUID: SeriesInstanceUID,
|
||||
referenceStudyUID: StudyInstanceUID,
|
||||
referencedImageId,
|
||||
@@ -158,14 +172,17 @@ function _getReport(mappedAnnotations, points, FrameOfReferenceUID, customizatio
|
||||
};
|
||||
}
|
||||
|
||||
function getDisplayText(mappedAnnotations, displaySet, customizationService) {
|
||||
function getDisplayText(mappedAnnotations, displaySet) {
|
||||
const displayText = {
|
||||
primary: [],
|
||||
secondary: [],
|
||||
};
|
||||
|
||||
if (!mappedAnnotations || !mappedAnnotations.length) {
|
||||
return '';
|
||||
return displayText;
|
||||
}
|
||||
|
||||
const displayText = [];
|
||||
|
||||
// Area is the same for all series
|
||||
// Length is the same for all series
|
||||
const { length, SeriesNumber, SOPInstanceUID, frameNumber, unit } = mappedAnnotations[0];
|
||||
|
||||
const instance = displaySet.instances.find(image => image.SOPInstanceUID === SOPInstanceUID);
|
||||
@@ -182,7 +199,8 @@ function getDisplayText(mappedAnnotations, displaySet, customizationService) {
|
||||
return displayText;
|
||||
}
|
||||
const roundedLength = utils.roundNumber(length, 2);
|
||||
displayText.push(`${roundedLength} ${unit} (S: ${SeriesNumber}${instanceText}${frameText})`);
|
||||
displayText.primary.push(`${roundedLength} ${unit}`);
|
||||
displayText.secondary.push(`S: ${SeriesNumber}${instanceText}${frameText}`);
|
||||
|
||||
return displayText;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@ import SUPPORTED_TOOLS from './constants/supportedTools';
|
||||
import getSOPInstanceAttributes from './utils/getSOPInstanceAttributes';
|
||||
import { getDisplayUnit } from './utils';
|
||||
import { utils } from '@ohif/core';
|
||||
|
||||
import { getIsLocked } from './utils/getIsLocked';
|
||||
import { getIsVisible } from './utils/getIsVisible';
|
||||
/**
|
||||
* Represents a mapping utility for Livewire measurements.
|
||||
*/
|
||||
@@ -28,6 +29,8 @@ const LivewireContour = {
|
||||
const { annotation } = csToolsEventDetail;
|
||||
const { metadata, data, annotationUID } = annotation;
|
||||
|
||||
const isLocked = getIsLocked(annotationUID);
|
||||
const isVisible = getIsVisible(annotationUID);
|
||||
if (!metadata || !data) {
|
||||
console.warn('Livewire tool: Missing metadata or data');
|
||||
return null;
|
||||
@@ -65,7 +68,9 @@ const LivewireContour = {
|
||||
toolName: metadata.toolName,
|
||||
displaySetInstanceUID: displaySet.displaySetInstanceUID,
|
||||
label: data.label,
|
||||
displayText: getDisplayText(annotation, displaySet, customizationService),
|
||||
isLocked,
|
||||
isVisible,
|
||||
displayText: getDisplayText(annotation, displaySet),
|
||||
data: data.cachedStats,
|
||||
type: getValueTypeFromToolType(toolName),
|
||||
getReport: () => getColumnValueReport(annotation, customizationService),
|
||||
@@ -119,7 +124,7 @@ function getColumnValueReport(annotation, customizationService) {
|
||||
* @param {Object} displaySet - The display set object.
|
||||
* @returns {string[]} - An array of display text.
|
||||
*/
|
||||
function getDisplayText(annotation, displaySet, customizationService) {
|
||||
function getDisplayText(annotation, displaySet) {
|
||||
const { metadata, data } = annotation;
|
||||
|
||||
if (!data.cachedStats || !data.cachedStats[`imageId:${metadata.referencedImageId}`]) {
|
||||
@@ -142,19 +147,26 @@ function getDisplayText(annotation, displaySet, customizationService) {
|
||||
const frameText = displaySet.isMultiFrame ? ` F: ${frameNumber}` : '';
|
||||
|
||||
const { SeriesNumber } = displaySet;
|
||||
let seriesText = null;
|
||||
if (SeriesNumber !== undefined) {
|
||||
displayText.push(`S: ${SeriesNumber}${instanceText}${frameText}`);
|
||||
seriesText = `S: ${SeriesNumber}${instanceText}${frameText}`;
|
||||
}
|
||||
|
||||
const texts = [];
|
||||
if (area) {
|
||||
/**
|
||||
* Add Area
|
||||
* Area sometimes becomes undefined if `preventHandleOutsideImage` is off
|
||||
*/
|
||||
const roundedArea = utils.roundNumber(area || 0, 2);
|
||||
displayText.push(`${roundedArea} ${getDisplayUnit(areaUnit)}`);
|
||||
texts.push(`${roundedArea} ${getDisplayUnit(areaUnit)}`);
|
||||
}
|
||||
|
||||
if (seriesText) {
|
||||
texts.push(seriesText);
|
||||
}
|
||||
|
||||
displayText.push({
|
||||
text: texts,
|
||||
series: seriesText,
|
||||
});
|
||||
|
||||
return displayText;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import SUPPORTED_TOOLS from './constants/supportedTools';
|
||||
import getSOPInstanceAttributes from './utils/getSOPInstanceAttributes';
|
||||
import { utils } from '@ohif/core';
|
||||
|
||||
import { getIsLocked } from './utils/getIsLocked';
|
||||
import { getIsVisible } from './utils/getIsVisible';
|
||||
import { getDisplayUnit } from './utils';
|
||||
import { getStatisticDisplayString } from './utils/getValueDisplayString';
|
||||
/**
|
||||
* Represents a mapping utility for Planar Freehand ROI measurements.
|
||||
*/
|
||||
@@ -12,10 +15,11 @@ const PlanarFreehandROI = {
|
||||
* Maps cornerstone annotation event data to measurement service format.
|
||||
*
|
||||
* @param {Object} csToolsEventDetail Cornerstone event data
|
||||
* @param {DisplaySetService} DisplaySetService Service for managing display sets
|
||||
* @param {DisplaySetService} displaySetService Service for managing display sets
|
||||
* @param {CornerstoneViewportService} CornerstoneViewportService Service for managing viewports
|
||||
* @param {Function} getValueTypeFromToolType Function to get value type from tool type
|
||||
* @returns {Measurement} Measurement instance
|
||||
* @param {CustomizationService} customizationService Service for customization
|
||||
* @returns {Measurement | null} Measurement instance or null if invalid
|
||||
*/
|
||||
toMeasurement: (
|
||||
csToolsEventDetail,
|
||||
@@ -27,8 +31,10 @@ const PlanarFreehandROI = {
|
||||
const { annotation } = csToolsEventDetail;
|
||||
const { metadata, data, annotationUID } = annotation;
|
||||
|
||||
const isLocked = getIsLocked(annotationUID);
|
||||
const isVisible = getIsVisible(annotationUID);
|
||||
if (!metadata || !data) {
|
||||
console.warn('PlanarFreehandROI tool: Missing metadata or data');
|
||||
console.debug('PlanarFreehandROI tool: Missing metadata or data');
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -51,6 +57,9 @@ const PlanarFreehandROI = {
|
||||
displaySet = displaySetService.getDisplaySetsForSeries(SeriesInstanceUID)[0];
|
||||
}
|
||||
|
||||
const mappedAnnotations = getMappedAnnotations(annotation, displaySetService);
|
||||
const displayText = getDisplayText(mappedAnnotations, displaySet);
|
||||
|
||||
return {
|
||||
uid: annotationUID,
|
||||
SOPInstanceUID,
|
||||
@@ -65,21 +74,72 @@ const PlanarFreehandROI = {
|
||||
toolName: metadata.toolName,
|
||||
displaySetInstanceUID: displaySet.displaySetInstanceUID,
|
||||
label: data.label,
|
||||
displayText: getDisplayText(annotation, displaySet, customizationService, displaySetService),
|
||||
displayText: displayText,
|
||||
data: data.cachedStats,
|
||||
type: getValueTypeFromToolType(toolName),
|
||||
getReport: () => getColumnValueReport(annotation, customizationService),
|
||||
isLocked,
|
||||
isVisible,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* This function is used to convert the measurement data to a
|
||||
* format that is suitable for report generation (e.g. for the csv report).
|
||||
* The report returns a list of columns and corresponding values.
|
||||
* Maps annotations to a structured format with relevant attributes.
|
||||
*
|
||||
* @param {object} annotation
|
||||
* @returns {object} Report's content from this tool
|
||||
* @param {Object} annotation The annotation object.
|
||||
* @param {DisplaySetService} displaySetService Service for managing display sets.
|
||||
* @returns {Array} Mapped annotations.
|
||||
*/
|
||||
function getMappedAnnotations(annotation, displaySetService) {
|
||||
const { metadata, data } = annotation;
|
||||
const { cachedStats } = data;
|
||||
const { referencedImageId } = metadata;
|
||||
const targets = Object.keys(cachedStats);
|
||||
|
||||
if (!targets.length) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const annotations = [];
|
||||
Object.keys(cachedStats).forEach(targetId => {
|
||||
const targetStats = cachedStats[targetId];
|
||||
|
||||
const { SOPInstanceUID, SeriesInstanceUID, frameNumber } = getSOPInstanceAttributes(
|
||||
referencedImageId,
|
||||
displaySetService,
|
||||
annotation
|
||||
);
|
||||
|
||||
const displaySet = displaySetService.getDisplaySetsForSeries(SeriesInstanceUID)[0];
|
||||
|
||||
const { SeriesNumber } = displaySet;
|
||||
const { mean, stdDev, max, area, Modality, areaUnit, modalityUnit } = targetStats;
|
||||
|
||||
annotations.push({
|
||||
SeriesInstanceUID,
|
||||
SOPInstanceUID,
|
||||
SeriesNumber,
|
||||
frameNumber,
|
||||
Modality,
|
||||
unit: modalityUnit,
|
||||
mean,
|
||||
stdDev,
|
||||
max,
|
||||
area,
|
||||
areaUnit,
|
||||
});
|
||||
});
|
||||
|
||||
return annotations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the measurement data to a format suitable for report generation.
|
||||
*
|
||||
* @param {object} annotation The annotation object.
|
||||
* @param {CustomizationService} customizationService Service for customization.
|
||||
* @returns {object} Report's content.
|
||||
*/
|
||||
function getColumnValueReport(annotation, customizationService) {
|
||||
const { PlanarFreehandROI } = customizationService.get('cornerstone.measurements');
|
||||
@@ -118,28 +178,25 @@ function getColumnValueReport(annotation, customizationService) {
|
||||
/**
|
||||
* Retrieves the display text for an annotation in a display set.
|
||||
*
|
||||
* @param {Object} annotation - The annotation object.
|
||||
* @param {Object} displaySet - The display set object.
|
||||
* @returns {string[]} - An array of display text.
|
||||
* @param {Array} mappedAnnotations The mapped annotations.
|
||||
* @param {Object} displaySet The display set object.
|
||||
* @returns {Object} Display text with primary and secondary information.
|
||||
*/
|
||||
function getDisplayText(annotation, displaySet, customizationService, displaySetService) {
|
||||
const { PlanarFreehandROI } = customizationService.get('cornerstone.measurements');
|
||||
const { displayText: displayTextClosed, displayTextOpen } = PlanarFreehandROI;
|
||||
function getDisplayText(mappedAnnotations, displaySet) {
|
||||
const displayText = {
|
||||
primary: [],
|
||||
secondary: [],
|
||||
};
|
||||
|
||||
const { metadata, data } = annotation;
|
||||
if (!mappedAnnotations || !mappedAnnotations.length) {
|
||||
return displayText;
|
||||
}
|
||||
|
||||
const isClosed = data.contour?.closed;
|
||||
const displayText = isClosed ? displayTextClosed : displayTextOpen;
|
||||
|
||||
const { SOPInstanceUID, frameNumber } = getSOPInstanceAttributes(
|
||||
metadata.referencedImageId,
|
||||
displaySetService,
|
||||
annotation
|
||||
);
|
||||
|
||||
const displayTextArray = [];
|
||||
// Area is the same for all series
|
||||
const { area, SOPInstanceUID, frameNumber, areaUnit } = mappedAnnotations[0];
|
||||
|
||||
const instance = displaySet.instances.find(image => image.SOPInstanceUID === SOPInstanceUID);
|
||||
|
||||
let InstanceNumber;
|
||||
if (instance) {
|
||||
InstanceNumber = instance.InstanceNumber;
|
||||
@@ -148,47 +205,19 @@ function getDisplayText(annotation, displaySet, customizationService, displaySet
|
||||
const instanceText = InstanceNumber ? ` I: ${InstanceNumber}` : '';
|
||||
const frameText = displaySet.isMultiFrame ? ` F: ${frameNumber}` : '';
|
||||
|
||||
const { SeriesNumber } = displaySet;
|
||||
if (SeriesNumber !== undefined) {
|
||||
displayTextArray.push(`S: ${SeriesNumber}${instanceText}${frameText}`);
|
||||
}
|
||||
const roundedArea = utils.roundNumber(area || 0, 2);
|
||||
displayText.primary.push(`${roundedArea} ${getDisplayUnit(areaUnit)}`);
|
||||
|
||||
const stats =
|
||||
data.cachedStats[`imageId:${metadata.referencedImageId}`] ||
|
||||
Array.from(Object.values(data.cachedStats))[0];
|
||||
mappedAnnotations.forEach(mappedAnnotation => {
|
||||
const { unit, max, SeriesNumber } = mappedAnnotation;
|
||||
|
||||
if (!stats) {
|
||||
return displayTextArray;
|
||||
}
|
||||
const maxStr = getStatisticDisplayString(max, unit, 'max');
|
||||
|
||||
const roundValues = values => {
|
||||
if (Array.isArray(values)) {
|
||||
return values.map(value => {
|
||||
if (isNaN(value)) {
|
||||
return value;
|
||||
}
|
||||
return utils.roundNumber(value, 2);
|
||||
});
|
||||
}
|
||||
return isNaN(values) ? [values] : [utils.roundNumber(values, 2)];
|
||||
};
|
||||
|
||||
const findUnitForValue = (displayTextItems, value) =>
|
||||
displayTextItems.find(({ type, for: filter }) => type === 'unit' && filter.includes(value))
|
||||
?.value;
|
||||
|
||||
const formatDisplayText = (displayName, result, unit) =>
|
||||
`${displayName}: ${roundValues(result).join(', ')} ${unit}`;
|
||||
|
||||
displayText.forEach(({ displayName, value, type }) => {
|
||||
if (type === 'value') {
|
||||
const result = stats[value];
|
||||
const unit = stats[findUnitForValue(displayText, value)] || '';
|
||||
displayTextArray.push(formatDisplayText(displayName, result, unit));
|
||||
}
|
||||
displayText.primary.push(maxStr);
|
||||
displayText.secondary.push(`S: ${SeriesNumber}${instanceText}${frameText}`);
|
||||
});
|
||||
|
||||
return displayTextArray;
|
||||
return displayText;
|
||||
}
|
||||
|
||||
export default PlanarFreehandROI;
|
||||
@@ -2,7 +2,8 @@ import SUPPORTED_TOOLS from './constants/supportedTools';
|
||||
import { getDisplayUnit } from './utils';
|
||||
import getSOPInstanceAttributes from './utils/getSOPInstanceAttributes';
|
||||
import { utils } from '@ohif/core';
|
||||
|
||||
import { getIsLocked } from './utils/getIsLocked';
|
||||
import { getIsVisible } from './utils/getIsVisible';
|
||||
const Probe = {
|
||||
toAnnotation: measurement => {},
|
||||
|
||||
@@ -21,7 +22,8 @@ const Probe = {
|
||||
) => {
|
||||
const { annotation } = csToolsEventDetail;
|
||||
const { metadata, data, annotationUID } = annotation;
|
||||
|
||||
const isLocked = getIsLocked(annotationUID);
|
||||
const isVisible = getIsVisible(annotationUID);
|
||||
if (!metadata || !data) {
|
||||
console.warn('Probe tool: Missing metadata or data');
|
||||
return null;
|
||||
@@ -65,6 +67,8 @@ const Probe = {
|
||||
FrameOfReferenceUID,
|
||||
points,
|
||||
metadata,
|
||||
isLocked,
|
||||
isVisible,
|
||||
referenceSeriesUID: SeriesInstanceUID,
|
||||
referenceStudyUID: StudyInstanceUID,
|
||||
referencedImageId,
|
||||
@@ -155,11 +159,14 @@ function _getReport(mappedAnnotations, points, FrameOfReferenceUID, customizatio
|
||||
}
|
||||
|
||||
function getDisplayText(mappedAnnotations, displaySet, customizationService) {
|
||||
if (!mappedAnnotations || !mappedAnnotations.length) {
|
||||
return '';
|
||||
}
|
||||
const displayText = {
|
||||
primary: [],
|
||||
secondary: [],
|
||||
};
|
||||
|
||||
const displayText = [];
|
||||
if (!mappedAnnotations || !mappedAnnotations.length) {
|
||||
return displayText;
|
||||
}
|
||||
|
||||
const { value, unit, SeriesNumber, SOPInstanceUID, frameNumber } = mappedAnnotations[0];
|
||||
|
||||
@@ -172,13 +179,12 @@ function getDisplayText(mappedAnnotations, displaySet, customizationService) {
|
||||
|
||||
const instanceText = InstanceNumber ? ` I: ${InstanceNumber}` : '';
|
||||
const frameText = displaySet.isMultiFrame ? ` F: ${frameNumber}` : '';
|
||||
if (value === undefined) {
|
||||
return displayText;
|
||||
|
||||
if (value !== undefined) {
|
||||
const roundedValue = utils.roundNumber(value, 2);
|
||||
displayText.primary.push(`${roundedValue} ${getDisplayUnit(unit)}`);
|
||||
displayText.secondary.push(`S: ${SeriesNumber}${instanceText}${frameText}`);
|
||||
}
|
||||
const roundedValue = utils.roundNumber(value, 2);
|
||||
displayText.push(
|
||||
`${roundedValue} ${getDisplayUnit(unit)} (S: ${SeriesNumber}${instanceText}${frameText})`
|
||||
);
|
||||
|
||||
return displayText;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ import { getDisplayUnit } from './utils';
|
||||
import getSOPInstanceAttributes from './utils/getSOPInstanceAttributes';
|
||||
import { utils } from '@ohif/core';
|
||||
import { getStatisticDisplayString } from './utils/getValueDisplayString';
|
||||
import { getIsLocked } from './utils/getIsLocked';
|
||||
import { getIsVisible } from './utils/getIsVisible';
|
||||
|
||||
const RectangleROI = {
|
||||
toAnnotation: measurement => {},
|
||||
@@ -13,8 +15,10 @@ const RectangleROI = {
|
||||
getValueTypeFromToolType,
|
||||
customizationService
|
||||
) => {
|
||||
const { annotation, viewportId } = csToolsEventDetail;
|
||||
const { annotation } = csToolsEventDetail;
|
||||
const { metadata, data, annotationUID } = annotation;
|
||||
const isLocked = getIsLocked(annotationUID);
|
||||
const isVisible = getIsVisible(annotationUID);
|
||||
|
||||
if (!metadata || !data) {
|
||||
console.warn('Rectangle ROI tool: Missing metadata or data');
|
||||
@@ -71,6 +75,8 @@ const RectangleROI = {
|
||||
data: data.cachedStats,
|
||||
type: getValueTypeFromToolType(toolName),
|
||||
getReport,
|
||||
isLocked,
|
||||
isVisible,
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -163,11 +169,14 @@ function _getReport(mappedAnnotations, points, FrameOfReferenceUID, customizatio
|
||||
}
|
||||
|
||||
function getDisplayText(mappedAnnotations, displaySet, customizationService) {
|
||||
if (!mappedAnnotations || !mappedAnnotations.length) {
|
||||
return '';
|
||||
}
|
||||
const displayText = {
|
||||
primary: [],
|
||||
secondary: [],
|
||||
};
|
||||
|
||||
const displayText = [];
|
||||
if (!mappedAnnotations || !mappedAnnotations.length) {
|
||||
return displayText;
|
||||
}
|
||||
|
||||
// Area is the same for all series
|
||||
const { area, SOPInstanceUID, frameNumber, areaUnit } = mappedAnnotations[0];
|
||||
@@ -184,7 +193,7 @@ function getDisplayText(mappedAnnotations, displaySet, customizationService) {
|
||||
|
||||
// Area sometimes becomes undefined if `preventHandleOutsideImage` is off.
|
||||
const roundedArea = utils.roundNumber(area || 0, 2);
|
||||
displayText.push(`${roundedArea} ${getDisplayUnit(areaUnit)}`);
|
||||
displayText.primary.push(`${roundedArea} ${getDisplayUnit(areaUnit)}`);
|
||||
|
||||
// Todo: we need a better UI for displaying all these information
|
||||
mappedAnnotations.forEach(mappedAnnotation => {
|
||||
@@ -192,10 +201,8 @@ function getDisplayText(mappedAnnotations, displaySet, customizationService) {
|
||||
|
||||
const maxStr = getStatisticDisplayString(max, unit, 'max');
|
||||
|
||||
const str = `${maxStr}(S:${SeriesNumber}${instanceText}${frameText})`;
|
||||
if (!displayText.includes(str)) {
|
||||
displayText.push(str);
|
||||
}
|
||||
displayText.primary.push(maxStr);
|
||||
displayText.secondary.push(`S: ${SeriesNumber}${instanceText}${frameText}`);
|
||||
});
|
||||
|
||||
return displayText;
|
||||
|
||||
@@ -1,25 +1,32 @@
|
||||
import SUPPORTED_TOOLS from './constants/supportedTools';
|
||||
import getSOPInstanceAttributes from './utils/getSOPInstanceAttributes';
|
||||
import { utils } from '@ohif/core';
|
||||
import { getIsLocked } from './utils/getIsLocked';
|
||||
import { getIsVisible } from './utils/getIsVisible';
|
||||
import { getDisplayUnit } from './utils';
|
||||
import { getStatisticDisplayString } from './utils/getValueDisplayString';
|
||||
|
||||
/**
|
||||
* Represents a mapping utility for Spline ROI measurements.
|
||||
*/
|
||||
const SplineROI = {
|
||||
toAnnotation: measurement => {},
|
||||
toAnnotation: measurement => {
|
||||
// Implementation for converting measurement to annotation
|
||||
},
|
||||
|
||||
/**
|
||||
* Maps cornerstone annotation event data to measurement service format.
|
||||
*
|
||||
* @param {Object} csToolsEventDetail Cornerstone event data
|
||||
* @param {DisplaySetService} DisplaySetService Service for managing display sets
|
||||
* @param {CornerstoneViewportService} CornerstoneViewportService Service for managing viewports
|
||||
* @param {Function} getValueTypeFromToolType Function to get value type from tool type
|
||||
* @returns {Measurement} Measurement instance
|
||||
* @param {Object} csToolsEventDetail - Cornerstone event data
|
||||
* @param {DisplaySetService} displaySetService - Service for managing display sets
|
||||
* @param {CornerstoneViewportService} CornerstoneViewportService - Service for managing viewports
|
||||
* @param {Function} getValueTypeFromToolType - Function to get value type from tool type
|
||||
* @param {CustomizationService} customizationService - Service for customization
|
||||
* @returns {Measurement | null} Measurement instance or null if invalid
|
||||
*/
|
||||
toMeasurement: (
|
||||
csToolsEventDetail,
|
||||
DisplaySetService,
|
||||
displaySetService,
|
||||
CornerstoneViewportService,
|
||||
getValueTypeFromToolType,
|
||||
customizationService
|
||||
@@ -27,6 +34,8 @@ const SplineROI = {
|
||||
const { annotation } = csToolsEventDetail;
|
||||
const { metadata, data, annotationUID } = annotation;
|
||||
|
||||
const isLocked = getIsLocked(annotationUID);
|
||||
const isVisible = getIsVisible(annotationUID);
|
||||
if (!metadata || !data) {
|
||||
console.warn('SplineROI tool: Missing metadata or data');
|
||||
return null;
|
||||
@@ -39,18 +48,21 @@ const SplineROI = {
|
||||
}
|
||||
|
||||
const { SOPInstanceUID, SeriesInstanceUID, frameNumber, StudyInstanceUID } =
|
||||
getSOPInstanceAttributes(referencedImageId);
|
||||
getSOPInstanceAttributes(referencedImageId, displaySetService, annotation);
|
||||
|
||||
let displaySet;
|
||||
if (SOPInstanceUID) {
|
||||
displaySet = DisplaySetService.getDisplaySetForSOPInstanceUID(
|
||||
displaySet = displaySetService.getDisplaySetForSOPInstanceUID(
|
||||
SOPInstanceUID,
|
||||
SeriesInstanceUID
|
||||
);
|
||||
} else {
|
||||
displaySet = DisplaySetService.getDisplaySetsForSeries(SeriesInstanceUID);
|
||||
displaySet = displaySetService.getDisplaySetsForSeries(SeriesInstanceUID)[0];
|
||||
}
|
||||
|
||||
const mappedAnnotations = getMappedAnnotations(annotation, displaySetService);
|
||||
const displayText = getDisplayText(mappedAnnotations, displaySet);
|
||||
|
||||
return {
|
||||
uid: annotationUID,
|
||||
SOPInstanceUID,
|
||||
@@ -61,24 +73,76 @@ const SplineROI = {
|
||||
frameNumber,
|
||||
referenceSeriesUID: SeriesInstanceUID,
|
||||
referenceStudyUID: StudyInstanceUID,
|
||||
referencedImageId,
|
||||
toolName: metadata.toolName,
|
||||
displaySetInstanceUID: displaySet.displaySetInstanceUID,
|
||||
label: data.label,
|
||||
displayText: getDisplayText(annotation, displaySet, customizationService),
|
||||
displayText: displayText,
|
||||
data: data.cachedStats,
|
||||
type: getValueTypeFromToolType(toolName),
|
||||
getReport: () => getColumnValueReport(annotation, customizationService),
|
||||
isLocked,
|
||||
isVisible,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* This function is used to convert the measurement data to a
|
||||
* format that is suitable for report generation (e.g. for the csv report).
|
||||
* The report returns a list of columns and corresponding values.
|
||||
* Maps annotations to a structured format with relevant attributes.
|
||||
*
|
||||
* @param {object} annotation
|
||||
* @returns {object} Report's content from this tool
|
||||
* @param {Object} annotation - The annotation object.
|
||||
* @param {DisplaySetService} displaySetService - Service for managing display sets.
|
||||
* @returns {Array} Mapped annotations.
|
||||
*/
|
||||
function getMappedAnnotations(annotation, displaySetService) {
|
||||
const { metadata, data } = annotation;
|
||||
const { cachedStats } = data;
|
||||
const { referencedImageId } = metadata;
|
||||
const targets = Object.keys(cachedStats);
|
||||
|
||||
if (!targets.length) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const annotations = [];
|
||||
Object.keys(cachedStats).forEach(targetId => {
|
||||
const targetStats = cachedStats[targetId];
|
||||
|
||||
const { SOPInstanceUID, SeriesInstanceUID, frameNumber } = getSOPInstanceAttributes(
|
||||
referencedImageId,
|
||||
displaySetService,
|
||||
annotation
|
||||
);
|
||||
|
||||
const displaySet = displaySetService.getDisplaySetsForSeries(SeriesInstanceUID)[0];
|
||||
|
||||
const { SeriesNumber } = displaySet;
|
||||
const { mean, stdDev, max, area, Modality, areaUnit, modalityUnit } = targetStats;
|
||||
|
||||
annotations.push({
|
||||
SeriesInstanceUID,
|
||||
SOPInstanceUID,
|
||||
SeriesNumber,
|
||||
frameNumber,
|
||||
Modality,
|
||||
unit: modalityUnit,
|
||||
mean,
|
||||
stdDev,
|
||||
max,
|
||||
area,
|
||||
areaUnit,
|
||||
});
|
||||
});
|
||||
|
||||
return annotations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the measurement data to a format suitable for report generation.
|
||||
*
|
||||
* @param {object} annotation - The annotation object.
|
||||
* @param {CustomizationService} customizationService - Service for customization.
|
||||
* @returns {object} Report's content.
|
||||
*/
|
||||
function getColumnValueReport(annotation, customizationService) {
|
||||
const { SplineROI } = customizationService.get('cornerstone.measurements');
|
||||
@@ -107,11 +171,6 @@ function getColumnValueReport(annotation, customizationService) {
|
||||
|
||||
/** Add points */
|
||||
if (data.contour.polyline) {
|
||||
/**
|
||||
* Points has the form of [[x1, y1, z1], [x2, y2, z2], ...]
|
||||
* convert it to string of [[x1 y1 z1];[x2 y2 z2];...]
|
||||
* so that it can be used in the CSV report
|
||||
*/
|
||||
columns.push('points');
|
||||
values.push(data.contour.polyline.map(p => p.join(' ')).join(';'));
|
||||
}
|
||||
@@ -122,23 +181,25 @@ function getColumnValueReport(annotation, customizationService) {
|
||||
/**
|
||||
* Retrieves the display text for an annotation in a display set.
|
||||
*
|
||||
* @param {Object} annotation - The annotation object.
|
||||
* @param {Array} mappedAnnotations - The mapped annotations.
|
||||
* @param {Object} displaySet - The display set object.
|
||||
* @returns {string[]} - An array of display text.
|
||||
* @returns {Object} Display text with primary and secondary information.
|
||||
*/
|
||||
function getDisplayText(annotation, displaySet, customizationService) {
|
||||
const { SplineROI } = customizationService.get('cornerstone.measurements');
|
||||
const { displayText } = SplineROI;
|
||||
const { metadata, data } = annotation;
|
||||
function getDisplayText(mappedAnnotations, displaySet) {
|
||||
const displayText = {
|
||||
primary: [],
|
||||
secondary: [],
|
||||
};
|
||||
|
||||
if (!data.cachedStats || !data.cachedStats[`imageId:${metadata.referencedImageId}`]) {
|
||||
return [];
|
||||
if (!mappedAnnotations || !mappedAnnotations.length) {
|
||||
return displayText;
|
||||
}
|
||||
const { SOPInstanceUID, frameNumber } = getSOPInstanceAttributes(metadata.referencedImageId);
|
||||
|
||||
const displayTextArray = [];
|
||||
// Area is the same for all series
|
||||
const { area, SOPInstanceUID, frameNumber, areaUnit } = mappedAnnotations[0];
|
||||
|
||||
const instance = displaySet.instances.find(image => image.SOPInstanceUID === SOPInstanceUID);
|
||||
|
||||
let InstanceNumber;
|
||||
if (instance) {
|
||||
InstanceNumber = instance.InstanceNumber;
|
||||
@@ -147,41 +208,20 @@ function getDisplayText(annotation, displaySet, customizationService) {
|
||||
const instanceText = InstanceNumber ? ` I: ${InstanceNumber}` : '';
|
||||
const frameText = displaySet.isMultiFrame ? ` F: ${frameNumber}` : '';
|
||||
|
||||
const { SeriesNumber } = displaySet;
|
||||
if (SeriesNumber !== undefined) {
|
||||
displayTextArray.push(`S: ${SeriesNumber}${instanceText}${frameText}`);
|
||||
}
|
||||
const roundedArea = utils.roundNumber(area || 0, 2);
|
||||
displayText.primary.push(`${roundedArea} ${getDisplayUnit(areaUnit)}`);
|
||||
|
||||
const stats = data.cachedStats[`imageId:${metadata.referencedImageId}`];
|
||||
// we don't have max yet for splines rois
|
||||
// mappedAnnotations.forEach(mappedAnnotation => {
|
||||
// const { unit, max, SeriesNumber } = mappedAnnotation;
|
||||
|
||||
const roundValues = values => {
|
||||
if (Array.isArray(values)) {
|
||||
return values.map(value => {
|
||||
if (isNaN(value)) {
|
||||
return value;
|
||||
}
|
||||
return utils.roundNumber(value);
|
||||
});
|
||||
}
|
||||
return isNaN(values) ? values : utils.roundNumber(values);
|
||||
};
|
||||
// const maxStr = getStatisticDisplayString(max, unit, 'max');
|
||||
|
||||
const findUnitForValue = (displayTextItems, value) =>
|
||||
displayTextItems.find(({ type, for: filter }) => type === 'unit' && filter.includes(value))
|
||||
?.value;
|
||||
// displayText.primary.push(maxStr);
|
||||
// displayText.secondary.push(`S: ${SeriesNumber}${instanceText}${frameText}`);
|
||||
// });
|
||||
|
||||
const formatDisplayText = (displayName, result, unit) =>
|
||||
`${displayName}: ${Array.isArray(result) ? roundValues(result).join(', ') : roundValues(result)} ${unit}`;
|
||||
|
||||
displayText.forEach(({ displayName, value, type }) => {
|
||||
if (type === 'value') {
|
||||
const result = stats[value];
|
||||
const unit = stats[findUnitForValue(displayText, value)] || '';
|
||||
displayTextArray.push(formatDisplayText(displayName, result, unit));
|
||||
}
|
||||
});
|
||||
|
||||
return displayTextArray;
|
||||
return displayText;
|
||||
}
|
||||
|
||||
export default SplineROI;
|
||||
+20
-12
@@ -1,8 +1,8 @@
|
||||
import SUPPORTED_TOOLS from './constants/supportedTools';
|
||||
import { getDisplayUnit } from './utils';
|
||||
import getSOPInstanceAttributes from './utils/getSOPInstanceAttributes';
|
||||
import { utils } from '@ohif/core';
|
||||
|
||||
import { getIsLocked } from './utils/getIsLocked';
|
||||
import { getIsVisible } from './utils/getIsVisible';
|
||||
const UltrasoundDirectional = {
|
||||
toAnnotation: measurement => {},
|
||||
|
||||
@@ -19,9 +19,10 @@ const UltrasoundDirectional = {
|
||||
getValueTypeFromToolType,
|
||||
customizationService
|
||||
) => {
|
||||
const { annotation, viewportId } = csToolsEventDetail;
|
||||
const { annotation } = csToolsEventDetail;
|
||||
const { metadata, data, annotationUID } = annotation;
|
||||
|
||||
const isLocked = getIsLocked(annotationUID);
|
||||
const isVisible = getIsVisible(annotationUID);
|
||||
if (!metadata || !data) {
|
||||
console.warn('Length tool: Missing metadata or data');
|
||||
return null;
|
||||
@@ -72,6 +73,8 @@ const UltrasoundDirectional = {
|
||||
data: data.cachedStats,
|
||||
type: getValueTypeFromToolType(toolName),
|
||||
getReport,
|
||||
isLocked,
|
||||
isVisible,
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -167,11 +170,14 @@ function _getReport(mappedAnnotations, points, FrameOfReferenceUID, customizatio
|
||||
}
|
||||
|
||||
function getDisplayText(mappedAnnotations, displaySet, customizationService) {
|
||||
if (!mappedAnnotations || !mappedAnnotations.length) {
|
||||
return '';
|
||||
}
|
||||
const displayText = {
|
||||
primary: [],
|
||||
secondary: [],
|
||||
};
|
||||
|
||||
const displayText = [];
|
||||
if (!mappedAnnotations || !mappedAnnotations.length) {
|
||||
return displayText;
|
||||
}
|
||||
|
||||
const { xValues, yValues, units, isUnitless, SeriesNumber, SOPInstanceUID, frameNumber } =
|
||||
mappedAnnotations[0];
|
||||
@@ -185,21 +191,23 @@ function getDisplayText(mappedAnnotations, displaySet, customizationService) {
|
||||
|
||||
const instanceText = InstanceNumber ? ` I: ${InstanceNumber}` : '';
|
||||
const frameText = displaySet.isMultiFrame ? ` F: ${frameNumber}` : '';
|
||||
const seriesText = `(S: ${SeriesNumber}${instanceText}${frameText})`;
|
||||
const seriesText = `S: ${SeriesNumber}${instanceText}${frameText}`;
|
||||
|
||||
if (xValues === undefined || yValues === undefined) {
|
||||
return displayText;
|
||||
}
|
||||
|
||||
if (isUnitless) {
|
||||
displayText.push(`${utils.roundNumber(xValues[0], 2)} ${units[0]} ${seriesText}`);
|
||||
displayText.primary.push(`${utils.roundNumber(xValues[0], 2)} ${units[0]}`);
|
||||
} else {
|
||||
const dist1 = Math.abs(xValues[1] - xValues[0]);
|
||||
const dist2 = Math.abs(yValues[1] - yValues[0]);
|
||||
displayText.push(`${utils.roundNumber(dist1)} ${units[0]} ${seriesText}`);
|
||||
displayText.push(`${utils.roundNumber(dist2)} ${units[1]} ${seriesText}`);
|
||||
displayText.primary.push(`${utils.roundNumber(dist1)} ${units[0]}`);
|
||||
displayText.primary.push(`${utils.roundNumber(dist2)} ${units[1]}`);
|
||||
}
|
||||
|
||||
displayText.secondary.push(seriesText);
|
||||
|
||||
return displayText;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import { locking } from '@cornerstonejs/tools/annotation';
|
||||
|
||||
export const getIsLocked = annotationUID => {
|
||||
return locking.isAnnotationLocked(annotationUID);
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
import { visibility } from '@cornerstonejs/tools/annotation';
|
||||
|
||||
export const getIsVisible = annotationUID => {
|
||||
const isVisible = visibility.isAnnotationVisible(annotationUID);
|
||||
return isVisible;
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
import { usePositionPresentationStore } from '../../stores/usePositionPresentationStore';
|
||||
import { useLutPresentationStore } from '../../stores/useLutPresentationStore';
|
||||
import { useSegmentationPresentationStore } from '../../stores/useSegmentationPresentationStore';
|
||||
|
||||
export function getViewportPresentations(
|
||||
viewportId: string,
|
||||
viewportOptions: AppTypes.ViewportGrid.GridViewportOptions
|
||||
) {
|
||||
const { lutPresentationStore } = useLutPresentationStore.getState();
|
||||
const { positionPresentationStore } = usePositionPresentationStore.getState();
|
||||
const { segmentationPresentationStore } = useSegmentationPresentationStore.getState();
|
||||
|
||||
// NOTE: this is the new viewport state, we should not get the presentationIds from the cornerstoneViewportService
|
||||
// since that has the old viewport state
|
||||
const { presentationIds } = viewportOptions;
|
||||
|
||||
if (!presentationIds) {
|
||||
return {
|
||||
positionPresentation: null,
|
||||
lutPresentation: null,
|
||||
segmentationPresentation: null,
|
||||
};
|
||||
}
|
||||
|
||||
const { lutPresentationId, positionPresentationId, segmentationPresentationId } = presentationIds;
|
||||
|
||||
return {
|
||||
positionPresentation: positionPresentationStore[positionPresentationId],
|
||||
lutPresentation: lutPresentationStore[lutPresentationId],
|
||||
segmentationPresentation: segmentationPresentationStore[segmentationPresentationId],
|
||||
};
|
||||
}
|
||||
+3
-4
@@ -1,7 +1,7 @@
|
||||
import { segmentation } from '@cornerstonejs/tools';
|
||||
|
||||
function removeToolGroupSegmentationRepresentations(toolGroupId) {
|
||||
const representations = segmentation.state.getSegmentationRepresentations(toolGroupId);
|
||||
function removeViewportSegmentationRepresentations(viewportId) {
|
||||
const representations = segmentation.state.getSegmentationRepresentations(viewportId);
|
||||
|
||||
if (!representations || !representations.length) {
|
||||
return;
|
||||
@@ -9,10 +9,9 @@ function removeToolGroupSegmentationRepresentations(toolGroupId) {
|
||||
|
||||
representations.forEach(representation => {
|
||||
segmentation.state.removeSegmentationRepresentation(
|
||||
toolGroupId,
|
||||
representation.segmentationRepresentationUID
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
export default removeToolGroupSegmentationRepresentations;
|
||||
export default removeViewportSegmentationRepresentations;
|
||||
Reference in new issue
Block a user