@abasb75/dicom-parser 0.0.0-test2 → 0.0.0-test20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Dataset.d.ts ADDED
@@ -0,0 +1,51 @@
1
+ import { DicomDate, DicomPatientModule, DicomPixelModule, DicomScalingModule, DicomTime, DicomVOILutModule, Tags } from "./types";
2
+ declare class Dataset {
3
+ /** duration of parse */
4
+ start: number;
5
+ end: number | undefined;
6
+ tags: Tags;
7
+ transferSyntaxUID: string;
8
+ dataView: DataView;
9
+ studyInstanceUID: string;
10
+ studyID: string;
11
+ seriesInstanceUID: string;
12
+ seriesNumber: number | string | undefined;
13
+ studyDate: string | DicomDate;
14
+ studyTime: number | DicomTime | string | undefined;
15
+ littleEndian: boolean;
16
+ accessionNumber: string;
17
+ imageType: number | string | number[] | string[] | undefined;
18
+ modality: number | string | number[] | string[] | undefined;
19
+ seriesDescription: string;
20
+ basicOffsetTable: number[] | undefined;
21
+ /** modules */
22
+ voiLUTModule: DicomVOILutModule;
23
+ patientModule: DicomPatientModule;
24
+ pixelModule: DicomPixelModule;
25
+ scalingModule: DicomScalingModule;
26
+ constructor(tags: Tags, dataView: DataView, littleEndian: boolean, start: number, end: number);
27
+ hasPixelData(): boolean;
28
+ getPixelData(frame?: number): Promise<DataView>;
29
+ getVOILutModule(): DicomVOILutModule;
30
+ getPatientModule(): DicomPatientModule;
31
+ getPixelModule(): DicomPixelModule;
32
+ getScalingModule(): DicomScalingModule;
33
+ date(group: number, element: number): string | {
34
+ year: string;
35
+ month: string;
36
+ day: string;
37
+ };
38
+ time(group: number, element: number): string | {
39
+ hour: string;
40
+ minute: string;
41
+ second: string;
42
+ };
43
+ int(group: number, element: number): number | undefined;
44
+ get(group: number, element: number): string;
45
+ string(group: number, element: number): string;
46
+ getValue(element: number | string, elementId?: number | string, vr?: string): string | number | DataView | (string | number)[] | undefined;
47
+ getPaletteColorData(): import("./types").PaletteColorData | undefined;
48
+ private _getValue;
49
+ private _reformatToString;
50
+ }
51
+ export default Dataset;
package/Dataset.js ADDED
@@ -0,0 +1,448 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
12
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ import PixelData from "./utils/PixelData";
38
+ import Tag from "./Tag";
39
+ import Value from "./Value";
40
+ import PaletteColor from "./utils/PaletteColor";
41
+ var Dataset = /** @class */ (function () {
42
+ function Dataset(tags, dataView, littleEndian, start, end) {
43
+ /** duration of parse */
44
+ Object.defineProperty(this, "start", {
45
+ enumerable: true,
46
+ configurable: true,
47
+ writable: true,
48
+ value: void 0
49
+ });
50
+ Object.defineProperty(this, "end", {
51
+ enumerable: true,
52
+ configurable: true,
53
+ writable: true,
54
+ value: void 0
55
+ });
56
+ Object.defineProperty(this, "tags", {
57
+ enumerable: true,
58
+ configurable: true,
59
+ writable: true,
60
+ value: void 0
61
+ });
62
+ Object.defineProperty(this, "transferSyntaxUID", {
63
+ enumerable: true,
64
+ configurable: true,
65
+ writable: true,
66
+ value: "1.2.840.10008.1.2"
67
+ });
68
+ Object.defineProperty(this, "dataView", {
69
+ enumerable: true,
70
+ configurable: true,
71
+ writable: true,
72
+ value: void 0
73
+ });
74
+ Object.defineProperty(this, "studyInstanceUID", {
75
+ enumerable: true,
76
+ configurable: true,
77
+ writable: true,
78
+ value: ""
79
+ });
80
+ Object.defineProperty(this, "studyID", {
81
+ enumerable: true,
82
+ configurable: true,
83
+ writable: true,
84
+ value: ""
85
+ });
86
+ Object.defineProperty(this, "seriesInstanceUID", {
87
+ enumerable: true,
88
+ configurable: true,
89
+ writable: true,
90
+ value: void 0
91
+ });
92
+ Object.defineProperty(this, "seriesNumber", {
93
+ enumerable: true,
94
+ configurable: true,
95
+ writable: true,
96
+ value: void 0
97
+ });
98
+ Object.defineProperty(this, "studyDate", {
99
+ enumerable: true,
100
+ configurable: true,
101
+ writable: true,
102
+ value: void 0
103
+ });
104
+ Object.defineProperty(this, "studyTime", {
105
+ enumerable: true,
106
+ configurable: true,
107
+ writable: true,
108
+ value: void 0
109
+ });
110
+ Object.defineProperty(this, "littleEndian", {
111
+ enumerable: true,
112
+ configurable: true,
113
+ writable: true,
114
+ value: void 0
115
+ });
116
+ Object.defineProperty(this, "accessionNumber", {
117
+ enumerable: true,
118
+ configurable: true,
119
+ writable: true,
120
+ value: void 0
121
+ });
122
+ Object.defineProperty(this, "imageType", {
123
+ enumerable: true,
124
+ configurable: true,
125
+ writable: true,
126
+ value: void 0
127
+ });
128
+ Object.defineProperty(this, "modality", {
129
+ enumerable: true,
130
+ configurable: true,
131
+ writable: true,
132
+ value: void 0
133
+ });
134
+ Object.defineProperty(this, "seriesDescription", {
135
+ enumerable: true,
136
+ configurable: true,
137
+ writable: true,
138
+ value: void 0
139
+ });
140
+ Object.defineProperty(this, "basicOffsetTable", {
141
+ enumerable: true,
142
+ configurable: true,
143
+ writable: true,
144
+ value: void 0
145
+ });
146
+ /** modules */
147
+ Object.defineProperty(this, "voiLUTModule", {
148
+ enumerable: true,
149
+ configurable: true,
150
+ writable: true,
151
+ value: void 0
152
+ });
153
+ Object.defineProperty(this, "patientModule", {
154
+ enumerable: true,
155
+ configurable: true,
156
+ writable: true,
157
+ value: void 0
158
+ });
159
+ Object.defineProperty(this, "pixelModule", {
160
+ enumerable: true,
161
+ configurable: true,
162
+ writable: true,
163
+ value: void 0
164
+ });
165
+ Object.defineProperty(this, "scalingModule", {
166
+ enumerable: true,
167
+ configurable: true,
168
+ writable: true,
169
+ value: void 0
170
+ });
171
+ this.tags = tags;
172
+ this.dataView = dataView;
173
+ this.littleEndian = littleEndian;
174
+ this.studyID = this.get(0x0020, 0x0010);
175
+ this.studyInstanceUID = this.string(0x0020, 0x000D);
176
+ this.seriesInstanceUID = this.get(0x0020, 0x000E);
177
+ this.seriesNumber = this.get(0x0020, 0x0011);
178
+ this.studyDate = this.date(0x0008, 0x0020);
179
+ this.studyTime = this.time(0x0008, 0x0030);
180
+ this.accessionNumber = this.string(0x0008, 0x0050);
181
+ this.imageType = this.get(0x0008, 0x0008);
182
+ this.modality = this.get(0x0008, 0x0060);
183
+ this.seriesDescription = this.string(0x0008, 0x103E);
184
+ this.voiLUTModule = this.getVOILutModule();
185
+ this.patientModule = this.getPatientModule();
186
+ this.pixelModule = this.getPixelModule();
187
+ this.scalingModule = this.getScalingModule();
188
+ this.start = start;
189
+ this.end = end;
190
+ }
191
+ Object.defineProperty(Dataset.prototype, "hasPixelData", {
192
+ enumerable: false,
193
+ configurable: true,
194
+ writable: true,
195
+ value: function () {
196
+ if (this.tags['0x7FE00010']
197
+ || this.tags['0x7FE00008']
198
+ || this.tags['0x7FE00009']) {
199
+ return true;
200
+ }
201
+ return false;
202
+ }
203
+ });
204
+ Object.defineProperty(Dataset.prototype, "getPixelData", {
205
+ enumerable: false,
206
+ configurable: true,
207
+ writable: true,
208
+ value: function () {
209
+ return __awaiter(this, arguments, void 0, function (frame) {
210
+ if (frame === void 0) { frame = 0; }
211
+ return __generator(this, function (_a) {
212
+ switch (_a.label) {
213
+ case 0: return [4 /*yield*/, PixelData.get(this, frame)];
214
+ case 1: return [2 /*return*/, _a.sent()];
215
+ }
216
+ });
217
+ });
218
+ }
219
+ });
220
+ Object.defineProperty(Dataset.prototype, "getVOILutModule", {
221
+ enumerable: false,
222
+ configurable: true,
223
+ writable: true,
224
+ value: function () {
225
+ return {
226
+ voiLUTFunction: this.get(0x0028, 0x1056),
227
+ windowWidth: this.int(0x0028, 0x1051),
228
+ windowCenter: this.int(0x0028, 0x1050),
229
+ voiLUTSequence: this.get(0x0028, 0x3010),
230
+ lutDescriptor: this.get(0x0028, 0x3002),
231
+ lutExplanation: this.get(0x0028, 0x3003),
232
+ lutData: this.get(0x0028, 0x3006),
233
+ windowCenterAndWidthExplanation: this.get(0x0028, 0x1055),
234
+ };
235
+ }
236
+ });
237
+ Object.defineProperty(Dataset.prototype, "getPatientModule", {
238
+ enumerable: false,
239
+ configurable: true,
240
+ writable: true,
241
+ value: function () {
242
+ return {
243
+ patientName: this.get(0x0010, 0x0010),
244
+ patientID: this.get(0x0010, 0x0020),
245
+ typeofPatientID: this.get(0x0010, 0x0022),
246
+ patientSex: this.get(0x0010, 0x0040),
247
+ patientBirthDate: this.get(0x0010, 0x0030),
248
+ patientAge: this.get(0x0010, 0x1010),
249
+ patientSize: this.get(0x0010, 0x1020),
250
+ otherPatientIDs: this.get(0x0010, 0x1000),
251
+ otherPatientNames: this.get(0x0010, 0x1001),
252
+ patientWeight: this.get(0x0010, 0x1030),
253
+ };
254
+ }
255
+ });
256
+ Object.defineProperty(Dataset.prototype, "getPixelModule", {
257
+ enumerable: false,
258
+ configurable: true,
259
+ writable: true,
260
+ value: function () {
261
+ return {
262
+ photometricInterpretation: this.get(0x0028, 0x0004),
263
+ numberOfFrames: this.int(0x0028, 0x0008),
264
+ pixelRepresentation: this.int(0x0028, 0x0103),
265
+ pixeSpacing: this.get(0x0028, 0x0030),
266
+ rows: this.int(0x0028, 0x0010),
267
+ columns: this.int(0x0028, 0x0011),
268
+ bitsAllocated: this.int(0x0028, 0x0100),
269
+ highBit: this.int(0x0028, 0x0102),
270
+ bitsStored: this.int(0x0028, 0x0101),
271
+ samplesPerPixel: this.int(0x0028, 0x0002),
272
+ pixelDataProviderURL: this.get(0x0028, 0x7FE0),
273
+ pixelPaddingRangeLimit: this.get(0x0028, 0x0121),
274
+ extendedOffsetTable: this.get(0x7FE0, 0x0001),
275
+ extendedOffsetTableLengths: this.get(0x7FE0, 0x0002),
276
+ pixelAspectRatio: this.get(0x0028, 0x0034),
277
+ planarConfiguration: this.int(0x0028, 0x0006),
278
+ redPaletteColorLookupTableDescriptor: this.get(0x0028, 0x1101),
279
+ greenPaletteColorLookupTableDescriptor: this.get(0x0028, 0x1102),
280
+ bluePaletteColorLookupTableDescriptor: this.get(0x0028, 0x1103),
281
+ alphaPaletteColorLookupTableDescriptor: this.get(0x0028, 0x1104),
282
+ redPaletteColorLookupTableData: this.get(0x0028, 0x1201),
283
+ greenPaletteColorLookupTableData: this.get(0x0028, 0x1202),
284
+ bluePaletteColorLookupTableData: this.get(0x0028, 0x1203),
285
+ alphaPaletteColorLookupTableData: this.get(0x0028, 0x1204),
286
+ segmentedRedPaletteColorLookupTableData: this.get(0x0028, 0x1221),
287
+ segmentedGreenPaletteColorLookupTableData: this.get(0x0028, 0x1222),
288
+ segmentedBluePaletteColorLookupTableData: this.get(0x0028, 0x1223),
289
+ segmentedAlphaPaletteColorLookupTableData: this.get(0x0028, 0x1224),
290
+ };
291
+ }
292
+ });
293
+ Object.defineProperty(Dataset.prototype, "getScalingModule", {
294
+ enumerable: false,
295
+ configurable: true,
296
+ writable: true,
297
+ value: function () {
298
+ return {
299
+ rescaleSlope: this.int(0x0028, 0x1053),
300
+ rescaleIntercept: this.int(0x0028, 0x1052),
301
+ modality: this.modality,
302
+ };
303
+ }
304
+ });
305
+ Object.defineProperty(Dataset.prototype, "date", {
306
+ enumerable: false,
307
+ configurable: true,
308
+ writable: true,
309
+ value: function (group, element) {
310
+ var dateValue = this.get(group, element);
311
+ if (/^[0-9]{4}\-[0-9]{2}\-[0-9]{2}$/.exec(dateValue)) {
312
+ var dateVaues = dateValue.split('-');
313
+ return {
314
+ year: dateVaues[0],
315
+ month: dateVaues[1],
316
+ day: dateVaues[2],
317
+ };
318
+ }
319
+ return dateValue;
320
+ }
321
+ });
322
+ Object.defineProperty(Dataset.prototype, "time", {
323
+ enumerable: false,
324
+ configurable: true,
325
+ writable: true,
326
+ value: function (group, element) {
327
+ var dateValue = this.get(group, element);
328
+ if (/^[0-9]{2}\:[0-9]{2}\:[0-9]{2}$/.exec(dateValue)) {
329
+ var dateVaues = dateValue.split(':');
330
+ return {
331
+ hour: dateVaues[0],
332
+ minute: dateVaues[1],
333
+ second: dateVaues[2],
334
+ };
335
+ }
336
+ return dateValue;
337
+ }
338
+ });
339
+ Object.defineProperty(Dataset.prototype, "int", {
340
+ enumerable: false,
341
+ configurable: true,
342
+ writable: true,
343
+ value: function (group, element) {
344
+ var is = this.get(group, element);
345
+ if (typeof is === "number") {
346
+ return is;
347
+ }
348
+ else if (Array.isArray(is) && typeof is[0] === "number") {
349
+ return is[0];
350
+ }
351
+ else {
352
+ return undefined;
353
+ }
354
+ }
355
+ });
356
+ Object.defineProperty(Dataset.prototype, "get", {
357
+ enumerable: false,
358
+ configurable: true,
359
+ writable: true,
360
+ value: function (group, element) {
361
+ var value = this.getValue(group, element);
362
+ return value;
363
+ }
364
+ });
365
+ Object.defineProperty(Dataset.prototype, "string", {
366
+ enumerable: false,
367
+ configurable: true,
368
+ writable: true,
369
+ value: function (group, element) {
370
+ return this.getValue(group, element, 'string') + "";
371
+ }
372
+ });
373
+ Object.defineProperty(Dataset.prototype, "getValue", {
374
+ enumerable: false,
375
+ configurable: true,
376
+ writable: true,
377
+ value: function (element, elementId, vr) {
378
+ var _a;
379
+ if (!element && !elementId) {
380
+ return "";
381
+ }
382
+ var _group, _element = "";
383
+ if (typeof element === 'string' && element.length >= 8) {
384
+ var el = element.replace(/^0[xX]/, '');
385
+ if (el.length !== 8) {
386
+ return "";
387
+ }
388
+ _group = el.slice(0, 3);
389
+ _element = el.slice(4, 7);
390
+ }
391
+ else if (typeof element === 'number' && element > 0xffff) {
392
+ var el = Tag.intTo4digitString(element);
393
+ _group = el.slice(0, 3);
394
+ _element = el.slice(4, 7);
395
+ }
396
+ else {
397
+ _group = this._reformatToString(element);
398
+ _element = this._reformatToString(elementId);
399
+ if (!_group || !_element)
400
+ return "";
401
+ }
402
+ var key = "0x".concat(_group).concat(_element);
403
+ if (!this.tags[key]) {
404
+ return "";
405
+ }
406
+ var _vr = vr || ((_a = this.tags[key]) === null || _a === void 0 ? void 0 : _a.vr) || Tag.getTagVRFromDictionary(_group, _element) || "AA";
407
+ return this._getValue(this.tags[key], _vr);
408
+ }
409
+ });
410
+ Object.defineProperty(Dataset.prototype, "getPaletteColorData", {
411
+ enumerable: false,
412
+ configurable: true,
413
+ writable: true,
414
+ value: function () {
415
+ return PaletteColor.get(this);
416
+ }
417
+ });
418
+ Object.defineProperty(Dataset.prototype, "_getValue", {
419
+ enumerable: false,
420
+ configurable: true,
421
+ writable: true,
422
+ value: function (tag, vr) {
423
+ if (vr === void 0) { vr = "AA"; }
424
+ var offset = tag.offset;
425
+ if (!offset)
426
+ return "";
427
+ var len = tag.valueLength;
428
+ var value = Value.byVr(this.dataView, offset, len, vr, this.littleEndian);
429
+ tag.value = value;
430
+ return value;
431
+ }
432
+ });
433
+ Object.defineProperty(Dataset.prototype, "_reformatToString", {
434
+ enumerable: false,
435
+ configurable: true,
436
+ writable: true,
437
+ value: function (input) {
438
+ if (!input)
439
+ return "";
440
+ if (typeof input === "string") {
441
+ return input.replace(/^0[xX]/, '');
442
+ }
443
+ return Tag.intTo4digitString(input);
444
+ }
445
+ });
446
+ return Dataset;
447
+ }());
448
+ export default Dataset;
package/Loader.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ declare class Loader {
2
+ private dicomSrc;
3
+ private xhr;
4
+ constructor(dicomSrc?: string);
5
+ load(dicomSrc?: string | File): Promise<ArrayBuffer | undefined>;
6
+ cancel(): void;
7
+ }
8
+ export default Loader;
package/Loader.js ADDED
@@ -0,0 +1,105 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
12
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ var Loader = /** @class */ (function () {
38
+ function Loader(dicomSrc) {
39
+ Object.defineProperty(this, "dicomSrc", {
40
+ enumerable: true,
41
+ configurable: true,
42
+ writable: true,
43
+ value: void 0
44
+ });
45
+ Object.defineProperty(this, "xhr", {
46
+ enumerable: true,
47
+ configurable: true,
48
+ writable: true,
49
+ value: void 0
50
+ });
51
+ this.dicomSrc = dicomSrc;
52
+ this.xhr = new XMLHttpRequest();
53
+ }
54
+ Object.defineProperty(Loader.prototype, "load", {
55
+ enumerable: false,
56
+ configurable: true,
57
+ writable: true,
58
+ value: function (dicomSrc) {
59
+ return __awaiter(this, void 0, void 0, function () {
60
+ var dicom_1;
61
+ var _this = this;
62
+ return __generator(this, function (_a) {
63
+ if (typeof dicomSrc === "string") {
64
+ dicom_1 = dicomSrc || this.dicomSrc;
65
+ if (!dicom_1)
66
+ return [2 /*return*/];
67
+ return [2 /*return*/, new Promise(function (resolve, reject) {
68
+ _this.xhr.onload = function () {
69
+ resolve(_this.xhr.response);
70
+ };
71
+ _this.xhr.onerror = function () {
72
+ reject(_this.xhr);
73
+ };
74
+ _this.xhr.responseType = 'arraybuffer';
75
+ _this.xhr.open('GET', dicom_1, true);
76
+ _this.xhr.send();
77
+ })];
78
+ }
79
+ else if (dicomSrc instanceof File) {
80
+ return [2 /*return*/, new Promise(function (resolve, reject) {
81
+ dicomSrc.arrayBuffer().then(function (arrayBuffer) {
82
+ resolve(arrayBuffer);
83
+ }).catch(function (reason) { return reject(reason); });
84
+ })];
85
+ }
86
+ return [2 /*return*/, new Promise(function (resolve, reject) {
87
+ if (false)
88
+ resolve(new ArrayBuffer(1));
89
+ reject("dicom source is not valid");
90
+ })];
91
+ });
92
+ });
93
+ }
94
+ });
95
+ Object.defineProperty(Loader.prototype, "cancel", {
96
+ enumerable: false,
97
+ configurable: true,
98
+ writable: true,
99
+ value: function () {
100
+ this.xhr.abort();
101
+ }
102
+ });
103
+ return Loader;
104
+ }());
105
+ export default Loader;
package/Parser.d.ts ADDED
@@ -0,0 +1,32 @@
1
+ import Dataset from "./Dataset";
2
+ import { Tags } from "./types";
3
+ declare class Parser {
4
+ private start;
5
+ private end;
6
+ private arrayBuffer;
7
+ private offset;
8
+ private dataView;
9
+ private tags;
10
+ private dataSet;
11
+ private EXEPTED;
12
+ private VRS;
13
+ private IMPLICT_TRANSFER_SYNTAXES;
14
+ private BIG_ENDIAN_TRANSFER_SYNTAXES;
15
+ private DEFLATED_TRANSFER_SYNTAXES;
16
+ private littleEndian;
17
+ private implicit;
18
+ private transferSyntaxUID;
19
+ private inflated;
20
+ constructor(arrayBuffer: ArrayBuffer);
21
+ parse(): Dataset;
22
+ getDataset(): Dataset | undefined;
23
+ getElements(sqLen?: number): Tags;
24
+ getValue(len: number): ArrayBuffer;
25
+ getNextGroupAndElement(): {
26
+ group: number;
27
+ element: number;
28
+ };
29
+ getNextVR(groupInt: number, elementInt: number): string;
30
+ concatArrayBuffers: (buffer1: ArrayBuffer, buffer2: ArrayBuffer) => ArrayBufferLike;
31
+ }
32
+ export default Parser;