From d2d7d20174b9a681880ae20a0b5bd81b8aa3a721 Mon Sep 17 00:00:00 2001 From: SACHIDANAND ALLE Date: Mon, 18 Nov 2024 18:04:23 -0800 Subject: [PATCH] Fix ES lint issues (#1784) Signed-off-by: Sachidanand Alle --- .../src/components/ModelSelector.tsx | 9 ++-- .../src/components/MonaiLabelPanel.tsx | 19 +++---- .../src/components/SegmentationToolbox.tsx | 46 ++++++++++------- .../src/components/SettingsTable.tsx | 8 +-- .../Toolbox/ThresholdSettingsPreset.tsx | 17 ++++--- .../src/components/actions/ActiveLearning.tsx | 41 ++++++--------- .../components/actions/AutoSegmentation.tsx | 10 ++-- .../src/components/actions/BaseTab.tsx | 13 +++-- .../src/components/actions/NextSampleForm.tsx | 10 ++-- .../src/components/actions/OptionTable.tsx | 30 ++++++----- .../src/components/actions/SmartEdit.tsx | 40 ++++++++------- .../src/components/callInputDialog.tsx | 6 +-- .../src/components/colorPickerDialog.tsx | 2 +- .../monai-label/src/getCommandsModule.ts | 18 +++---- .../monai-label/src/getPanelModule.tsx | 8 ++- .../extensions/monai-label/src/index.tsx | 1 - .../ohifv3/extensions/monai-label/src/init.ts | 4 +- .../src/services/MonaiLabelClient.js | 3 +- .../src/utils/GenericAnatomyColors.js | 1 - .../monai-label/src/utils/GenericUtils.js | 20 +++++--- .../src/utils/SegmentationReader.js | 4 +- .../src/utils/SegmentationUtils.tsx | 50 ++++++++----------- .../ohifv3/modes/monai-label/babel.config.js | 6 +-- .../ohifv3/modes/monai-label/src/index.tsx | 2 +- .../modes/monai-label/src/toolbarButtons.js | 2 +- 25 files changed, 187 insertions(+), 183 deletions(-) diff --git a/plugins/ohifv3/extensions/monai-label/src/components/ModelSelector.tsx b/plugins/ohifv3/extensions/monai-label/src/components/ModelSelector.tsx index c2371f336..b70475148 100644 --- a/plugins/ohifv3/extensions/monai-label/src/components/ModelSelector.tsx +++ b/plugins/ohifv3/extensions/monai-label/src/components/ModelSelector.tsx @@ -1,4 +1,3 @@ - import React, { Component } from 'react'; import PropTypes from 'prop-types'; @@ -41,9 +40,11 @@ export default class ModelSelector extends Component { return null; } - onChangeModel = evt => { + onChangeModel = (evt) => { this.setState({ currentModel: evt.target.value }); - if (this.props.onSelectModel) this.props.onSelectModel(evt.target.value); + if (this.props.onSelectModel) { + this.props.onSelectModel(evt.target.value); + } }; currentModel = () => { @@ -84,7 +85,7 @@ export default class ModelSelector extends Component { onChange={this.onChangeModel} value={currentModel} > - {this.props.models.map(model => ( + {this.props.models.map((model) => ( diff --git a/plugins/ohifv3/extensions/monai-label/src/components/MonaiLabelPanel.tsx b/plugins/ohifv3/extensions/monai-label/src/components/MonaiLabelPanel.tsx index f62e3f5d6..5a13d1f54 100644 --- a/plugins/ohifv3/extensions/monai-label/src/components/MonaiLabelPanel.tsx +++ b/plugins/ohifv3/extensions/monai-label/src/components/MonaiLabelPanel.tsx @@ -121,7 +121,7 @@ export default class MonaiLabelPanel extends Component { const response = await this.client().info(); // remove the background - const labels = response.data.labels.splice(1) + const labels = response.data.labels.splice(1); const segmentations = [ { @@ -129,7 +129,7 @@ export default class MonaiLabelPanel extends Component { label: 'Segmentations', segments: labels.map((label, index) => ({ segmentIndex: index + 1, - label + label, })), isActive: true, activeSegmentIndex: 1, @@ -137,7 +137,7 @@ export default class MonaiLabelPanel extends Component { ]; this.props.commandsManager.runCommand('loadSegmentationsForViewport', { - segmentations + segmentations, }); if (response.status !== 200) { @@ -163,16 +163,18 @@ export default class MonaiLabelPanel extends Component { // Leave Event for (const action of Object.keys(this.actions)) { if (this.state.action === action) { - if (this.actions[action].current) + if (this.actions[action].current) { this.actions[action].current.onLeaveActionTab(); + } } } // Enter Event for (const action of Object.keys(this.actions)) { if (name === action) { - if (this.actions[action].current) + if (this.actions[action].current) { this.actions[action].current.onEnterActionTab(); + } } } this.setState({ action: name }); @@ -193,11 +195,10 @@ export default class MonaiLabelPanel extends Component { console.info('These are the predicted labels'); console.info(onInfoLabelNames); - if (onInfoLabelNames.hasOwnProperty('background')){ -delete onInfoLabelNames.background; + if (onInfoLabelNames.hasOwnProperty('background')) { + delete onInfoLabelNames.background; } - const ret = SegmentationReader.parseNrrdData(response.data); if (!ret) { @@ -248,7 +249,7 @@ delete onInfoLabelNames.background; }; _debug = async () => { - let nrrdFetch = await fetch('http://localhost:3000/pred2.nrrd'); + const nrrdFetch = await fetch('http://localhost:3000/pred2.nrrd'); const info = { spleen: 1, diff --git a/plugins/ohifv3/extensions/monai-label/src/components/SegmentationToolbox.tsx b/plugins/ohifv3/extensions/monai-label/src/components/SegmentationToolbox.tsx index 4577a56b7..338b389ab 100644 --- a/plugins/ohifv3/extensions/monai-label/src/components/SegmentationToolbox.tsx +++ b/plugins/ohifv3/extensions/monai-label/src/components/SegmentationToolbox.tsx @@ -83,11 +83,11 @@ function SegmentationToolbox({ servicesManager, extensionManager }) { const unsubscriptions = []; - events.forEach(event => { + events.forEach((event) => { const { unsubscribe } = segmentationService.subscribe(event, () => { const segmentations = segmentationService.getSegmentations(); - const activeSegmentation = segmentations?.find(seg => seg.isActive); + const activeSegmentation = segmentations?.find((seg) => seg.isActive); setToolsEnabled(activeSegmentation?.segmentCount > 0); }); @@ -96,7 +96,7 @@ function SegmentationToolbox({ servicesManager, extensionManager }) { }); return () => { - unsubscriptions.forEach(unsubscribe => unsubscribe()); + unsubscriptions.forEach((unsubscribe) => unsubscribe()); }; }, [activeViewportId, viewports, segmentationService]); @@ -117,7 +117,7 @@ function SegmentationToolbox({ servicesManager, extensionManager }) { }, [toolbarService, updateActiveTool]); const setToolActive = useCallback( - toolName => { + (toolName) => { toolbarService.recordInteraction({ groupId: 'SegmentationTools', itemId: 'Brush', @@ -139,8 +139,12 @@ function SegmentationToolbox({ servicesManager, extensionManager }) { const updateBrushSize = useCallback( (toolName, brushSize) => { - toolGroupService.getToolGroupIds()?.forEach(toolGroupId => { - segmentationUtils.setBrushSizeForToolGroup(toolGroupId, brushSize, toolName); + toolGroupService.getToolGroupIds()?.forEach((toolGroupId) => { + segmentationUtils.setBrushSizeForToolGroup( + toolGroupId, + brushSize, + toolName + ); }); }, [toolGroupService] @@ -150,7 +154,7 @@ function SegmentationToolbox({ servicesManager, extensionManager }) { (valueAsStringOrNumber, toolCategory) => { const value = Number(valueAsStringOrNumber); - _getToolNamesFromCategory(toolCategory).forEach(toolName => { + _getToolNamesFromCategory(toolCategory).forEach((toolName) => { updateBrushSize(toolName, value); }); @@ -166,7 +170,7 @@ function SegmentationToolbox({ servicesManager, extensionManager }) { ); const handleRangeChange = useCallback( - newRange => { + (newRange) => { if ( newRange[0] === state.ThresholdBrush.thresholdRange[0] && newRange[1] === state.ThresholdBrush.thresholdRange[1] @@ -176,8 +180,8 @@ function SegmentationToolbox({ servicesManager, extensionManager }) { const toolNames = _getToolNamesFromCategory('ThresholdBrush'); - toolNames.forEach(toolName => { - toolGroupService.getToolGroupIds()?.forEach(toolGroupId => { + toolNames.forEach((toolName) => { + toolGroupService.getToolGroupIds()?.forEach((toolGroupId) => { const toolGroup = toolGroupService.getToolGroup(toolGroupId); toolGroup.setToolConfiguration(toolName, { strategySpecificConfiguration: { @@ -208,7 +212,9 @@ function SegmentationToolbox({ servicesManager, extensionManager }) { name: 'Brush', icon: 'icon-tool-brush', disabled: !toolsEnabled, - active: state.activeTool === 'CircularBrush' || state.activeTool === 'SphereBrush', + active: + state.activeTool === 'CircularBrush' || + state.activeTool === 'SphereBrush', onClick: () => setToolActive('CircularBrush'), options: [ { @@ -219,7 +225,7 @@ function SegmentationToolbox({ servicesManager, extensionManager }) { max: 100, value: state.Brush.brushSize, step: 0.5, - onChange: value => onBrushSizeChange(value, 'Brush'), + onChange: (value) => onBrushSizeChange(value, 'Brush'), }, { name: 'Mode', @@ -230,7 +236,7 @@ function SegmentationToolbox({ servicesManager, extensionManager }) { { value: 'CircularBrush', label: 'Circle' }, { value: 'SphereBrush', label: 'Sphere' }, ], - onChange: value => setToolActive(value), + onChange: (value) => setToolActive(value), }, ], }, @@ -238,7 +244,9 @@ function SegmentationToolbox({ servicesManager, extensionManager }) { name: 'Eraser', icon: 'icon-tool-eraser', disabled: !toolsEnabled, - active: state.activeTool === 'CircularEraser' || state.activeTool === 'SphereEraser', + active: + state.activeTool === 'CircularEraser' || + state.activeTool === 'SphereEraser', onClick: () => setToolActive('CircularEraser'), options: [ { @@ -249,7 +257,7 @@ function SegmentationToolbox({ servicesManager, extensionManager }) { max: 100, value: state.Eraser.brushSize, step: 0.5, - onChange: value => onBrushSizeChange(value, 'Eraser'), + onChange: (value) => onBrushSizeChange(value, 'Eraser'), }, { name: 'Mode', @@ -260,7 +268,7 @@ function SegmentationToolbox({ servicesManager, extensionManager }) { { value: 'CircularEraser', label: 'Circle' }, { value: 'SphereEraser', label: 'Sphere' }, ], - onChange: value => setToolActive(value), + onChange: (value) => setToolActive(value), }, ], }, @@ -284,7 +292,7 @@ function SegmentationToolbox({ servicesManager, extensionManager }) { { value: 'RectangleScissor', label: 'Rectangle' }, { value: 'SphereScissor', label: 'Sphere' }, ], - onChange: value => setToolActive(value), + onChange: (value) => setToolActive(value), }, ], }, @@ -305,7 +313,7 @@ function SegmentationToolbox({ servicesManager, extensionManager }) { max: 100, value: state.ThresholdBrush.brushSize, step: 0.5, - onChange: value => onBrushSizeChange(value, 'ThresholdBrush'), + onChange: (value) => onBrushSizeChange(value, 'ThresholdBrush'), }, { name: 'Mode', @@ -316,7 +324,7 @@ function SegmentationToolbox({ servicesManager, extensionManager }) { { value: 'ThresholdCircularBrush', label: 'Circle' }, { value: 'ThresholdSphereBrush', label: 'Sphere' }, ], - onChange: value => setToolActive(value), + onChange: (value) => setToolActive(value), }, { type: 'custom', diff --git a/plugins/ohifv3/extensions/monai-label/src/components/SettingsTable.tsx b/plugins/ohifv3/extensions/monai-label/src/components/SettingsTable.tsx index d5db4bc9a..12fe1a284 100644 --- a/plugins/ohifv3/extensions/monai-label/src/components/SettingsTable.tsx +++ b/plugins/ohifv3/extensions/monai-label/src/components/SettingsTable.tsx @@ -8,8 +8,8 @@ export default class SettingsTable extends Component { constructor(props) { super(props); - const onInfo = props.onInfo - this.onInfo = onInfo + const onInfo = props.onInfo; + this.onInfo = onInfo; this.state = this.getSettings(); } @@ -35,8 +35,8 @@ export default class SettingsTable extends Component { }; }; - onBlurSeverURL = evt => { - let url = evt.target.value; + onBlurSeverURL = (evt) => { + const url = evt.target.value; this.setState({ url: url }); CookieUtils.setCookie('MONAILABEL_SERVER_URL', url); }; diff --git a/plugins/ohifv3/extensions/monai-label/src/components/Toolbox/ThresholdSettingsPreset.tsx b/plugins/ohifv3/extensions/monai-label/src/components/Toolbox/ThresholdSettingsPreset.tsx index f708233c3..63670c9f6 100644 --- a/plugins/ohifv3/extensions/monai-label/src/components/Toolbox/ThresholdSettingsPreset.tsx +++ b/plugins/ohifv3/extensions/monai-label/src/components/Toolbox/ThresholdSettingsPreset.tsx @@ -33,16 +33,19 @@ function ThresholdSettings({ onRangeChange }) { const [options, setOptions] = useState(defaultOptions); const [selectedPreset, setSelectedPreset] = useState(defaultOptions[0].value); - const handleRangeChange = newRange => { - const selectedOption = options.find(o => o.value === selectedPreset); + const handleRangeChange = (newRange) => { + const selectedOption = options.find((o) => o.value === selectedPreset); - if (newRange[0] === selectedOption.range[0] && newRange[1] === selectedOption.range[1]) { + if ( + newRange[0] === selectedOption.range[0] && + newRange[1] === selectedOption.range[1] + ) { return; } onRangeChange(newRange); - const updatedOptions = options.map(o => { + const updatedOptions = options.map((o) => { if (o.value === selectedPreset) { return { ...o, @@ -55,7 +58,9 @@ function ThresholdSettings({ onRangeChange }) { setOptions(updatedOptions); }; - const selectedPresetRange = options.find(ds => ds.value === selectedPreset).range; + const selectedPresetRange = options.find( + (ds) => ds.value === selectedPreset + ).range; return (
@@ -66,7 +71,7 @@ function ThresholdSettings({ onRangeChange }) { isClearable={false} onChange={handlePresetChange} options={options} - value={options.find(ds => ds.value === selectedPreset)} + value={options.find((ds) => ds.value === selectedPreset)} className="text-white" isSearchable={false} /> diff --git a/plugins/ohifv3/extensions/monai-label/src/components/actions/ActiveLearning.tsx b/plugins/ohifv3/extensions/monai-label/src/components/actions/ActiveLearning.tsx index dd0bd2fc4..9925c1146 100644 --- a/plugins/ohifv3/extensions/monai-label/src/components/actions/ActiveLearning.tsx +++ b/plugins/ohifv3/extensions/monai-label/src/components/actions/ActiveLearning.tsx @@ -16,9 +16,7 @@ import React from 'react'; import './ActiveLearning.css'; import BaseTab from './BaseTab'; import NextSampleForm from './NextSampleForm'; -import { - createSegmentMetadata, -} from '../../utils/SegmentationUtils'; +import { createSegmentMetadata } from '../../utils/SegmentationUtils'; export default class OptionTable extends BaseTab { constructor(props) { @@ -30,15 +28,15 @@ export default class OptionTable extends BaseTab { }; } - onChangeStrategy = evt => { + onChangeStrategy = (evt) => { this.setState({ strategy: evt.target.value }); }; - onSegmentSelected = id => { + onSegmentSelected = (id) => { this.setState({ segmentId: id }); }; - onSegmentDeleted = id => { + onSegmentDeleted = (id) => { this.setState({ segmentId: null }); }; @@ -112,8 +110,7 @@ export default class OptionTable extends BaseTab { }; onClickSubmitLabel = async () => { - - const labelmaps3D = cornerstone.cache.getVolume('1') + const labelmaps3D = cornerstone.cache.getVolume('1'); if (!labelmaps3D) { console.info('LabelMap3D is empty.. so zero segments'); @@ -127,19 +124,15 @@ export default class OptionTable extends BaseTab { duration: 5000, }); - const labelNames = this.props.info.labels + const labelNames = this.props.info.labels; const segments = []; for (let i = 0; i < labelNames.length; i++) { if (labelNames[i] === 'background') { console.debug('Ignore Background...'); continue; } - let segment = createSegmentMetadata( - labelNames[i], - i, - '' - ) - segments.push(segment) + const segment = createSegmentMetadata(labelNames[i], i, ''); + segments.push(segment); } const params = { label_info: segments }; @@ -150,9 +143,7 @@ export default class OptionTable extends BaseTab { type: 'application/octet-stream', }); - const response = await this.props - .client() - .save_label(image, label, params); + const response = await this.props.client().save_label(image, label, params); if (response.status !== 200) { this.notification.show({ @@ -181,7 +172,7 @@ export default class OptionTable extends BaseTab { ? this.state.segmentId : getFirstSegmentId(this.props.viewConstants.element); */ - const segmentId = this.state.segmentId + const segmentId = this.state.segmentId; const ds = this.props.info.datastore; const completed = ds && ds.completed ? ds.completed : 0; @@ -231,7 +222,7 @@ export default class OptionTable extends BaseTab {