chore(prettier): full repo linting and code reformatting once and for all (#3627)
This commit is contained in:
1 parent
01500a2d4c
commit
9045ddaedc
656 files changed
+21737
-20628
No files matched your search
@@ -1,8 +1,10 @@
|
||||
{
|
||||
"plugins": ["prettier-plugin-tailwindcss"],
|
||||
"trailingComma": "es5",
|
||||
"printWidth": 80,
|
||||
"printWidth": 100,
|
||||
"proseWrap": "always",
|
||||
"tabWidth": 2,
|
||||
"semi": true,
|
||||
"singleQuote": true
|
||||
"singleQuote": true,
|
||||
"arrowParens": "avoid"
|
||||
}
|
||||
@@ -7,7 +7,6 @@ const ENTRY = {
|
||||
app: `${SRC_DIR}/index.tsx`,
|
||||
};
|
||||
|
||||
|
||||
module.exports = (env, argv) => {
|
||||
return webpackCommon(env, argv, { SRC_DIR, DIST_DIR, ENTRY });
|
||||
};
|
||||
@@ -10,7 +10,7 @@ module.exports = {
|
||||
modules: 'commonjs',
|
||||
debug: false,
|
||||
},
|
||||
"@babel/preset-typescript",
|
||||
'@babel/preset-typescript',
|
||||
],
|
||||
'@babel/preset-react',
|
||||
],
|
||||
@@ -26,7 +26,7 @@ module.exports = {
|
||||
// WebPack handles ES6 --> Target Syntax
|
||||
['@babel/preset-env', { modules: false }],
|
||||
'@babel/preset-react',
|
||||
"@babel/preset-typescript",
|
||||
'@babel/preset-typescript',
|
||||
],
|
||||
ignore: ['**/*.test.jsx', '**/*.test.js', '__snapshots__', '__tests__'],
|
||||
},
|
||||
@@ -35,7 +35,7 @@ module.exports = {
|
||||
// WebPack handles ES6 --> Target Syntax
|
||||
['@babel/preset-env', { modules: false }],
|
||||
'@babel/preset-react',
|
||||
"@babel/preset-typescript",
|
||||
'@babel/preset-typescript',
|
||||
],
|
||||
plugins: ['react-hot-loader/babel'],
|
||||
ignore: ['**/*.test.jsx', '**/*.test.js', '__snapshots__', '__tests__'],
|
||||
|
||||
@@ -17,32 +17,21 @@ function _getReferencedFrameOfReferenceUID(naturalizedDataset) {
|
||||
const { ContentSequence } = naturalizedDataset;
|
||||
|
||||
const imagingMeasurementsContentItem = ContentSequence.find(
|
||||
ci =>
|
||||
ci.ConceptNameCodeSequence.CodeValue ===
|
||||
DCM_CODE_VALUES.IMAGING_MEASUREMENTS
|
||||
ci => ci.ConceptNameCodeSequence.CodeValue === DCM_CODE_VALUES.IMAGING_MEASUREMENTS
|
||||
);
|
||||
|
||||
const firstMeasurementGroupContentItem = toArray(
|
||||
imagingMeasurementsContentItem.ContentSequence
|
||||
).find(
|
||||
ci =>
|
||||
ci.ConceptNameCodeSequence.CodeValue === DCM_CODE_VALUES.MEASUREMENT_GROUP
|
||||
);
|
||||
).find(ci => ci.ConceptNameCodeSequence.CodeValue === DCM_CODE_VALUES.MEASUREMENT_GROUP);
|
||||
|
||||
const imageRegionContentItem = toArray(
|
||||
firstMeasurementGroupContentItem.ContentSequence
|
||||
).find(
|
||||
const imageRegionContentItem = toArray(firstMeasurementGroupContentItem.ContentSequence).find(
|
||||
ci => ci.ConceptNameCodeSequence.CodeValue === DCM_CODE_VALUES.IMAGE_REGION
|
||||
);
|
||||
|
||||
return imageRegionContentItem.ReferencedFrameOfReferenceUID;
|
||||
}
|
||||
|
||||
function _getDisplaySetsFromSeries(
|
||||
instances,
|
||||
servicesManager,
|
||||
extensionManager
|
||||
) {
|
||||
function _getDisplaySetsFromSeries(instances, servicesManager, extensionManager) {
|
||||
// If the series has no instances, stop here
|
||||
if (!instances || !instances.length) {
|
||||
throw new Error('No instances were provided');
|
||||
@@ -58,9 +47,7 @@ function _getDisplaySetsFromSeries(
|
||||
instance.StudyInstanceUID,
|
||||
instance.SeriesInstanceUID
|
||||
).instances[0];
|
||||
const ReferencedFrameOfReferenceUID = _getReferencedFrameOfReferenceUID(
|
||||
naturalizedDataset
|
||||
);
|
||||
const ReferencedFrameOfReferenceUID = _getReferencedFrameOfReferenceUID(naturalizedDataset);
|
||||
|
||||
const {
|
||||
FrameOfReferenceUID,
|
||||
@@ -98,23 +85,19 @@ function _getDisplaySetsFromSeries(
|
||||
loadError: false,
|
||||
};
|
||||
|
||||
displaySet.load = function(referencedDisplaySet) {
|
||||
return loadSR(microscopyService, displaySet, referencedDisplaySet).catch(
|
||||
error => {
|
||||
displaySet.isLoaded = false;
|
||||
displaySet.loadError = true;
|
||||
throw new Error(error);
|
||||
}
|
||||
);
|
||||
displaySet.load = function (referencedDisplaySet) {
|
||||
return loadSR(microscopyService, displaySet, referencedDisplaySet).catch(error => {
|
||||
displaySet.isLoaded = false;
|
||||
displaySet.loadError = true;
|
||||
throw new Error(error);
|
||||
});
|
||||
};
|
||||
|
||||
displaySet.getSourceDisplaySet = function() {
|
||||
displaySet.getSourceDisplaySet = function () {
|
||||
let allDisplaySets = [];
|
||||
const studyMetadata = DicomMetadataStore.getStudy(StudyInstanceUID);
|
||||
studyMetadata.series.forEach(series => {
|
||||
const displaySets = displaySetService.getDisplaySetsForSeries(
|
||||
series.SeriesInstanceUID
|
||||
);
|
||||
const displaySets = displaySetService.getDisplaySetsForSeries(series.SeriesInstanceUID);
|
||||
allDisplaySets = allDisplaySets.concat(displaySets);
|
||||
});
|
||||
return getSourceDisplaySet(allDisplaySets, displaySet);
|
||||
@@ -123,16 +106,9 @@ function _getDisplaySetsFromSeries(
|
||||
return [displaySet];
|
||||
}
|
||||
|
||||
export default function getDicomMicroscopySRSopClassHandler({
|
||||
servicesManager,
|
||||
extensionManager,
|
||||
}) {
|
||||
export default function getDicomMicroscopySRSopClassHandler({ servicesManager, extensionManager }) {
|
||||
const getDisplaySetsFromSeries = instances => {
|
||||
return _getDisplaySetsFromSeries(
|
||||
instances,
|
||||
servicesManager,
|
||||
extensionManager
|
||||
);
|
||||
return _getDisplaySetsFromSeries(instances, servicesManager, extensionManager);
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
@@ -9,11 +9,7 @@ const SOP_CLASS_UIDS = {
|
||||
const SOPClassHandlerId =
|
||||
'@ohif/extension-dicom-microscopy.sopClassHandlerModule.DicomMicroscopySopClassHandler';
|
||||
|
||||
function _getDisplaySetsFromSeries(
|
||||
instances,
|
||||
servicesManager,
|
||||
extensionManager
|
||||
) {
|
||||
function _getDisplaySetsFromSeries(instances, servicesManager, extensionManager) {
|
||||
// If the series has no instances, stop here
|
||||
if (!instances || !instances.length) {
|
||||
throw new Error('No instances were provided');
|
||||
@@ -112,16 +108,9 @@ function _getDisplaySetsFromSeries(
|
||||
return [displaySet];
|
||||
}
|
||||
|
||||
export default function getDicomMicroscopySopClassHandler({
|
||||
servicesManager,
|
||||
extensionManager,
|
||||
}) {
|
||||
export default function getDicomMicroscopySopClassHandler({ servicesManager, extensionManager }) {
|
||||
const getDisplaySetsFromSeries = instances => {
|
||||
return _getDisplaySetsFromSeries(
|
||||
instances,
|
||||
servicesManager,
|
||||
extensionManager
|
||||
);
|
||||
return _getDisplaySetsFromSeries(instances, servicesManager, extensionManager);
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
@@ -62,7 +62,8 @@
|
||||
font-size: 10px;
|
||||
z-index: 11;
|
||||
color: var(--ol-foreground-color);
|
||||
text-shadow: -1.5px 0 var(--ol-partial-background-color),
|
||||
text-shadow:
|
||||
-1.5px 0 var(--ol-partial-background-color),
|
||||
0 1.5px var(--ol-partial-background-color),
|
||||
1.5px 0 var(--ol-partial-background-color),
|
||||
0 -1.5px var(--ol-partial-background-color);
|
||||
@@ -74,7 +75,8 @@
|
||||
text-align: center;
|
||||
bottom: 25px;
|
||||
color: var(--ol-foreground-color);
|
||||
text-shadow: -1.5px 0 var(--ol-partial-background-color),
|
||||
text-shadow:
|
||||
-1.5px 0 var(--ol-partial-background-color),
|
||||
0 1.5px var(--ol-partial-background-color),
|
||||
1.5px 0 var(--ol-partial-background-color),
|
||||
0 -1.5px var(--ol-partial-background-color);
|
||||
@@ -147,13 +149,17 @@
|
||||
.DicomMicroscopyViewer .ol-rotate {
|
||||
top: 0.5em;
|
||||
right: 0.5em;
|
||||
transition: opacity 0.25s linear, visibility 0s linear;
|
||||
transition:
|
||||
opacity 0.25s linear,
|
||||
visibility 0s linear;
|
||||
}
|
||||
|
||||
.DicomMicroscopyViewer .ol-rotate.ol-hidden {
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transition: opacity 0.25s linear, visibility 0s linear 0.25s;
|
||||
transition:
|
||||
opacity 0.25s linear,
|
||||
visibility 0s linear 0.25s;
|
||||
}
|
||||
|
||||
.DicomMicroscopyViewer .ol-zoom-extent {
|
||||
|
||||
@@ -103,10 +103,7 @@ class DicomMicroscopyViewport extends Component {
|
||||
// you should only do this once.
|
||||
async installOpenLayersRenderer(container, displaySet) {
|
||||
const loadViewer = async metadata => {
|
||||
const {
|
||||
viewer: DicomMicroscopyViewer,
|
||||
metadata: metadataUtils,
|
||||
} = await import(
|
||||
const { viewer: DicomMicroscopyViewer, metadata: metadataUtils } = await import(
|
||||
/* webpackChunkName: "dicom-microscopy-viewer" */ 'dicom-microscopy-viewer'
|
||||
);
|
||||
const microscopyViewer = DicomMicroscopyViewer.VolumeImageViewer;
|
||||
@@ -163,10 +160,7 @@ class DicomMicroscopyViewport extends Component {
|
||||
metadata.forEach(m => {
|
||||
// NOTE: depending on different data source, image.ImageType sometimes
|
||||
// is a string, not a string array.
|
||||
m.ImageType =
|
||||
typeof m.ImageType === 'string'
|
||||
? m.ImageType.split('\\')
|
||||
: m.ImageType;
|
||||
m.ImageType = typeof m.ImageType === 'string' ? m.ImageType.split('\\') : m.ImageType;
|
||||
|
||||
const inst = cleanDenaturalizedDataset(
|
||||
dcmjs.data.DicomMetaDictionary.denaturalizeDataset(m),
|
||||
@@ -211,11 +205,7 @@ class DicomMicroscopyViewport extends Component {
|
||||
|
||||
this.viewer = new microscopyViewer(options);
|
||||
|
||||
if (
|
||||
this.overlayElement &&
|
||||
this.overlayElement.current &&
|
||||
this.viewer.addViewportOverlay
|
||||
) {
|
||||
if (this.overlayElement && this.overlayElement.current && this.viewer.addViewportOverlay) {
|
||||
this.viewer.addViewportOverlay({
|
||||
element: this.overlayElement.current,
|
||||
coordinates: [0, 0], // TODO: dicom-microscopy-viewer documentation says this can be false to be automatically, but it is not.
|
||||
@@ -263,22 +253,13 @@ class DicomMicroscopyViewport extends Component {
|
||||
const { viewportId } = viewportOptions;
|
||||
// Todo-rename: this is always getting the 0
|
||||
const displaySet = displaySets[0];
|
||||
this.installOpenLayersRenderer(this.container.current, displaySet).then(
|
||||
() => {
|
||||
this.setState({ isLoaded: true });
|
||||
}
|
||||
);
|
||||
this.installOpenLayersRenderer(this.container.current, displaySet).then(() => {
|
||||
this.setState({ isLoaded: true });
|
||||
});
|
||||
}
|
||||
|
||||
componentDidUpdate(
|
||||
prevProps: Readonly<{}>,
|
||||
prevState: Readonly<{}>,
|
||||
snapshot?: any
|
||||
): void {
|
||||
if (
|
||||
this.managedViewer &&
|
||||
prevProps.displaySets !== this.props.displaySets
|
||||
) {
|
||||
componentDidUpdate(prevProps: Readonly<{}>, prevState: Readonly<{}>, snapshot?: any): void {
|
||||
if (this.managedViewer && prevProps.displaySets !== this.props.displaySets) {
|
||||
const { displaySets } = this.props;
|
||||
const displaySet = displaySets[0];
|
||||
|
||||
@@ -317,9 +298,7 @@ class DicomMicroscopyViewport extends Component {
|
||||
>
|
||||
<div style={{ ...style, display: 'none' }}>
|
||||
<div style={{ ...style }} ref={this.overlayElement}>
|
||||
<div
|
||||
style={{ position: 'relative', height: '100%', width: '100%' }}
|
||||
>
|
||||
<div style={{ position: 'relative', height: '100%', width: '100%' }}>
|
||||
{displaySet && firstInstance.imageId && (
|
||||
<ViewportOverlay
|
||||
displaySet={displaySet}
|
||||
@@ -331,11 +310,7 @@ class DicomMicroscopyViewport extends Component {
|
||||
</div>
|
||||
</div>
|
||||
{ReactResizeDetector && (
|
||||
<ReactResizeDetector
|
||||
handleWidth
|
||||
handleHeight
|
||||
onResize={this.onWindowResize}
|
||||
/>
|
||||
<ReactResizeDetector handleWidth handleHeight onResize={this.onWindowResize} />
|
||||
)}
|
||||
{this.state.error ? (
|
||||
<h2>{JSON.stringify(this.state.error)}</h2>
|
||||
@@ -343,7 +318,7 @@ class DicomMicroscopyViewport extends Component {
|
||||
<div style={style} ref={this.container} />
|
||||
)}
|
||||
{this.state.isLoaded ? null : (
|
||||
<LoadingIndicatorProgress className={'w-full h-full bg-black'} />
|
||||
<LoadingIndicatorProgress className={'h-full w-full bg-black'} />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import {
|
||||
ServicesManager,
|
||||
ExtensionManager,
|
||||
CommandsManager,
|
||||
DicomMetadataStore,
|
||||
} from '@ohif/core';
|
||||
import { ServicesManager, ExtensionManager, CommandsManager, DicomMetadataStore } from '@ohif/core';
|
||||
import { MeasurementTable, Icon, ButtonGroup, Button } from '@ohif/ui';
|
||||
import { withTranslation, WithTranslation } from 'react-i18next';
|
||||
import { EVENTS as MicroscopyEvents } from '../../services/MicroscopyService';
|
||||
@@ -73,9 +68,7 @@ interface IMicroscopyPanelProps extends WithTranslation {
|
||||
function MicroscopyPanel(props: IMicroscopyPanelProps) {
|
||||
const { microscopyService } = props.servicesManager.services;
|
||||
|
||||
const [studyInstanceUID, setStudyInstanceUID] = useState(
|
||||
null as string | null
|
||||
);
|
||||
const [studyInstanceUID, setStudyInstanceUID] = useState(null as string | null);
|
||||
const [roiAnnotations, setRoiAnnotations] = useState([] as any[]);
|
||||
const [selectedAnnotation, setSelectedAnnotation] = useState(null as any);
|
||||
const { servicesManager, extensionManager } = props;
|
||||
@@ -85,9 +78,7 @@ function MicroscopyPanel(props: IMicroscopyPanelProps) {
|
||||
useEffect(() => {
|
||||
const viewport = props.viewports[props.activeViewportId];
|
||||
if (viewport.displaySetInstanceUIDs[0]) {
|
||||
const displaySet = displaySetService.getDisplaySetByUID(
|
||||
viewport.displaySetInstanceUIDs[0]
|
||||
);
|
||||
const displaySet = displaySetService.getDisplaySetByUID(viewport.displaySetInstanceUIDs[0]);
|
||||
if (displaySet) {
|
||||
setStudyInstanceUID(displaySet.StudyInstanceUID);
|
||||
}
|
||||
@@ -96,9 +87,7 @@ function MicroscopyPanel(props: IMicroscopyPanelProps) {
|
||||
|
||||
useEffect(() => {
|
||||
const onAnnotationUpdated = () => {
|
||||
const roiAnnotations = microscopyService.getAnnotationsForStudy(
|
||||
studyInstanceUID
|
||||
);
|
||||
const roiAnnotations = microscopyService.getAnnotationsForStudy(studyInstanceUID);
|
||||
setRoiAnnotations(roiAnnotations);
|
||||
};
|
||||
|
||||
@@ -111,21 +100,15 @@ function MicroscopyPanel(props: IMicroscopyPanelProps) {
|
||||
onAnnotationUpdated();
|
||||
};
|
||||
|
||||
const {
|
||||
unsubscribe: unsubscribeAnnotationUpdated,
|
||||
} = microscopyService.subscribe(
|
||||
const { unsubscribe: unsubscribeAnnotationUpdated } = microscopyService.subscribe(
|
||||
MicroscopyEvents.ANNOTATION_UPDATED,
|
||||
onAnnotationUpdated
|
||||
);
|
||||
const {
|
||||
unsubscribe: unsubscribeAnnotationSelected,
|
||||
} = microscopyService.subscribe(
|
||||
const { unsubscribe: unsubscribeAnnotationSelected } = microscopyService.subscribe(
|
||||
MicroscopyEvents.ANNOTATION_SELECTED,
|
||||
onAnnotationSelected
|
||||
);
|
||||
const {
|
||||
unsubscribe: unsubscribeAnnotationRemoved,
|
||||
} = microscopyService.subscribe(
|
||||
const { unsubscribe: unsubscribeAnnotationRemoved } = microscopyService.subscribe(
|
||||
MicroscopyEvents.ANNOTATION_REMOVED,
|
||||
onAnnotationRemoved
|
||||
);
|
||||
@@ -147,9 +130,7 @@ function MicroscopyPanel(props: IMicroscopyPanelProps) {
|
||||
* @returns
|
||||
*/
|
||||
const promptSave = () => {
|
||||
const annotations = microscopyService.getAnnotationsForStudy(
|
||||
studyInstanceUID
|
||||
);
|
||||
const annotations = microscopyService.getAnnotationsForStudy(studyInstanceUID);
|
||||
|
||||
if (!annotations || saving) {
|
||||
return;
|
||||
@@ -172,9 +153,7 @@ function MicroscopyPanel(props: IMicroscopyPanelProps) {
|
||||
const getAllDisplaySets = (studyMetadata: any) => {
|
||||
let allDisplaySets = [] as any[];
|
||||
studyMetadata.series.forEach((series: any) => {
|
||||
const displaySets = displaySetService.getDisplaySetsForSeries(
|
||||
series.SeriesInstanceUID
|
||||
);
|
||||
const displaySets = displaySetService.getDisplaySetsForSeries(series.SeriesInstanceUID);
|
||||
allDisplaySets = allDisplaySets.concat(displaySets);
|
||||
});
|
||||
return allDisplaySets;
|
||||
@@ -189,9 +168,7 @@ function MicroscopyPanel(props: IMicroscopyPanelProps) {
|
||||
const saveFunction = async (SeriesDescription: string) => {
|
||||
const dataSource = extensionManager.getActiveDataSource()[0];
|
||||
const { onSaveComplete } = props;
|
||||
const annotations = microscopyService.getAnnotationsForStudy(
|
||||
studyInstanceUID
|
||||
);
|
||||
const annotations = microscopyService.getAnnotationsForStudy(studyInstanceUID);
|
||||
|
||||
saving = true;
|
||||
|
||||
@@ -206,10 +183,7 @@ function MicroscopyPanel(props: IMicroscopyPanelProps) {
|
||||
// Get the next available series number after 4700.
|
||||
|
||||
const dsWithMetadata = displaySets.filter(
|
||||
ds =>
|
||||
ds.metadata &&
|
||||
ds.metadata.SeriesNumber &&
|
||||
typeof ds.metadata.SeriesNumber === 'number'
|
||||
ds => ds.metadata && ds.metadata.SeriesNumber && typeof ds.metadata.SeriesNumber === 'number'
|
||||
);
|
||||
|
||||
// Generate next series number
|
||||
@@ -220,11 +194,7 @@ function MicroscopyPanel(props: IMicroscopyPanelProps) {
|
||||
const { instance: metadata } = smDisplaySet;
|
||||
|
||||
// construct SR dataset
|
||||
const dataset = constructSR(
|
||||
metadata,
|
||||
{ SeriesDescription, SeriesNumber },
|
||||
annotations
|
||||
);
|
||||
const dataset = constructSR(metadata, { SeriesDescription, SeriesNumber }, annotations);
|
||||
|
||||
// Save in DICOM format
|
||||
try {
|
||||
@@ -271,13 +241,11 @@ function MicroscopyPanel(props: IMicroscopyPanelProps) {
|
||||
// TODO: studies?
|
||||
const study = DicomMetadataStore.getStudy(StudyInstanceUID);
|
||||
|
||||
const lastDerivedDisplaySet = study.derivedDisplaySets.sort(
|
||||
(ds1: any, ds2: any) => {
|
||||
const dateTime1 = Number(`${ds1.SeriesDate}${ds1.SeriesTime}`);
|
||||
const dateTime2 = Number(`${ds2.SeriesDate}${ds2.SeriesTime}`);
|
||||
return dateTime1 > dateTime2;
|
||||
}
|
||||
)[study.derivedDisplaySets.length - 1];
|
||||
const lastDerivedDisplaySet = study.derivedDisplaySets.sort((ds1: any, ds2: any) => {
|
||||
const dateTime1 = Number(`${ds1.SeriesDate}${ds1.SeriesTime}`);
|
||||
const dateTime2 = Number(`${ds2.SeriesDate}${ds2.SeriesTime}`);
|
||||
return dateTime1 > dateTime2;
|
||||
})[study.derivedDisplaySets.length - 1];
|
||||
|
||||
// TODO: use dataSource.reject.dicom()
|
||||
// await DICOMSR.rejectMeasurements(
|
||||
@@ -314,13 +282,7 @@ function MicroscopyPanel(props: IMicroscopyPanelProps) {
|
||||
* Handler for "Edit" action of an annotation item
|
||||
* @param param0
|
||||
*/
|
||||
const onMeasurementItemEditHandler = ({
|
||||
uid,
|
||||
isActive,
|
||||
}: {
|
||||
uid: string;
|
||||
isActive: boolean;
|
||||
}) => {
|
||||
const onMeasurementItemEditHandler = ({ uid, isActive }: { uid: string; isActive: boolean }) => {
|
||||
props.commandsManager.runCommand('setLabel', { uid }, 'MICROSCOPY');
|
||||
};
|
||||
|
||||
@@ -344,10 +306,7 @@ function MicroscopyPanel(props: IMicroscopyPanelProps) {
|
||||
} else if (length !== undefined) {
|
||||
displayText.push(
|
||||
shortAxisLength
|
||||
? `${formatLength(length, 'μm')} x ${formatLength(
|
||||
shortAxisLength,
|
||||
'μm'
|
||||
)}`
|
||||
? `${formatLength(length, 'μm')} x ${formatLength(shortAxisLength, 'μm')}`
|
||||
: `${formatLength(length, 'μm')}`
|
||||
);
|
||||
}
|
||||
@@ -368,7 +327,7 @@ function MicroscopyPanel(props: IMicroscopyPanelProps) {
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
className="overflow-x-hidden overflow-y-auto ohif-scrollbar"
|
||||
className="ohif-scrollbar overflow-y-auto overflow-x-hidden"
|
||||
data-cy={'measurements-panel'}
|
||||
>
|
||||
<MeasurementTable
|
||||
@@ -406,8 +365,6 @@ function MicroscopyPanel(props: IMicroscopyPanelProps) {
|
||||
);
|
||||
}
|
||||
|
||||
const connectedMicroscopyPanel = withTranslation(['MicroscopyTable', 'Common'])(
|
||||
MicroscopyPanel
|
||||
);
|
||||
const connectedMicroscopyPanel = withTranslation(['MicroscopyTable', 'Common'])(MicroscopyPanel);
|
||||
|
||||
export default connectedMicroscopyPanel;
|
||||
@@ -84,4 +84,4 @@
|
||||
|
||||
.DicomMicroscopyViewer .top-viewport .flex span:not(.font-light) {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,7 @@ import classnames from 'classnames';
|
||||
|
||||
import listComponentGenerator from './listComponentGenerator';
|
||||
import './ViewportOverlay.css';
|
||||
import {
|
||||
formatDICOMDate,
|
||||
formatDICOMTime,
|
||||
formatNumberPrecision,
|
||||
formatPN,
|
||||
} from './utils';
|
||||
import { formatDICOMDate, formatDICOMTime, formatNumberPrecision, formatPN } from './utils';
|
||||
|
||||
interface OverlayItem {
|
||||
id: string;
|
||||
@@ -41,20 +36,15 @@ export const generateFromConfig = ({
|
||||
}) => {
|
||||
return (props: any) => {
|
||||
const topLeftClass = 'top-viewport left-viewport text-primary-light';
|
||||
const topRightClass =
|
||||
'top-viewport right-viewport-scrollbar text-primary-light';
|
||||
const bottomRightClass =
|
||||
'bottom-viewport right-viewport-scrollbar text-primary-light';
|
||||
const topRightClass = 'top-viewport right-viewport-scrollbar text-primary-light';
|
||||
const bottomRightClass = 'bottom-viewport right-viewport-scrollbar text-primary-light';
|
||||
const bottomLeftClass = 'bottom-viewport left-viewport text-primary-light';
|
||||
const overlay = 'absolute pointer-events-none microscopy-viewport-overlay';
|
||||
|
||||
return (
|
||||
<>
|
||||
{topLeft && topLeft.length > 0 && (
|
||||
<div
|
||||
data-cy={'viewport-overlay-top-left'}
|
||||
className={classnames(overlay, topLeftClass)}
|
||||
>
|
||||
<div data-cy={'viewport-overlay-top-left'} className={classnames(overlay, topLeftClass)}>
|
||||
{listComponentGenerator({ ...props, list: topLeft, itemGenerator })}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -81,20 +81,13 @@ export function formatPN(name) {
|
||||
* @returns {string} comrpession type.
|
||||
*/
|
||||
export function getCompression(imageId) {
|
||||
const generalImageModule =
|
||||
cornerstone.metaData.get('generalImageModule', imageId) || {};
|
||||
const {
|
||||
lossyImageCompression,
|
||||
lossyImageCompressionRatio,
|
||||
lossyImageCompressionMethod,
|
||||
} = generalImageModule;
|
||||
const generalImageModule = cornerstone.metaData.get('generalImageModule', imageId) || {};
|
||||
const { lossyImageCompression, lossyImageCompressionRatio, lossyImageCompressionMethod } =
|
||||
generalImageModule;
|
||||
|
||||
if (lossyImageCompression === '01' && lossyImageCompressionRatio !== '') {
|
||||
const compressionMethod = lossyImageCompressionMethod || 'Lossy: ';
|
||||
const compressionRatio = formatNumberPrecision(
|
||||
lossyImageCompressionRatio,
|
||||
2
|
||||
);
|
||||
const compressionRatio = formatNumberPrecision(lossyImageCompressionRatio, 2);
|
||||
return compressionMethod + compressionRatio + ' : 1';
|
||||
}
|
||||
|
||||
|
||||
@@ -11,11 +11,7 @@ export default function getCommandsModule({
|
||||
commandsManager: CommandsManager;
|
||||
extensionManager: ExtensionManager;
|
||||
}) {
|
||||
const {
|
||||
viewportGridService,
|
||||
uiDialogService,
|
||||
microscopyService,
|
||||
} = servicesManager.services;
|
||||
const { viewportGridService, uiDialogService, microscopyService } = servicesManager.services;
|
||||
|
||||
const actions = {
|
||||
// Measurement tool commands:
|
||||
@@ -63,15 +59,9 @@ export default function getCommandsModule({
|
||||
},
|
||||
];
|
||||
if (
|
||||
[
|
||||
'line',
|
||||
'box',
|
||||
'circle',
|
||||
'point',
|
||||
'polygon',
|
||||
'freehandpolygon',
|
||||
'freehandline',
|
||||
].indexOf(toolName) >= 0
|
||||
['line', 'box', 'circle', 'point', 'polygon', 'freehandpolygon', 'freehandline'].indexOf(
|
||||
toolName
|
||||
) >= 0
|
||||
) {
|
||||
// TODO: read from configuration
|
||||
const options = {
|
||||
@@ -124,9 +114,7 @@ export default function getCommandsModule({
|
||||
},
|
||||
toggleOverlays: () => {
|
||||
// overlay
|
||||
const overlays = document.getElementsByClassName(
|
||||
'microscopy-viewport-overlay'
|
||||
);
|
||||
const overlays = document.getElementsByClassName('microscopy-viewport-overlay');
|
||||
let onoff = false; // true if this will toggle on
|
||||
for (let i = 0; i < overlays.length; i++) {
|
||||
if (i === 0) {
|
||||
|
||||
@@ -30,15 +30,8 @@ export default {
|
||||
*/
|
||||
id,
|
||||
|
||||
async preRegistration({
|
||||
servicesManager,
|
||||
commandsManager,
|
||||
configuration = {},
|
||||
appConfig,
|
||||
}) {
|
||||
servicesManager.registerService(
|
||||
MicroscopyService.REGISTRATION(servicesManager)
|
||||
);
|
||||
async preRegistration({ servicesManager, commandsManager, configuration = {}, appConfig }) {
|
||||
servicesManager.registerService(MicroscopyService.REGISTRATION(servicesManager));
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -94,11 +87,7 @@ export default {
|
||||
* Each sop class handler is defined by a { name, sopClassUids, getDisplaySetsFromSeries}.
|
||||
* Examples include the default sop class handler provided by the default extension
|
||||
*/
|
||||
getSopClassHandlerModule({
|
||||
servicesManager,
|
||||
commandsManager,
|
||||
extensionManager,
|
||||
}) {
|
||||
getSopClassHandlerModule({ servicesManager, commandsManager, extensionManager }) {
|
||||
return [
|
||||
getDicomMicroscopySopClassHandler({
|
||||
servicesManager,
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import ViewerManager, { EVENTS as ViewerEvents } from '../tools/viewerManager';
|
||||
import RoiAnnotation, {
|
||||
EVENTS as AnnotationEvents,
|
||||
} from '../utils/RoiAnnotation';
|
||||
import RoiAnnotation, { EVENTS as AnnotationEvents } from '../utils/RoiAnnotation';
|
||||
import styles from '../utils/styles';
|
||||
import { DicomMetadataStore, PubSubService } from '@ohif/core';
|
||||
|
||||
@@ -158,10 +156,7 @@ export default class MicroscopyService extends PubSubService {
|
||||
_onRoiUpdated(data) {
|
||||
const { roiGraphic, managedViewer } = data;
|
||||
this.synchronizeViewers(managedViewer);
|
||||
this._broadcastEvent(
|
||||
EVENTS.ANNOTATION_UPDATED,
|
||||
this.getAnnotation(roiGraphic.uid)
|
||||
);
|
||||
this._broadcastEvent(EVENTS.ANNOTATION_UPDATED, this.getAnnotation(roiGraphic.uid));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -175,10 +170,7 @@ export default class MicroscopyService extends PubSubService {
|
||||
_onRoiSelected(data) {
|
||||
const { roiGraphic } = data;
|
||||
const selectedAnnotation = this.getAnnotation(roiGraphic.uid);
|
||||
if (
|
||||
selectedAnnotation &&
|
||||
selectedAnnotation !== this.getSelectedAnnotation()
|
||||
) {
|
||||
if (selectedAnnotation && selectedAnnotation !== this.getSelectedAnnotation()) {
|
||||
if (this.selectedAnnotation) {
|
||||
this.clearSelection();
|
||||
}
|
||||
@@ -221,16 +213,11 @@ export default class MicroscopyService extends PubSubService {
|
||||
* @param {ViewerManager} managedViewer The viewer being removed
|
||||
*/
|
||||
_removeManagedViewerSubscriptions(managedViewer) {
|
||||
managedViewer._roiAddedSubscription &&
|
||||
managedViewer._roiAddedSubscription.unsubscribe();
|
||||
managedViewer._roiModifiedSubscription &&
|
||||
managedViewer._roiModifiedSubscription.unsubscribe();
|
||||
managedViewer._roiRemovedSubscription &&
|
||||
managedViewer._roiRemovedSubscription.unsubscribe();
|
||||
managedViewer._roiUpdatedSubscription &&
|
||||
managedViewer._roiUpdatedSubscription.unsubscribe();
|
||||
managedViewer._roiSelectedSubscription &&
|
||||
managedViewer._roiSelectedSubscription.unsubscribe();
|
||||
managedViewer._roiAddedSubscription && managedViewer._roiAddedSubscription.unsubscribe();
|
||||
managedViewer._roiModifiedSubscription && managedViewer._roiModifiedSubscription.unsubscribe();
|
||||
managedViewer._roiRemovedSubscription && managedViewer._roiRemovedSubscription.unsubscribe();
|
||||
managedViewer._roiUpdatedSubscription && managedViewer._roiUpdatedSubscription.unsubscribe();
|
||||
managedViewer._roiSelectedSubscription && managedViewer._roiSelectedSubscription.unsubscribe();
|
||||
|
||||
managedViewer._roiAddedSubscription = null;
|
||||
managedViewer._roiModifiedSubscription = null;
|
||||
@@ -264,8 +251,7 @@ export default class MicroscopyService extends PubSubService {
|
||||
* @returns {Array} The managed viewers for the given series UID
|
||||
*/
|
||||
getManagedViewersForStudy(studyInstanceUID) {
|
||||
const filter = managedViewer =>
|
||||
managedViewer.studyInstanceUID === studyInstanceUID;
|
||||
const filter = managedViewer => managedViewer.studyInstanceUID === studyInstanceUID;
|
||||
return Array.from(this.managedViewers).filter(filter);
|
||||
}
|
||||
|
||||
@@ -276,10 +262,7 @@ export default class MicroscopyService extends PubSubService {
|
||||
*/
|
||||
_restoreAnnotations(managedViewer) {
|
||||
const { studyInstanceUID, seriesInstanceUID } = managedViewer;
|
||||
const annotations = this.getAnnotationsForSeries(
|
||||
studyInstanceUID,
|
||||
seriesInstanceUID
|
||||
);
|
||||
const annotations = this.getAnnotationsForSeries(studyInstanceUID, seriesInstanceUID);
|
||||
annotations.forEach(roiAnnotation => {
|
||||
managedViewer.addRoiGraphic(roiAnnotation.roiGraphic);
|
||||
});
|
||||
@@ -301,13 +284,7 @@ export default class MicroscopyService extends PubSubService {
|
||||
*
|
||||
* @returns {ViewerManager} managed viewer
|
||||
*/
|
||||
addViewer(
|
||||
viewer,
|
||||
viewportId,
|
||||
container,
|
||||
studyInstanceUID,
|
||||
seriesInstanceUID
|
||||
) {
|
||||
addViewer(viewer, viewportId, container, studyInstanceUID, seriesInstanceUID) {
|
||||
const managedViewer = new ViewerManager(
|
||||
viewer,
|
||||
viewportId,
|
||||
@@ -507,9 +484,7 @@ export default class MicroscopyService extends PubSubService {
|
||||
*/
|
||||
toggleOverviewMap(viewportId) {
|
||||
const managedViewers = Array.from(this.managedViewers);
|
||||
const managedViewer = managedViewers.find(
|
||||
mv => mv.viewportId === viewportId
|
||||
);
|
||||
const managedViewer = managedViewers.find(mv => mv.viewportId === viewportId);
|
||||
if (managedViewer) {
|
||||
managedViewer.toggleOverviewMap();
|
||||
}
|
||||
@@ -529,9 +504,7 @@ export default class MicroscopyService extends PubSubService {
|
||||
|
||||
const managedViewers = Array.from(this.managedViewers).filter(filter);
|
||||
|
||||
managedViewers.forEach(managedViewer =>
|
||||
managedViewer.removeRoiGraphic(uid)
|
||||
);
|
||||
managedViewers.forEach(managedViewer => managedViewer.removeRoiGraphic(uid));
|
||||
|
||||
if (this.annotations[uid]) {
|
||||
this.roiUids.delete(uid);
|
||||
@@ -570,34 +543,24 @@ export default class MicroscopyService extends PubSubService {
|
||||
*/
|
||||
synchronizeViewers(baseManagedViewer) {
|
||||
const { studyInstanceUID, seriesInstanceUID } = baseManagedViewer;
|
||||
const managedViewers = this._getManagedViewersForSeries(
|
||||
studyInstanceUID,
|
||||
seriesInstanceUID
|
||||
);
|
||||
const managedViewers = this._getManagedViewersForSeries(studyInstanceUID, seriesInstanceUID);
|
||||
|
||||
// Prevent infinite loops arrising from updates.
|
||||
managedViewers.forEach(managedViewer =>
|
||||
this._removeManagedViewerSubscriptions(managedViewer)
|
||||
);
|
||||
managedViewers.forEach(managedViewer => this._removeManagedViewerSubscriptions(managedViewer));
|
||||
|
||||
managedViewers.forEach(managedViewer => {
|
||||
if (managedViewer === baseManagedViewer) {
|
||||
return;
|
||||
}
|
||||
|
||||
const annotations = this.getAnnotationsForSeries(
|
||||
studyInstanceUID,
|
||||
seriesInstanceUID
|
||||
);
|
||||
const annotations = this.getAnnotationsForSeries(studyInstanceUID, seriesInstanceUID);
|
||||
managedViewer.clearRoiGraphics();
|
||||
annotations.forEach(roiAnnotation => {
|
||||
managedViewer.addRoiGraphic(roiAnnotation.roiGraphic);
|
||||
});
|
||||
});
|
||||
|
||||
managedViewers.forEach(managedViewer =>
|
||||
this._addManagedViewerSubscriptions(managedViewer)
|
||||
);
|
||||
managedViewers.forEach(managedViewer => this._addManagedViewerSubscriptions(managedViewer));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -46,13 +46,7 @@ const EVENTS = {
|
||||
* expose only the features/behaviors that are relevant to the application
|
||||
*/
|
||||
class ViewerManager extends PubSubService {
|
||||
constructor(
|
||||
viewer,
|
||||
viewportId,
|
||||
container,
|
||||
studyInstanceUID,
|
||||
seriesInstanceUID
|
||||
) {
|
||||
constructor(viewer, viewportId, container, studyInstanceUID, seriesInstanceUID) {
|
||||
super(EVENTS);
|
||||
this.viewer = viewer;
|
||||
this.viewportId = viewportId;
|
||||
@@ -119,18 +113,9 @@ class ViewerManager extends PubSubService {
|
||||
*/
|
||||
unregisterEvents() {
|
||||
this.container.removeEventListener(ApiEvents.ROI_ADDED, this.onRoiAdded);
|
||||
this.container.removeEventListener(
|
||||
ApiEvents.ROI_MODIFIED,
|
||||
this.onRoiModified
|
||||
);
|
||||
this.container.removeEventListener(
|
||||
ApiEvents.ROI_REMOVED,
|
||||
this.onRoiRemoved
|
||||
);
|
||||
this.container.removeEventListener(
|
||||
ApiEvents.ROI_SELECTED,
|
||||
this.onRoiSelected
|
||||
);
|
||||
this.container.removeEventListener(ApiEvents.ROI_MODIFIED, this.onRoiModified);
|
||||
this.container.removeEventListener(ApiEvents.ROI_REMOVED, this.onRoiRemoved);
|
||||
this.container.removeEventListener(ApiEvents.ROI_SELECTED, this.onRoiSelected);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -327,26 +312,16 @@ class ViewerManager extends PubSubService {
|
||||
*/
|
||||
activateInteractions(interactions) {
|
||||
const interactionsMap = {
|
||||
draw: activate =>
|
||||
activate ? 'activateDrawInteraction' : 'deactivateDrawInteraction',
|
||||
modify: activate =>
|
||||
activate ? 'activateModifyInteraction' : 'deactivateModifyInteraction',
|
||||
draw: activate => (activate ? 'activateDrawInteraction' : 'deactivateDrawInteraction'),
|
||||
modify: activate => (activate ? 'activateModifyInteraction' : 'deactivateModifyInteraction'),
|
||||
translate: activate =>
|
||||
activate
|
||||
? 'activateTranslateInteraction'
|
||||
: 'deactivateTranslateInteraction',
|
||||
snap: activate =>
|
||||
activate ? 'activateSnapInteraction' : 'deactivateSnapInteraction',
|
||||
activate ? 'activateTranslateInteraction' : 'deactivateTranslateInteraction',
|
||||
snap: activate => (activate ? 'activateSnapInteraction' : 'deactivateSnapInteraction'),
|
||||
dragPan: activate =>
|
||||
activate
|
||||
? 'activateDragPanInteraction'
|
||||
: 'deactivateDragPanInteraction',
|
||||
activate ? 'activateDragPanInteraction' : 'deactivateDragPanInteraction',
|
||||
dragZoom: activate =>
|
||||
activate
|
||||
? 'activateDragZoomInteraction'
|
||||
: 'deactivateDragZoomInteraction',
|
||||
select: activate =>
|
||||
activate ? 'activateSelectInteraction' : 'deactivateSelectInteraction',
|
||||
activate ? 'activateDragZoomInteraction' : 'deactivateDragZoomInteraction',
|
||||
select: activate => (activate ? 'activateSelectInteraction' : 'deactivateSelectInteraction'),
|
||||
};
|
||||
|
||||
const availableInteractionsName = Object.keys(interactionsMap);
|
||||
@@ -355,9 +330,7 @@ class ViewerManager extends PubSubService {
|
||||
interaction => interaction[0] === availableInteractionName
|
||||
);
|
||||
if (!interaction) {
|
||||
const deactivateInteractionMethod = interactionsMap[
|
||||
availableInteractionName
|
||||
](false);
|
||||
const deactivateInteractionMethod = interactionsMap[availableInteractionName](false);
|
||||
this.viewer[deactivateInteractionMethod]();
|
||||
} else {
|
||||
const [name, config] = interaction;
|
||||
|
||||
@@ -13,13 +13,7 @@ const EVENTS = {
|
||||
* Represents a single annotation for the Microscopy Viewer
|
||||
*/
|
||||
class RoiAnnotation extends PubSubService {
|
||||
constructor(
|
||||
roiGraphic,
|
||||
studyInstanceUID,
|
||||
seriesInstanceUID,
|
||||
label = '',
|
||||
viewState = null
|
||||
) {
|
||||
constructor(roiGraphic, studyInstanceUID, seriesInstanceUID, label = '', viewState = null) {
|
||||
super(EVENTS);
|
||||
this.uid = roiGraphic.uid;
|
||||
this.roiGraphic = roiGraphic;
|
||||
@@ -34,9 +28,7 @@ class RoiAnnotation extends PubSubService {
|
||||
const roiGraphic = this.roiGraphic;
|
||||
|
||||
const roiGraphicSymbols = Object.getOwnPropertySymbols(roiGraphic);
|
||||
const _scoord3d = roiGraphicSymbols.find(
|
||||
s => String(s) === 'Symbol(scoord3d)'
|
||||
);
|
||||
const _scoord3d = roiGraphicSymbols.find(s => String(s) === 'Symbol(scoord3d)');
|
||||
|
||||
return roiGraphic[_scoord3d];
|
||||
}
|
||||
@@ -45,9 +37,7 @@ class RoiAnnotation extends PubSubService {
|
||||
const scoord3d = this.getScoord3d();
|
||||
const scoord3dSymbols = Object.getOwnPropertySymbols(scoord3d);
|
||||
|
||||
const _coordinates = scoord3dSymbols.find(
|
||||
s => String(s) === 'Symbol(coordinates)'
|
||||
);
|
||||
const _coordinates = scoord3dSymbols.find(s => String(s) === 'Symbol(coordinates)');
|
||||
|
||||
const coordinates = scoord3d[_coordinates];
|
||||
return coordinates;
|
||||
|
||||
@@ -5,9 +5,7 @@ export default function areaOfPolygon(coordinates) {
|
||||
let j = n - 1;
|
||||
|
||||
for (let i = 0; i < n; i++) {
|
||||
area +=
|
||||
(coordinates[j][0] + coordinates[i][0]) *
|
||||
(coordinates[j][1] - coordinates[i][1]);
|
||||
area += (coordinates[j][0] + coordinates[i][0]) * (coordinates[j][1] - coordinates[i][1]);
|
||||
j = i; // j is previous vertex to i
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ export default function callInputDialog({
|
||||
label="Enter your annotation"
|
||||
labelClassName="text-white text-[14px] leading-[1.2]"
|
||||
autoFocus
|
||||
className="bg-black border-primary-main"
|
||||
className="border-primary-main bg-black"
|
||||
type="text"
|
||||
value={value.defaultValue}
|
||||
onChange={event => {
|
||||
|
||||
@@ -35,9 +35,7 @@ export default function cleanDenaturalizedDataset(
|
||||
}
|
||||
): any {
|
||||
if (Array.isArray(obj)) {
|
||||
const newAry = obj.map(o =>
|
||||
isPrimitive(o) ? o : cleanDenaturalizedDataset(o, options)
|
||||
);
|
||||
const newAry = obj.map(o => (isPrimitive(o) ? o : cleanDenaturalizedDataset(o, options)));
|
||||
return newAry;
|
||||
} else if (isPrimitive(obj)) {
|
||||
return obj;
|
||||
@@ -47,31 +45,19 @@ export default function cleanDenaturalizedDataset(
|
||||
delete obj[key].Value;
|
||||
} else if (Array.isArray(obj[key].Value) && obj[key].vr) {
|
||||
if (obj[key].Value.length === 1 && obj[key].Value[0].BulkDataURI) {
|
||||
dicomWebUtils.fixBulkDataURI(
|
||||
obj[key].Value[0],
|
||||
options,
|
||||
options.dataSourceConfig
|
||||
);
|
||||
dicomWebUtils.fixBulkDataURI(obj[key].Value[0], options, options.dataSourceConfig);
|
||||
|
||||
obj[key].BulkDataURI = obj[key].Value[0].BulkDataURI;
|
||||
|
||||
// prevent mixed-content blockage
|
||||
if (
|
||||
window.location.protocol === 'https:' &&
|
||||
obj[key].BulkDataURI.startsWith('http:')
|
||||
) {
|
||||
obj[key].BulkDataURI = obj[key].BulkDataURI.replace(
|
||||
'http:',
|
||||
'https:'
|
||||
);
|
||||
if (window.location.protocol === 'https:' && obj[key].BulkDataURI.startsWith('http:')) {
|
||||
obj[key].BulkDataURI = obj[key].BulkDataURI.replace('http:', 'https:');
|
||||
}
|
||||
delete obj[key].Value;
|
||||
} else if (vrNumerics.includes(obj[key].vr)) {
|
||||
obj[key].Value = obj[key].Value.map(v => +v);
|
||||
} else {
|
||||
obj[key].Value = obj[key].Value.map(entry =>
|
||||
cleanDenaturalizedDataset(entry, options)
|
||||
);
|
||||
obj[key].Value = obj[key].Value.map(entry => cleanDenaturalizedDataset(entry, options));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -9,11 +9,7 @@ import DEVICE_OBSERVER_UID from './DEVICE_OBSERVER_UID';
|
||||
*
|
||||
* @return Comprehensive3DSR dataset
|
||||
*/
|
||||
export default function constructSR(
|
||||
metadata,
|
||||
{ SeriesDescription, SeriesNumber },
|
||||
annotations
|
||||
) {
|
||||
export default function constructSR(metadata, { SeriesDescription, SeriesNumber }, annotations) {
|
||||
// Handle malformed data
|
||||
if (!metadata.SpecimenDescriptionSequence) {
|
||||
metadata.SpecimenDescriptionSequence = {
|
||||
@@ -31,11 +27,9 @@ export default function constructSR(
|
||||
schemeDesignator: 'DCM',
|
||||
meaning: 'Person',
|
||||
}),
|
||||
observerIdentifyingAttributes: new dcmjs.sr.templates.PersonObserverIdentifyingAttributes(
|
||||
{
|
||||
name: '@ohif/extension-dicom-microscopy',
|
||||
}
|
||||
),
|
||||
observerIdentifyingAttributes: new dcmjs.sr.templates.PersonObserverIdentifyingAttributes({
|
||||
name: '@ohif/extension-dicom-microscopy',
|
||||
}),
|
||||
}),
|
||||
observerDeviceContext: new dcmjs.sr.templates.ObserverContext({
|
||||
observerType: new dcmjs.sr.coding.CodedConcept({
|
||||
@@ -43,11 +37,9 @@ export default function constructSR(
|
||||
schemeDesignator: 'DCM',
|
||||
meaning: 'Device',
|
||||
}),
|
||||
observerIdentifyingAttributes: new dcmjs.sr.templates.DeviceObserverIdentifyingAttributes(
|
||||
{
|
||||
uid: DEVICE_OBSERVER_UID,
|
||||
}
|
||||
),
|
||||
observerIdentifyingAttributes: new dcmjs.sr.templates.DeviceObserverIdentifyingAttributes({
|
||||
uid: DEVICE_OBSERVER_UID,
|
||||
}),
|
||||
}),
|
||||
subjectContext: new dcmjs.sr.templates.SubjectContext({
|
||||
subjectClass: new dcmjs.sr.coding.CodedConcept({
|
||||
@@ -55,28 +47,18 @@ export default function constructSR(
|
||||
schemeDesignator: 'DCM',
|
||||
meaning: 'Specimen',
|
||||
}),
|
||||
subjectClassSpecificContext: new dcmjs.sr.templates.SubjectContextSpecimen(
|
||||
{
|
||||
uid: SpecimenDescriptionSequence.SpecimenUID,
|
||||
identifier:
|
||||
SpecimenDescriptionSequence.SpecimenIdentifier ||
|
||||
metadata.SeriesInstanceUID,
|
||||
containerIdentifier:
|
||||
metadata.ContainerIdentifier || metadata.SeriesInstanceUID,
|
||||
}
|
||||
),
|
||||
subjectClassSpecificContext: new dcmjs.sr.templates.SubjectContextSpecimen({
|
||||
uid: SpecimenDescriptionSequence.SpecimenUID,
|
||||
identifier: SpecimenDescriptionSequence.SpecimenIdentifier || metadata.SeriesInstanceUID,
|
||||
containerIdentifier: metadata.ContainerIdentifier || metadata.SeriesInstanceUID,
|
||||
}),
|
||||
}),
|
||||
});
|
||||
|
||||
const imagingMeasurements = [];
|
||||
for (let i = 0; i < annotations.length; i++) {
|
||||
const { roiGraphic: roi, label } = annotations[i];
|
||||
let {
|
||||
measurements,
|
||||
evaluations,
|
||||
marker,
|
||||
presentationState,
|
||||
} = roi.properties;
|
||||
let { measurements, evaluations, marker, presentationState } = roi.properties;
|
||||
|
||||
console.debug('[SR] storing marker...', marker);
|
||||
console.debug('[SR] storing measurements...', measurements);
|
||||
@@ -97,9 +79,7 @@ export default function constructSR(
|
||||
? measurement.MeasuredValueSequence[0]
|
||||
: measurement.MeasuredValueSequence;
|
||||
|
||||
const MeasuredValueUnits = Array.isArray(
|
||||
MeasuredValue.MeasurementUnitsCodeSequence
|
||||
)
|
||||
const MeasuredValueUnits = Array.isArray(MeasuredValue.MeasurementUnitsCodeSequence)
|
||||
? MeasuredValue.MeasurementUnitsCodeSequence[0]
|
||||
: MeasuredValue.MeasurementUnitsCodeSequence;
|
||||
|
||||
@@ -136,29 +116,27 @@ export default function constructSR(
|
||||
});
|
||||
|
||||
const identifier = `ROI #${i + 1}`;
|
||||
const group = new dcmjs.sr.templates.PlanarROIMeasurementsAndQualitativeEvaluations(
|
||||
{
|
||||
trackingIdentifier: new dcmjs.sr.templates.TrackingIdentifier({
|
||||
uid: roi.uid,
|
||||
identifier: presentationState
|
||||
? identifier.concat(`(${JSON.stringify(presentationState)})`)
|
||||
: identifier,
|
||||
}),
|
||||
referencedRegion: new dcmjs.sr.contentItems.ImageRegion3D({
|
||||
graphicType: roi.scoord3d.graphicType,
|
||||
graphicData: roi.scoord3d.graphicData,
|
||||
frameOfReferenceUID: roi.scoord3d.frameOfReferenceUID,
|
||||
}),
|
||||
findingType: new dcmjs.sr.coding.CodedConcept({
|
||||
value: label,
|
||||
schemeDesignator: '@ohif/extension-dicom-microscopy',
|
||||
meaning: 'FREETEXT',
|
||||
}),
|
||||
/** Evaluations will conflict with current tracking identifier */
|
||||
/** qualitativeEvaluations: evaluations, */
|
||||
measurements,
|
||||
}
|
||||
);
|
||||
const group = new dcmjs.sr.templates.PlanarROIMeasurementsAndQualitativeEvaluations({
|
||||
trackingIdentifier: new dcmjs.sr.templates.TrackingIdentifier({
|
||||
uid: roi.uid,
|
||||
identifier: presentationState
|
||||
? identifier.concat(`(${JSON.stringify(presentationState)})`)
|
||||
: identifier,
|
||||
}),
|
||||
referencedRegion: new dcmjs.sr.contentItems.ImageRegion3D({
|
||||
graphicType: roi.scoord3d.graphicType,
|
||||
graphicData: roi.scoord3d.graphicData,
|
||||
frameOfReferenceUID: roi.scoord3d.frameOfReferenceUID,
|
||||
}),
|
||||
findingType: new dcmjs.sr.coding.CodedConcept({
|
||||
value: label,
|
||||
schemeDesignator: '@ohif/extension-dicom-microscopy',
|
||||
meaning: 'FREETEXT',
|
||||
}),
|
||||
/** Evaluations will conflict with current tracking identifier */
|
||||
/** qualitativeEvaluations: evaluations, */
|
||||
measurements,
|
||||
});
|
||||
imagingMeasurements.push(...group);
|
||||
}
|
||||
|
||||
@@ -180,8 +158,7 @@ export default function constructSR(
|
||||
evidence: [metadata],
|
||||
seriesInstanceUID: dcmjs.data.DicomMetaDictionary.uid(),
|
||||
seriesNumber: SeriesNumber,
|
||||
seriesDescription:
|
||||
SeriesDescription || 'Whole slide imaging structured report',
|
||||
seriesDescription: SeriesDescription || 'Whole slide imaging structured report',
|
||||
sopInstanceUID: dcmjs.data.DicomMetaDictionary.uid(),
|
||||
instanceNumber: 1,
|
||||
manufacturer: 'dcmjs-org',
|
||||
|
||||
@@ -3,10 +3,7 @@ import { inv, multiply } from 'mathjs';
|
||||
// TODO -> This is pulled out of some internal logic from Dicom Microscopy Viewer,
|
||||
// We should likely just expose this there.
|
||||
|
||||
export default function coordinateFormatScoord3d2Geometry(
|
||||
coordinates,
|
||||
pyramid
|
||||
) {
|
||||
export default function coordinateFormatScoord3d2Geometry(coordinates, pyramid) {
|
||||
let transform = false;
|
||||
if (!Array.isArray(coordinates[0])) {
|
||||
coordinates = [coordinates];
|
||||
|
||||
@@ -15,10 +15,7 @@ DICOMwebClient._buildMultipartAcceptHeaderFieldValue = () => {
|
||||
* @param param0
|
||||
* @returns
|
||||
*/
|
||||
export default function getDicomWebClient({
|
||||
extensionManager,
|
||||
servicesManager,
|
||||
}) {
|
||||
export default function getDicomWebClient({ extensionManager, servicesManager }) {
|
||||
const dataSourceConfig = window.config.dataSources.find(
|
||||
ds => ds.sourceName === extensionManager.activeDataSource
|
||||
);
|
||||
@@ -55,29 +52,19 @@ export default function getDicomWebClient({
|
||||
//
|
||||
client.retrieveInstanceFrames = async options => {
|
||||
if (!('studyInstanceUID' in options)) {
|
||||
throw new Error(
|
||||
'Study Instance UID is required for retrieval of instance frames'
|
||||
);
|
||||
throw new Error('Study Instance UID is required for retrieval of instance frames');
|
||||
}
|
||||
if (!('seriesInstanceUID' in options)) {
|
||||
throw new Error(
|
||||
'Series Instance UID is required for retrieval of instance frames'
|
||||
);
|
||||
throw new Error('Series Instance UID is required for retrieval of instance frames');
|
||||
}
|
||||
if (!('sopInstanceUID' in options)) {
|
||||
throw new Error(
|
||||
'SOP Instance UID is required for retrieval of instance frames'
|
||||
);
|
||||
throw new Error('SOP Instance UID is required for retrieval of instance frames');
|
||||
}
|
||||
if (!('frameNumbers' in options)) {
|
||||
throw new Error(
|
||||
'frame numbers are required for retrieval of instance frames'
|
||||
);
|
||||
throw new Error('frame numbers are required for retrieval of instance frames');
|
||||
}
|
||||
console.log(
|
||||
`retrieve frames ${options.frameNumbers.toString()} of instance ${
|
||||
options.sopInstanceUID
|
||||
}`
|
||||
`retrieve frames ${options.frameNumbers.toString()} of instance ${options.sopInstanceUID}`
|
||||
);
|
||||
|
||||
const instance = DicomMetadataStore.getInstance(
|
||||
@@ -91,9 +78,7 @@ export default function getDicomWebClient({
|
||||
: options.frameNumbers.split(',');
|
||||
|
||||
return frameNumbers.map(fr =>
|
||||
Array.isArray(instance.PixelData)
|
||||
? instance.PixelData[+fr - 1]
|
||||
: instance.PixelData
|
||||
Array.isArray(instance.PixelData) ? instance.PixelData[+fr - 1] : instance.PixelData
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -5,24 +5,18 @@
|
||||
* @param {*} microscopySRDisplaySet
|
||||
* @returns
|
||||
*/
|
||||
export default function getSourceDisplaySet(
|
||||
allDisplaySets,
|
||||
microscopySRDisplaySet
|
||||
) {
|
||||
export default function getSourceDisplaySet(allDisplaySets, microscopySRDisplaySet) {
|
||||
const { ReferencedFrameOfReferenceUID } = microscopySRDisplaySet;
|
||||
|
||||
const otherDisplaySets = allDisplaySets.filter(
|
||||
ds =>
|
||||
ds.displaySetInstanceUID !== microscopySRDisplaySet.displaySetInstanceUID
|
||||
ds => ds.displaySetInstanceUID !== microscopySRDisplaySet.displaySetInstanceUID
|
||||
);
|
||||
const referencedDisplaySet = otherDisplaySets.find(
|
||||
displaySet =>
|
||||
displaySet.Modality === 'SM' &&
|
||||
(displaySet.FrameOfReferenceUID === ReferencedFrameOfReferenceUID ||
|
||||
// sometimes each depth instance has the different FrameOfReferenceID
|
||||
displaySet.othersFrameOfReferenceUID.includes(
|
||||
ReferencedFrameOfReferenceUID
|
||||
))
|
||||
displaySet.othersFrameOfReferenceUID.includes(ReferencedFrameOfReferenceUID))
|
||||
);
|
||||
|
||||
if (!referencedDisplaySet && otherDisplaySets.length >= 1) {
|
||||
|
||||
@@ -3,8 +3,7 @@ import dcmjs from 'dcmjs';
|
||||
import DCM_CODE_VALUES from './dcmCodeValues';
|
||||
import toArray from './toArray';
|
||||
|
||||
const MeasurementReport =
|
||||
dcmjs.adapters.DICOMMicroscopyViewer.MeasurementReport;
|
||||
const MeasurementReport = dcmjs.adapters.DICOMMicroscopyViewer.MeasurementReport;
|
||||
|
||||
// Define as async so that it returns a promise, expected by the ViewportGrid
|
||||
export default async function loadSR(
|
||||
@@ -16,9 +15,7 @@ export default async function loadSR(
|
||||
|
||||
const { StudyInstanceUID, FrameOfReferenceUID } = referencedDisplaySet;
|
||||
|
||||
const managedViewers = microscopyService.getManagedViewersForStudy(
|
||||
StudyInstanceUID
|
||||
);
|
||||
const managedViewers = microscopyService.getManagedViewersForStudy(StudyInstanceUID);
|
||||
|
||||
if (!managedViewers || !managedViewers.length) {
|
||||
return;
|
||||
@@ -26,10 +23,7 @@ export default async function loadSR(
|
||||
|
||||
microscopySRDisplaySet.isLoaded = true;
|
||||
|
||||
const { rois, labels } = await _getROIsFromToolState(
|
||||
naturalizedDataset,
|
||||
FrameOfReferenceUID
|
||||
);
|
||||
const { rois, labels } = await _getROIsFromToolState(naturalizedDataset, FrameOfReferenceUID);
|
||||
|
||||
const managedViewer = managedViewers[0];
|
||||
|
||||
@@ -58,9 +52,7 @@ async function _getROIsFromToolState(naturalizedDataset, FrameOfReferenceUID) {
|
||||
/* webpackChunkName: "dicom-microscopy-viewer" */ 'dicom-microscopy-viewer'
|
||||
);
|
||||
|
||||
const measurementGroupContentItems = _getMeasurementGroups(
|
||||
naturalizedDataset
|
||||
);
|
||||
const measurementGroupContentItems = _getMeasurementGroups(naturalizedDataset);
|
||||
|
||||
const rois = [];
|
||||
const labels = [];
|
||||
@@ -71,17 +63,13 @@ async function _getROIsFromToolState(naturalizedDataset, FrameOfReferenceUID) {
|
||||
|
||||
const capsToolType = t.toUpperCase();
|
||||
|
||||
const measurementGroupContentItemsForTool = measurementGroupContentItems.filter(
|
||||
mg => {
|
||||
const imageRegionContentItem = toArray(mg.ContentSequence).find(
|
||||
ci =>
|
||||
ci.ConceptNameCodeSequence.CodeValue ===
|
||||
DCM_CODE_VALUES.IMAGE_REGION
|
||||
);
|
||||
const measurementGroupContentItemsForTool = measurementGroupContentItems.filter(mg => {
|
||||
const imageRegionContentItem = toArray(mg.ContentSequence).find(
|
||||
ci => ci.ConceptNameCodeSequence.CodeValue === DCM_CODE_VALUES.IMAGE_REGION
|
||||
);
|
||||
|
||||
return imageRegionContentItem.GraphicType === capsToolType;
|
||||
}
|
||||
);
|
||||
return imageRegionContentItem.GraphicType === capsToolType;
|
||||
});
|
||||
|
||||
toolSpecificToolState.forEach((coordinates, index) => {
|
||||
const properties = {};
|
||||
@@ -109,9 +97,7 @@ async function _getROIsFromToolState(naturalizedDataset, FrameOfReferenceUID) {
|
||||
);
|
||||
|
||||
const trackingGroup = toArray(measurementGroup.ContentSequence).find(
|
||||
ci =>
|
||||
ci.ConceptNameCodeSequence.CodeValue ===
|
||||
DCM_CODE_VALUES.TRACKING_UNIQUE_IDENTIFIER
|
||||
ci => ci.ConceptNameCodeSequence.CodeValue === DCM_CODE_VALUES.TRACKING_UNIQUE_IDENTIFIER
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -138,9 +124,7 @@ async function _getROIsFromToolState(naturalizedDataset, FrameOfReferenceUID) {
|
||||
);
|
||||
|
||||
let evaluations = toArray(measurementGroup.ContentSequence).filter(ci =>
|
||||
[DCM_CODE_VALUES.TRACKING_UNIQUE_IDENTIFIER].includes(
|
||||
ci.ConceptNameCodeSequence.CodeValue
|
||||
)
|
||||
[DCM_CODE_VALUES.TRACKING_UNIQUE_IDENTIFIER].includes(ci.ConceptNameCodeSequence.CodeValue)
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -191,17 +175,12 @@ function _getMeasurementGroups(naturalizedDataset) {
|
||||
const { ContentSequence } = naturalizedDataset;
|
||||
|
||||
const imagingMeasurementsContentItem = ContentSequence.find(
|
||||
ci =>
|
||||
ci.ConceptNameCodeSequence.CodeValue ===
|
||||
DCM_CODE_VALUES.IMAGING_MEASUREMENTS
|
||||
ci => ci.ConceptNameCodeSequence.CodeValue === DCM_CODE_VALUES.IMAGING_MEASUREMENTS
|
||||
);
|
||||
|
||||
const measurementGroupContentItems = toArray(
|
||||
imagingMeasurementsContentItem.ContentSequence
|
||||
).filter(
|
||||
ci =>
|
||||
ci.ConceptNameCodeSequence.CodeValue === DCM_CODE_VALUES.MEASUREMENT_GROUP
|
||||
);
|
||||
).filter(ci => ci.ConceptNameCodeSequence.CodeValue === DCM_CODE_VALUES.MEASUREMENT_GROUP);
|
||||
|
||||
return measurementGroupContentItems;
|
||||
}
|
||||
Reference in new issue
Block a user