Skip to content

Commit d9c563a

Browse files
committed
refactor(segmentGroups): store archives under segmentations
1 parent f411cfc commit d9c563a

6 files changed

Lines changed: 21 additions & 15 deletions

File tree

src/components/SaveSegmentGroupDialog.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<v-form v-model="valid" @submit.prevent="saveSegmentGroup">
88
<v-text-field
99
v-model="fileName"
10-
hint="Filename used for downloads. Invalid filename characters are replaced automatically."
10+
hint="Filename used for downloads."
1111
label="Filename"
1212
:rules="[validFileName]"
1313
required

src/io/state-file/__tests__/segmentGroupArchivePath.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ describe('io/state-file/segmentGroupArchivePath', () => {
88

99
expect(
1010
makeSegmentGroupArchivePath('Liver: left/right*?', 'vti', usedPaths)
11-
).to.equal('labels/Liver left right.vti');
11+
).to.equal('segmentations/Liver left right.vti');
1212
});
1313

1414
it('deduplicates colliding sanitized names case-insensitively', () => {
1515
const usedPaths = new Set<string>();
1616

1717
expect(
1818
makeSegmentGroupArchivePath('Liver/Left', 'vti', usedPaths)
19-
).to.equal('labels/Liver Left.vti');
19+
).to.equal('segmentations/Liver Left.vti');
2020
expect(
2121
makeSegmentGroupArchivePath('liver:left', 'vti', usedPaths)
22-
).to.equal('labels/liver left (2).vti');
22+
).to.equal('segmentations/liver left (2).vti');
2323
});
2424
});
2525
});

src/io/state-file/segmentGroupArchivePath.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { normalize } from '@/src/utils/path';
22
import { sanitizeFileStem } from '@/src/io/fileName';
33

44
export const DEFAULT_SEGMENT_GROUP_ARCHIVE_STEM = 'Segment Group';
5+
const SEGMENT_GROUP_ARCHIVE_DIR = 'segmentations';
56

67
export function sanitizeSegmentGroupFileStem(
78
name: string,
@@ -22,10 +23,12 @@ export function makeSegmentGroupArchivePath(
2223
const stem = sanitizeSegmentGroupFileStem(name);
2324

2425
let index = 1;
25-
let path = normalize(`labels/${stem}.${extension}`);
26+
let path = normalize(`${SEGMENT_GROUP_ARCHIVE_DIR}/${stem}.${extension}`);
2627
while (usedPaths.has(makeArchivePathKey(path))) {
2728
index += 1;
28-
path = normalize(`labels/${stem} (${index}).${extension}`);
29+
path = normalize(
30+
`${SEGMENT_GROUP_ARCHIVE_DIR}/${stem} (${index}).${extension}`
31+
);
2932
}
3033

3134
usedPaths.add(makeArchivePathKey(path));

tests/pageobjects/volview.page.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Page from './page';
77

88
let lastId = 0;
99
const getId = () => {
10-
return lastId++;
10+
return `${process.pid}-${Date.now()}-${lastId++}`;
1111
};
1212

1313
export const setValueVueInput = async (
@@ -216,7 +216,10 @@ class VolViewPage extends Page {
216216
await confirm.click();
217217

218218
cleanuptotal.addCleanup(async () => {
219-
fs.unlinkSync(path.join(TEMP_DIR, fileName));
219+
const filePath = path.join(TEMP_DIR, fileName);
220+
if (fs.existsSync(filePath)) {
221+
fs.unlinkSync(filePath);
222+
}
220223
});
221224

222225
return fileName;

tests/specs/session-large-uri-base.e2e.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ const createSessionZip = async (
7878
segmentGroups: [
7979
{
8080
id: 'seg-1',
81-
path: 'labels/seg-1.nii.gz',
81+
path: 'segmentations/seg-1.nii.gz',
8282
metadata: {
8383
name: 'Annotation',
8484
parentImage: '0',
@@ -100,7 +100,7 @@ const createSessionZip = async (
100100

101101
const zip = new JSZip();
102102
zip.file('manifest.json', JSON.stringify(manifest, null, 2));
103-
zip.file('labels/seg-1.nii.gz', labelmapNiftiGz);
103+
zip.file('segmentations/seg-1.nii.gz', labelmapNiftiGz);
104104
return zip.generateAsync({ type: 'nodebuffer', compression: 'STORE' });
105105
};
106106

tests/specs/session-state-lifecycle.e2e.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,22 +133,22 @@ describe('Session state lifecycle', () => {
133133
await openUrls([PROSTATEX_DATASET]);
134134

135135
const segmentGroupName = 'Liver: left/right*?';
136-
const sanitizedFilePath = 'labels/Liver left right.vti';
136+
const sanitizedFilePath = 'segmentations/Liver left right.vti';
137137

138138
await volViewPage.createSegmentGroup(segmentGroupName);
139139

140140
const { manifest, zip } = await saveAndParseManifest();
141141
if (!zip) {
142142
throw new Error('Expected saved session zip to be available');
143143
}
144-
const labelMaps = manifest.labelMaps as Array<{
144+
const segmentGroups = manifest.segmentGroups as Array<{
145145
path: string;
146146
metadata: { name: string };
147147
}>;
148148

149-
expect(labelMaps.length).toEqual(1);
150-
expect(labelMaps[0].metadata.name).toEqual(segmentGroupName);
151-
expect(labelMaps[0].path).toEqual(sanitizedFilePath);
149+
expect(segmentGroups.length).toEqual(1);
150+
expect(segmentGroups[0].metadata.name).toEqual(segmentGroupName);
151+
expect(segmentGroups[0].path).toEqual(sanitizedFilePath);
152152
expect(Object.keys(zip.files)).toContain(sanitizedFilePath);
153153
});
154154
});

0 commit comments

Comments
 (0)