fix(typescript): rename services to fix typescript (#3165)

* fix: Rename services to lower camel case, hp, measure

* fix: Rename DisplaySetService instances to displaySetService

* fix: Rename CornerstoneViewportService to lower camel case

* fix: Added lower case segmentationService rename

* rename other services (#3166)

* rename uiDialogService

* rename toolGroupService

* rename uiNotificationService

* rename viewportGridService

* rename syncGroupService

* rename CornerstoneCacheService

* Fix a syntax error in hotkeys

* Fix a couple of rename issues that were missed

---------

Co-authored-by: Alireza <ar.sedghi@gmail.com>
This commit is contained in:
Bill WallaceandAlireza authored and GitHub committed 2023-02-10 16:46:09 -05:00
1 parent a97fb2fc9a
commit 8af0362d12
97 files changed
+934 -908

No files matched your search

+1 -1
View File
@@ -30,7 +30,7 @@
"peerDependencies": {
"@ohif/core": "^3.0.0",
"@ohif/ui": "^2.0.0",
"dcmjs": "^0.28.3",
"dcmjs": "0.29.4",
"dicom-parser": "^1.8.9",
"hammerjs": "^2.0.8",
"prop-types": "^15.6.2",
+10 -10
View File
@@ -25,10 +25,10 @@ const DEFAULT_MEATADATA = {
export default function PanelPetSUV({ servicesManager, commandsManager }) {
const { t } = useTranslation('PanelSUV');
const {
DisplaySetService,
ToolGroupService,
displaySetService,
toolGroupService,
toolbarService,
HangingProtocolService,
hangingProtocolService,
} = (servicesManager as ServicesManager).services;
const [metadata, setMetadata] = useState(DEFAULT_MEATADATA);
const [ptDisplaySet, setPtDisplaySet] = useState(null);
@@ -70,8 +70,8 @@ export default function PanelPetSUV({ servicesManager, commandsManager }) {
};
useEffect(() => {
const displaySets = DisplaySetService.getActiveDisplaySets();
const { viewportMatchDetails } = HangingProtocolService.getMatchDetails();
const displaySets = displaySetService.getActiveDisplaySets();
const { viewportMatchDetails } = hangingProtocolService.getMatchDetails();
if (!displaySets.length) {
return;
}
@@ -89,8 +89,8 @@ export default function PanelPetSUV({ servicesManager, commandsManager }) {
// get the patientMetadata from the StudyInstanceUIDs and update the state
useEffect(() => {
const { unsubscribe } = HangingProtocolService.subscribe(
HangingProtocolService.EVENTS.PROTOCOL_CHANGED,
const { unsubscribe } = hangingProtocolService.subscribe(
hangingProtocolService.EVENTS.PROTOCOL_CHANGED,
({ viewportMatchDetails }) => {
const displaySetInfo = getMatchingPTDisplaySet(viewportMatchDetails);
@@ -112,7 +112,7 @@ export default function PanelPetSUV({ servicesManager, commandsManager }) {
throw new Error('No ptDisplaySet found');
}
const toolGroupIds = ToolGroupService.getToolGroupIds();
const toolGroupIds = toolGroupService.getToolGroupIds();
// Todo: we don't have a proper way to perform a toggle command and update the
// state for the toolbar, so here, we manually toggle the toolbar
@@ -139,7 +139,7 @@ export default function PanelPetSUV({ servicesManager, commandsManager }) {
);
// update the displaySets
DisplaySetService.setDisplaySetMetadataInvalidated(
displaySetService.setDisplaySetMetadataInvalidated(
ptDisplaySet.displaySetInstanceUID
);
}
@@ -238,7 +238,7 @@ export default function PanelPetSUV({ servicesManager, commandsManager }) {
PanelPetSUV.propTypes = {
servicesManager: PropTypes.shape({
services: PropTypes.shape({
MeasurementService: PropTypes.shape({
measurementService: PropTypes.shape({
getMeasurements: PropTypes.func.isRequired,
subscribe: PropTypes.func.isRequired,
EVENTS: PropTypes.object.isRequired,
@@ -45,14 +45,14 @@ export default function PanelRoiThresholdSegmentation({
servicesManager,
commandsManager,
}) {
const { SegmentationService } = servicesManager.services;
const { segmentationService } = servicesManager.services;
const { t } = useTranslation('PanelSUV');
const [showConfig, setShowConfig] = useState(false);
const [labelmapLoading, setLabelmapLoading] = useState(false);
const [selectedSegmentationId, setSelectedSegmentationId] = useState(null);
const [segmentations, setSegmentations] = useState(() =>
SegmentationService.getSegmentations()
segmentationService.getSegmentations()
);
const [config, dispatch] = useReducer(reducer, {
@@ -90,7 +90,7 @@ export default function PanelRoiThresholdSegmentation({
const lesionGlyoclysisStats = lesionStats.volume * lesionStats.meanValue;
// update segDetails with the suv peak for the active segmentation
const segmentation = SegmentationService.getSegmentation(
const segmentation = segmentationService.getSegmentation(
selectedSegmentationId
);
@@ -101,7 +101,7 @@ export default function PanelRoiThresholdSegmentation({
};
const notYetUpdatedAtSource = true;
SegmentationService.addOrUpdateSegmentation(
segmentationService.addOrUpdateSegmentation(
{
...segmentation,
...Object.assign(segmentation.cachedStats, cachedStats),
@@ -118,13 +118,13 @@ export default function PanelRoiThresholdSegmentation({
*/
useEffect(() => {
// ~~ Subscription
const added = SegmentationService.EVENTS.SEGMENTATION_ADDED;
const updated = SegmentationService.EVENTS.SEGMENTATION_UPDATED;
const added = segmentationService.EVENTS.SEGMENTATION_ADDED;
const updated = segmentationService.EVENTS.SEGMENTATION_UPDATED;
const subscriptions = [];
[added, updated].forEach(evt => {
const { unsubscribe } = SegmentationService.subscribe(evt, () => {
const segmentations = SegmentationService.getSegmentations();
const { unsubscribe } = segmentationService.subscribe(evt, () => {
const segmentations = segmentationService.getSegmentations();
setSegmentations(segmentations);
});
subscriptions.push(unsubscribe);
@@ -138,10 +138,10 @@ export default function PanelRoiThresholdSegmentation({
}, []);
useEffect(() => {
const { unsubscribe } = SegmentationService.subscribe(
SegmentationService.EVENTS.SEGMENTATION_REMOVED,
const { unsubscribe } = segmentationService.subscribe(
segmentationService.EVENTS.SEGMENTATION_REMOVED,
() => {
const segmentations = SegmentationService.getSegmentations();
const segmentations = segmentationService.getSegmentations();
setSegmentations(segmentations);
if (segmentations.length > 0) {
@@ -223,15 +223,15 @@ export default function PanelRoiThresholdSegmentation({
setSelectedSegmentationId(id);
}}
onToggleVisibility={id => {
SegmentationService.toggleSegmentationVisibility(id);
segmentationService.toggleSegmentationVisibility(id);
}}
onToggleVisibilityAll={ids => {
ids.map(id => {
SegmentationService.toggleSegmentationVisibility(id);
segmentationService.toggleSegmentationVisibility(id);
});
}}
onDelete={id => {
SegmentationService.remove(id);
segmentationService.remove(id);
}}
onEdit={id => {
segmentationEditHandler({
@@ -285,7 +285,7 @@ PanelRoiThresholdSegmentation.propTypes = {
}),
servicesManager: PropTypes.shape({
services: PropTypes.shape({
SegmentationService: PropTypes.shape({
segmentationService: PropTypes.shape({
getSegmentation: PropTypes.func.isRequired,
getSegmentations: PropTypes.func.isRequired,
toggleSegmentationVisibility: PropTypes.func.isRequired,
@@ -2,14 +2,14 @@ import React from 'react';
import { Input, Dialog } from '@ohif/ui';
function segmentationItemEditHandler({ id, servicesManager }) {
const { SegmentationService, UIDialogService } = servicesManager.services;
const { segmentationService, uiDialogService } = servicesManager.services;
const segmentation = SegmentationService.getSegmentation(id);
const segmentation = segmentationService.getSegmentation(id);
const onSubmitHandler = ({ action, value }) => {
switch (action.id) {
case 'save': {
SegmentationService.addOrUpdateSegmentation(
segmentationService.addOrUpdateSegmentation(
{
...segmentation,
...value,
@@ -18,10 +18,10 @@ function segmentationItemEditHandler({ id, servicesManager }) {
);
}
}
UIDialogService.dismiss({ id: 'enter-annotation' });
uiDialogService.dismiss({ id: 'enter-annotation' });
};
UIDialogService.create({
uiDialogService.create({
id: 'enter-annotation',
centralize: true,
isDraggable: false,
+26 -26
View File
@@ -20,13 +20,13 @@ const commandsModule = ({
extensionManager,
}) => {
const {
ViewportGridService,
UINotificationService,
DisplaySetService,
HangingProtocolService,
ToolGroupService,
CornerstoneViewportService,
SegmentationService,
viewportGridService,
uiNotificationService,
displaySetService,
hangingProtocolService,
toolGroupService,
cornerstoneViewportService,
segmentationService,
} = servicesManager.services;
const utilityModule = extensionManager.getModuleEntry(
@@ -36,14 +36,14 @@ const commandsModule = ({
const { getEnabledElement } = utilityModule.exports;
function _getActiveViewportsEnabledElement() {
const { activeViewportIndex } = ViewportGridService.getState();
const { activeViewportIndex } = viewportGridService.getState();
const { element } = getEnabledElement(activeViewportIndex) || {};
const enabledElement = cs.getEnabledElement(element);
return enabledElement;
}
function _getMatchedViewportsToolGroupIds() {
const { viewportMatchDetails } = HangingProtocolService.getMatchDetails();
const { viewportMatchDetails } = hangingProtocolService.getMatchDetails();
const toolGroupIds = [];
viewportMatchDetails.forEach((value, key) => {
const { viewportOptions } = value;
@@ -67,7 +67,7 @@ const commandsModule = ({
for (const [viewportIndex, viewportDetails] of viewportMatchDetails) {
const { displaySetsInfo } = viewportDetails;
const displaySets = displaySetsInfo.map(({ displaySetInstanceUID }) =>
DisplaySetService.getDisplaySetByUID(displaySetInstanceUID)
displaySetService.getDisplaySetByUID(displaySetInstanceUID)
);
if (!displaySets || displaySets.length === 0) {
@@ -121,17 +121,17 @@ const commandsModule = ({
createNewLabelmapFromPT: async () => {
// Create a segmentation of the same resolution as the source data
// using volumeLoader.createAndCacheDerivedVolume.
const { viewportMatchDetails } = HangingProtocolService.getMatchDetails();
const { viewportMatchDetails } = hangingProtocolService.getMatchDetails();
const ptDisplaySet = actions.getMatchingPTDisplaySet({
viewportMatchDetails,
});
if (!ptDisplaySet) {
UINotificationService.error('No matching PT display set found');
uiNotificationService.error('No matching PT display set found');
return;
}
const segmentationId = await SegmentationService.createSegmentationForDisplaySet(
const segmentationId = await segmentationService.createSegmentationForDisplaySet(
ptDisplaySet.displaySetInstanceUID
);
@@ -142,14 +142,14 @@ const commandsModule = ({
for (const toolGroupId of toolGroupIds) {
const hydrateSegmentation = true;
await SegmentationService.addSegmentationRepresentationToToolGroup(
await segmentationService.addSegmentationRepresentationToToolGroup(
toolGroupId,
segmentationId,
hydrateSegmentation,
representationType
);
SegmentationService.setActiveSegmentationForToolGroup(
segmentationService.setActiveSegmentationForToolGroup(
segmentationId,
toolGroupId
);
@@ -161,7 +161,7 @@ const commandsModule = ({
const toolGroupIds = _getMatchedViewportsToolGroupIds();
toolGroupIds.forEach(toolGroupId => {
SegmentationService.setActiveSegmentationForToolGroup(
segmentationService.setActiveSegmentationForToolGroup(
segmentationId,
toolGroupId
);
@@ -193,7 +193,7 @@ const commandsModule = ({
);
if (annotationUIDs.length === 0) {
UINotificationService.show({
uiNotificationService.show({
title: 'Commands Module',
message: 'No ROIThreshold Tool is Selected',
type: 'error',
@@ -289,7 +289,7 @@ const commandsModule = ({
},
calculateTMTV: ({ segmentations }) => {
const labelmaps = segmentations.map(s =>
SegmentationService.getLabelmapVolume(s.id)
segmentationService.getLabelmapVolume(s.id)
);
if (!labelmaps.length) {
@@ -314,7 +314,7 @@ const commandsModule = ({
},
getTotalLesionGlycolysis: ({ segmentations }) => {
const labelmapVolumes = segmentations.map(s =>
SegmentationService.getLabelmapVolume(s.id)
segmentationService.getLabelmapVolume(s.id)
);
let mergedLabelmap;
@@ -448,7 +448,7 @@ const commandsModule = ({
},
getSegmentationCSVReport: ({ segmentations }) => {
if (!segmentations || !segmentations.length) {
segmentations = SegmentationService.getSegmentations();
segmentations = segmentationService.getSegmentations();
}
let report = {};
@@ -474,7 +474,7 @@ const commandsModule = ({
}
});
const labelmapVolume = SegmentationService.getLabelmapVolume(id);
const labelmapVolume = segmentationService.getLabelmapVolume(id);
if (!labelmapVolume) {
report[id] = segReport;
@@ -484,7 +484,7 @@ const commandsModule = ({
const referencedVolumeId = labelmapVolume.referencedVolumeId;
segReport.referencedVolumeId = referencedVolumeId;
const referencedVolume = SegmentationService.getLabelmapVolume(
const referencedVolume = segmentationService.getLabelmapVolume(
referencedVolumeId
);
@@ -525,8 +525,8 @@ const commandsModule = ({
dicomRTAnnotationExport(annotations);
},
setFusionPTColormap: ({ toolGroupId, colormap }) => {
const toolGroup = ToolGroupService.getToolGroup(toolGroupId);
const { viewportMatchDetails } = HangingProtocolService.getMatchDetails();
const toolGroup = toolGroupService.getToolGroup(toolGroupId);
const { viewportMatchDetails } = hangingProtocolService.getMatchDetails();
const ptDisplaySet = actions.getMatchingPTDisplaySet({
viewportMatchDetails,
@@ -540,7 +540,7 @@ const commandsModule = ({
let viewports = [];
fusionViewportIds.forEach(viewportId => {
const viewportInfo = CornerstoneViewportService.getViewportInfo(
const viewportInfo = cornerstoneViewportService.getViewportInfo(
viewportId
);
@@ -552,7 +552,7 @@ const commandsModule = ({
});
viewports.push(
CornerstoneViewportService.getCornerstoneViewport(viewportId)
cornerstoneViewportService.getCornerstoneViewport(viewportId)
);
});
+8 -8
View File
@@ -16,25 +16,25 @@ const CORNERSTONE_3D_TOOLS_SOURCE_VERSION = '0.1';
*/
export default function init({ servicesManager, extensionManager }) {
const {
MeasurementService,
DisplaySetService,
CornerstoneViewportService,
measurementService,
displaySetService,
cornerstoneViewportService,
} = servicesManager.services;
addTool(RectangleROIStartEndThresholdTool);
const { RectangleROIStartEndThreshold } = measurementServiceMappingsFactory(
MeasurementService,
DisplaySetService,
CornerstoneViewportService
measurementService,
displaySetService,
cornerstoneViewportService
);
const csTools3DVer1MeasurementSource = MeasurementService.getSource(
const csTools3DVer1MeasurementSource = measurementService.getSource(
CORNERSTONE_3D_TOOLS_SOURCE_NAME,
CORNERSTONE_3D_TOOLS_SOURCE_VERSION
);
MeasurementService.addMapping(
measurementService.addMapping(
csTools3DVer1MeasurementSource,
'RectangleROIStartEndThreshold',
RectangleROIStartEndThreshold.matchingCriteria,
@@ -12,8 +12,8 @@ const RectangleROIStartEndThreshold = {
*/
toMeasurement: (
csToolsEventDetail,
DisplaySetService,
CornerstoneViewportService
displaySetService,
cornerstoneViewportService
) => {
const { annotation, viewportId } = csToolsEventDetail;
const { metadata, data, annotationUID } = annotation;
@@ -36,19 +36,19 @@ const RectangleROIStartEndThreshold = {
StudyInstanceUID,
} = getSOPInstanceAttributes(
referencedImageId,
CornerstoneViewportService,
cornerstoneViewportService,
viewportId
);
let displaySet;
if (SOPInstanceUID) {
displaySet = DisplaySetService.getDisplaySetForSOPInstanceUID(
displaySet = displaySetService.getDisplaySetForSOPInstanceUID(
SOPInstanceUID,
SeriesInstanceUID
);
} else {
displaySet = DisplaySetService.getDisplaySetsForSeries(SeriesInstanceUID);
displaySet = displaySetService.getDisplaySetsForSeries(SeriesInstanceUID);
}
const { cachedStats } = data;
@@ -1,9 +1,9 @@
import RectangleROIStartEndThreshold from './RectangleROIStartEndThreshold';
const measurementServiceMappingsFactory = (
MeasurementService,
DisplaySetService,
CornerstoneViewportService
measurementService,
displaySetService,
cornerstoneViewportService
) => {
return {
RectangleROIStartEndThreshold: {
@@ -11,12 +11,12 @@ const measurementServiceMappingsFactory = (
toMeasurement: csToolsAnnotation =>
RectangleROIStartEndThreshold.toMeasurement(
csToolsAnnotation,
DisplaySetService,
CornerstoneViewportService
displaySetService,
cornerstoneViewportService
),
matchingCriteria: [
{
valueType: MeasurementService.VALUE_TYPES.ROI_THRESHOLD_MANUAL,
valueType: measurementService.VALUE_TYPES.ROI_THRESHOLD_MANUAL,
},
],
},