forked from Kitware/VolView
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdicomFileMetaLoader.ts
More file actions
43 lines (36 loc) · 1.02 KB
/
Copy pathdicomFileMetaLoader.ts
File metadata and controls
43 lines (36 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { ReadDicomTagsFunction } from '@/src/core/streaming/dicom/dicomMetaLoader';
import { MetaLoader } from '@/src/core/streaming/types';
import { Maybe } from '@/src/types';
import { Tags } from '@/src/core/dicomTags';
import {
parseUltrasoundRegionFromBlob,
UltrasoundRegions,
} from '@/src/core/streaming/dicom/ultrasoundRegion';
export class DicomFileMetaLoader implements MetaLoader {
public tags: Maybe<Array<[string, string]>>;
public ultrasoundRegions: UltrasoundRegions | undefined;
private file: File;
constructor(
file: File,
private readDicomTags: ReadDicomTagsFunction
) {
this.file = file;
}
get meta() {
return this.tags;
}
get metaBlob() {
return this.file;
}
async load() {
if (this.tags) return;
this.tags = await this.readDicomTags(this.file);
const modality = new Map(this.tags).get(Tags.Modality)?.trim();
if (modality === 'US') {
this.ultrasoundRegions = await parseUltrasoundRegionFromBlob(this.file);
}
}
stop() {
// do nothing
}
}