Skip to content

Commit 53b28dd

Browse files
committed
refactor: general cleanup
1 parent 564f8d6 commit 53b28dd

4 files changed

Lines changed: 71 additions & 69 deletions

File tree

src/components/tools/ScalarProbe.vue

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -118,47 +118,49 @@ const getImageSamples = (x: number, y: number) => {
118118
firstToSample.image.indexToWorld(pickedIjk) as vec3
119119
);
120120
121-
const samples = sampleSet.value.map((item: any) => {
122-
// Convert world position to this specific image's IJK
123-
const itemIjk = worldPointToIndex(item.image, worldPosition);
124-
const dims = item.image.getDimensions();
125-
const scalarData = item.image.getPointData().getScalars();
126-
127-
// Round to nearest integer indices
128-
const i = Math.round(itemIjk[0]);
129-
const j = Math.round(itemIjk[1]);
130-
const k = Math.round(itemIjk[2]);
131-
132-
// Check bounds
133-
if (
134-
i < 0 ||
135-
j < 0 ||
136-
k < 0 ||
137-
i >= dims[0] ||
138-
j >= dims[1] ||
139-
k >= dims[2]
140-
) {
141-
return null;
142-
}
143-
144-
const index = dims[0] * dims[1] * k + dims[0] * j + i;
145-
const scalars = scalarData.getTuple(index) as number[];
146-
const baseInfo = { id: item.id, name: item.name };
147-
148-
if (item.type === 'segmentGroup') {
149-
return {
150-
...baseInfo,
151-
displayValues: scalars.map(
152-
(v) => item.segments.byValue[v]?.name || 'Background'
153-
),
154-
};
155-
}
156-
return { ...baseInfo, displayValues: scalars };
157-
});
121+
const samples = sampleSet.value
122+
.map((item: any) => {
123+
// Convert world position to this specific image's IJK
124+
const itemIjk = worldPointToIndex(item.image, worldPosition);
125+
const dims = item.image.getDimensions();
126+
const scalarData = item.image.getPointData().getScalars();
127+
128+
// Round to nearest integer indices
129+
const i = Math.round(itemIjk[0]);
130+
const j = Math.round(itemIjk[1]);
131+
const k = Math.round(itemIjk[2]);
132+
133+
// Check bounds
134+
if (
135+
i < 0 ||
136+
j < 0 ||
137+
k < 0 ||
138+
i >= dims[0] ||
139+
j >= dims[1] ||
140+
k >= dims[2]
141+
) {
142+
return null;
143+
}
144+
145+
const index = dims[0] * dims[1] * k + dims[0] * j + i;
146+
const scalars = scalarData.getTuple(index) as number[];
147+
const baseInfo = { id: item.id, name: item.name };
148+
149+
if (item.type === 'segmentGroup') {
150+
return {
151+
...baseInfo,
152+
displayValues: scalars.map(
153+
(v) => item.segments.byValue[v]?.name || 'Background'
154+
),
155+
};
156+
}
157+
return { ...baseInfo, displayValues: scalars };
158+
})
159+
.filter((s): s is NonNullable<typeof s> => s !== null);
158160
159161
return {
160162
pos: worldPosition,
161-
samples: samples.filter((s): s is NonNullable<typeof s> => s !== null),
163+
samples,
162164
};
163165
};
164166

src/components/vtk/VtkSegmentationSliceRepresentation.vue

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -111,22 +111,19 @@ watchEffect(() => {
111111
const slice = vtkFieldRef(sliceRep.mapper, 'slice');
112112
const { slice: storedSlice } = useSliceConfig(viewId, parentImageId);
113113
114-
watchImmediate(
115-
[storedSlice, labelmapLpsOrientation, () => parentMetadata.value],
116-
() => {
117-
const parentImage = parentMetadata.value;
118-
const labelmap = imageData.value;
119-
if (!parentImage || !labelmap || storedSlice.value == null) return;
120-
121-
slice.value = convertSliceIndex(
122-
storedSlice.value,
123-
parentImage.lpsOrientation,
124-
parentImage.indexToWorld,
125-
labelmap,
126-
axis.value
127-
);
128-
}
129-
);
114+
watchImmediate([storedSlice, labelmapLpsOrientation, parentMetadata], () => {
115+
const parentImage = parentMetadata.value;
116+
const labelmap = imageData.value;
117+
if (!parentImage || !labelmap || storedSlice.value == null) return;
118+
119+
slice.value = convertSliceIndex(
120+
storedSlice.value,
121+
parentImage.lpsOrientation,
122+
parentImage.indexToWorld,
123+
labelmap,
124+
axis.value
125+
);
126+
});
130127
131128
// set coloring properties
132129
const applySegmentColoring = () => {

src/io/import/dataSource.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,57 +5,58 @@ import { Maybe } from '@/src/types';
55
/**
66
* Represents a URI source with a file name for the downloaded resource.
77
*/
8-
export interface UriSource {
8+
export type UriSource = {
99
type: 'uri';
1010
uri: string;
1111
name: string;
1212
mime?: string;
1313
fetcher?: Fetcher;
14-
}
14+
};
1515

1616
/**
1717
* Represents a user-specified file.
1818
*/
19-
export interface FileSource {
19+
export type FileSource = {
2020
type: 'file';
2121
file: File;
2222
fileType: string;
23-
}
23+
};
2424

2525
/**
2626
* Represents an archive member. The parent should exist and be a FileSource.
2727
*/
28-
export interface ArchiveSource {
28+
export type ArchiveSource = {
2929
type: 'archive';
30-
// Full path + filename inside the archive
3130
path: string;
3231
parent: FileSource;
33-
}
32+
};
3433

3534
/**
3635
* Represents a collection of data sources.
3736
*
3837
* This is used for data that is derived from a collection of data sources,
3938
* e.g. reconstructed DICOM.
4039
*/
41-
export interface CollectionSource {
40+
export type CollectionSource = {
4241
type: 'collection';
43-
4442
sources: DataSource[];
45-
}
43+
};
4644

4745
/**
4846
* Represents a data chunk for further processing and import.
4947
*/
50-
export interface ChunkSource {
48+
export type ChunkSource = {
5149
type: 'chunk';
5250
chunk: Chunk;
5351
mime: string;
54-
}
52+
};
5553

56-
export interface StateFileLeaf {
54+
/**
55+
* Used to map DICOM volumes back to state file datasets.
56+
*/
57+
export type StateFileLeaf = {
5758
stateID: string;
58-
}
59+
};
5960

6061
/**
6162
* Represents a source of data.

wdio.shared.conf.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ export const TEST_PORT = 4567;
3636
// DOWNLOAD_TIMEOUT=60000 && npm run test:e2e:dev
3737
export const DOWNLOAD_TIMEOUT = Number(process.env.DOWNLOAD_TIMEOUT ?? 20000);
3838

39+
const IS_CI = !!(process.env.CI || process.env.GITHUB_ACTIONS);
40+
3941
const ROOT = projectRoot();
4042
const TMP = '.tmp/';
4143
// TEMP_DIR is also browser downloads directory
@@ -59,7 +61,7 @@ export const config: Options.Testrunner = {
5961
// ============
6062
// Capabilities
6163
// ============
62-
maxInstances: 1,
64+
maxInstances: IS_CI ? 1 : 6,
6365
//
6466
// ===================
6567
// Test Configurations

0 commit comments

Comments
 (0)