Skip to content

Commit c20e79f

Browse files
committed
fix: compute image stats for SEG DICOM files
Changed image-stats to watch activeScalars directly instead of using useVtkComputed. This ensures stats are computed when SEG images replace their vtkImageData object after loading, fixing the paint tool error when selecting segmentation files.
1 parent 19d50e4 commit c20e79f

4 files changed

Lines changed: 7 additions & 18 deletions

File tree

‎src/components/DicomQuickInfoButton.vue‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,3 @@ const dicomInfo = computed(() => {
9292
</template>
9393

9494
<style scoped src="@/src/components/styles/utils.css"></style>
95-
<style scoped></style>

‎src/components/LayoutGrid.vue‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { computed, defineComponent, PropType, toRefs } from 'vue';
1818
import { Layout } from '@/src/types/layout';
1919
import { useViewStore } from '@/src/store/views';
2020
import { useToolStore } from '@/src/store/tools';
21-
import { ALLOW_MAXIMIZE_TOOLS } from '@/src/config';
21+
import { Tools } from '@/src/store/tools/types';
2222
import LayoutGridItem from '@/src/components/LayoutGridItem.vue';
2323
2424
export default defineComponent({
@@ -32,7 +32,7 @@ export default defineComponent({
3232
},
3333
maximize(id: string) {
3434
const currentTool = useToolStore().currentTool;
35-
if (ALLOW_MAXIMIZE_TOOLS.includes(currentTool)) {
35+
if (currentTool !== Tools.Polygon) {
3636
useViewStore().setActiveView(id);
3737
useViewStore().toggleActiveViewMaximized();
3838
}

‎src/config.ts‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import type { Layout } from './types/layout';
88
import type { ViewInfoInit } from './types/views';
99
import { SampleDataset } from './types';
1010
import { Action } from './constants';
11-
import { Tools } from './store/tools/types';
1211

1312
/**
1413
* These are the initial view IDs.
@@ -231,14 +230,6 @@ export const ACTION_TO_KEY = {
231230
showKeyboardShortcuts: '?',
232231
} satisfies Record<Action, string>;
233232

234-
export const ALLOW_MAXIMIZE_TOOLS = [
235-
Tools.WindowLevel,
236-
Tools.Pan,
237-
Tools.Zoom,
238-
Tools.Select,
239-
Tools.Crosshairs,
240-
];
241-
242233
export const DEFAULT_SEGMENT_MASKS: SegmentMask[] = [
243234
{
244235
value: 1,

‎src/store/image-stats.ts‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
import * as Comlink from 'comlink';
1212
import vtkDataArray from '@kitware/vtk.js/Common/Core/DataArray';
1313
import vtkImageData from '@kitware/vtk.js/Common/DataModel/ImageData';
14-
import { useVtkComputed } from '@/src/core/vtk/useVtkComputed';
1514
import { WLAutoRanges, WL_HIST_BINS } from '@/src/constants';
1615
import { HistogramWorker } from '@/src/utils/histogram.worker';
1716
import { Maybe } from '@/src/types';
@@ -134,13 +133,13 @@ export const useImageStatsStore = defineStore('image-stats', () => {
134133
const activeScalars = computed(() =>
135134
imageData.value?.getPointData()?.getScalars()
136135
);
137-
const scalarRange = useVtkComputed(activeScalars, () =>
138-
activeScalars.value?.getRange(0)
139-
);
140136

141137
watch(
142-
scalarRange,
143-
(range) => {
138+
activeScalars,
139+
(scalars) => {
140+
if (!scalars) return;
141+
142+
const range = scalars.getRange(0);
144143
if (range) {
145144
internalSetScalarRange(id, range[0], range[1]);
146145
}

0 commit comments

Comments
 (0)