@abasb75/dicom-parser 0.0.0-test3 → 0.0.1-a

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/package.json CHANGED
@@ -1,34 +1,24 @@
1
1
  {
2
- "name": "@abasb75/dicom-parser",
3
- "version": "0.0.0-test3",
4
- "description": "a javascript powerfull dicom parser",
5
- "main": "index.js",
6
- "type": "module",
7
- "types": "index.d.ts",
8
- "keywords": [
9
- "dicom",
10
- "dcm",
11
- "dcmjs",
12
- "dicom-parser",
13
- "pacs"
14
- ],
15
- "author": "Abbas Bagheri <abasbagheria@gmail.com>",
16
- "license": "ISC",
17
- "repository": {
18
- "type": "git",
19
- "url": "git+https://github.com/abasb75/dicom-parser/raction.git"
20
- },
21
- "bugs": {
22
- "url": "https://github.com/abasb75/dicom-parser/issues"
23
- },
24
- "homepage": "https://github.com/abasb75/dicom-parser#readme",
25
- "dependencies": {
26
- "pako": "^2.1.0"
27
- },
28
- "peerDependencies": {
29
- "pako": "^2.1.0"
30
- },
31
- "devDependencies": {
32
- "@types/pako": "^2.0.3"
33
- }
2
+ "name": "@abasb75/dicom-parser",
3
+ "version": "0.0.1a",
4
+ "description": "A lightweight DICOM parser.",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "scripts": {
12
+ "build": "tsup"
13
+ },
14
+ "dependencies": {
15
+ "pako": "^2.1.0"
16
+ },
17
+ "keywords": [
18
+ "dicom",
19
+ "parser",
20
+ "medical",
21
+ "radiology"
22
+ ],
23
+ "license": "MIT"
34
24
  }
package/Dataset.d.ts DELETED
@@ -1,57 +0,0 @@
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
- pixelRepresentation: number | string | undefined;
16
- littleEndian: boolean;
17
- pixeSpacing: number | number[] | string | undefined;
18
- accessionNumber: string;
19
- bitsAllocated: number | string | undefined;
20
- bitsStored: number | string | undefined;
21
- highBit: number | string | undefined;
22
- imageType: number | string | number[] | string[] | undefined;
23
- modality: number | string | number[] | string[] | undefined;
24
- seriesDescription: string;
25
- rows: string | number | undefined;
26
- columns: string | number | undefined;
27
- patientSex: any;
28
- /** modules */
29
- voiLUTModule: DicomVOILutModule;
30
- patientModule: DicomPatientModule;
31
- pixelModule: DicomPixelModule;
32
- scalingModule: DicomScalingModule;
33
- constructor(tags: Tags, dataView: DataView, littleEndian: boolean, start: number, end: number);
34
- hasPixelData(): boolean;
35
- getPixelData(frame?: number): Promise<DataView>;
36
- getVOILutModule(): DicomVOILutModule;
37
- getPatientModule(): DicomPatientModule;
38
- getPixelModule(): DicomPixelModule;
39
- getScalingModule(): DicomScalingModule;
40
- date(group: number, element: number): string | {
41
- year: string;
42
- month: string;
43
- day: string;
44
- };
45
- time(group: number, element: number): string | {
46
- hour: string;
47
- minute: string;
48
- second: string;
49
- };
50
- int(group: number, element: number): number | undefined;
51
- get(group: number, element: number): string;
52
- string(group: number, element: number): string;
53
- getValue(element: number | string, elementId?: number | string, vr?: string): string | number | DataView | (string | number)[] | undefined;
54
- private _getValue;
55
- private _reformatToString;
56
- }
57
- export default Dataset;
package/Dataset.js DELETED
@@ -1,469 +0,0 @@
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 "./PixelData";
38
- import Tag from "./Tag";
39
- import Value from "./Value";
40
- var Dataset = /** @class */ (function () {
41
- function Dataset(tags, dataView, littleEndian, start, end) {
42
- /** duration of parse */
43
- Object.defineProperty(this, "start", {
44
- enumerable: true,
45
- configurable: true,
46
- writable: true,
47
- value: void 0
48
- });
49
- Object.defineProperty(this, "end", {
50
- enumerable: true,
51
- configurable: true,
52
- writable: true,
53
- value: void 0
54
- });
55
- Object.defineProperty(this, "tags", {
56
- enumerable: true,
57
- configurable: true,
58
- writable: true,
59
- value: void 0
60
- });
61
- Object.defineProperty(this, "transferSyntaxUID", {
62
- enumerable: true,
63
- configurable: true,
64
- writable: true,
65
- value: "1.2.840.10008.1.2"
66
- });
67
- Object.defineProperty(this, "dataView", {
68
- enumerable: true,
69
- configurable: true,
70
- writable: true,
71
- value: void 0
72
- });
73
- Object.defineProperty(this, "studyInstanceUID", {
74
- enumerable: true,
75
- configurable: true,
76
- writable: true,
77
- value: ""
78
- });
79
- Object.defineProperty(this, "studyID", {
80
- enumerable: true,
81
- configurable: true,
82
- writable: true,
83
- value: ""
84
- });
85
- Object.defineProperty(this, "seriesInstanceUID", {
86
- enumerable: true,
87
- configurable: true,
88
- writable: true,
89
- value: void 0
90
- });
91
- Object.defineProperty(this, "seriesNumber", {
92
- enumerable: true,
93
- configurable: true,
94
- writable: true,
95
- value: void 0
96
- });
97
- Object.defineProperty(this, "studyDate", {
98
- enumerable: true,
99
- configurable: true,
100
- writable: true,
101
- value: void 0
102
- });
103
- Object.defineProperty(this, "studyTime", {
104
- enumerable: true,
105
- configurable: true,
106
- writable: true,
107
- value: void 0
108
- });
109
- Object.defineProperty(this, "pixelRepresentation", {
110
- enumerable: true,
111
- configurable: true,
112
- writable: true,
113
- value: void 0
114
- });
115
- Object.defineProperty(this, "littleEndian", {
116
- enumerable: true,
117
- configurable: true,
118
- writable: true,
119
- value: void 0
120
- });
121
- Object.defineProperty(this, "pixeSpacing", {
122
- enumerable: true,
123
- configurable: true,
124
- writable: true,
125
- value: void 0
126
- });
127
- Object.defineProperty(this, "accessionNumber", {
128
- enumerable: true,
129
- configurable: true,
130
- writable: true,
131
- value: void 0
132
- });
133
- Object.defineProperty(this, "bitsAllocated", {
134
- enumerable: true,
135
- configurable: true,
136
- writable: true,
137
- value: void 0
138
- });
139
- Object.defineProperty(this, "bitsStored", {
140
- enumerable: true,
141
- configurable: true,
142
- writable: true,
143
- value: void 0
144
- });
145
- Object.defineProperty(this, "highBit", {
146
- enumerable: true,
147
- configurable: true,
148
- writable: true,
149
- value: void 0
150
- });
151
- Object.defineProperty(this, "imageType", {
152
- enumerable: true,
153
- configurable: true,
154
- writable: true,
155
- value: void 0
156
- });
157
- Object.defineProperty(this, "modality", {
158
- enumerable: true,
159
- configurable: true,
160
- writable: true,
161
- value: void 0
162
- });
163
- Object.defineProperty(this, "seriesDescription", {
164
- enumerable: true,
165
- configurable: true,
166
- writable: true,
167
- value: void 0
168
- });
169
- Object.defineProperty(this, "rows", {
170
- enumerable: true,
171
- configurable: true,
172
- writable: true,
173
- value: void 0
174
- });
175
- Object.defineProperty(this, "columns", {
176
- enumerable: true,
177
- configurable: true,
178
- writable: true,
179
- value: void 0
180
- });
181
- Object.defineProperty(this, "patientSex", {
182
- enumerable: true,
183
- configurable: true,
184
- writable: true,
185
- value: void 0
186
- });
187
- /** modules */
188
- Object.defineProperty(this, "voiLUTModule", {
189
- enumerable: true,
190
- configurable: true,
191
- writable: true,
192
- value: void 0
193
- });
194
- Object.defineProperty(this, "patientModule", {
195
- enumerable: true,
196
- configurable: true,
197
- writable: true,
198
- value: void 0
199
- });
200
- Object.defineProperty(this, "pixelModule", {
201
- enumerable: true,
202
- configurable: true,
203
- writable: true,
204
- value: void 0
205
- });
206
- Object.defineProperty(this, "scalingModule", {
207
- enumerable: true,
208
- configurable: true,
209
- writable: true,
210
- value: void 0
211
- });
212
- this.tags = tags;
213
- this.dataView = dataView;
214
- this.littleEndian = littleEndian;
215
- this.studyID = this.get(0x0020, 0x0010);
216
- this.studyInstanceUID = this.string(0x0020, 0x000D);
217
- this.seriesInstanceUID = this.get(0x0020, 0x000E);
218
- this.seriesNumber = this.get(0x0020, 0x0011);
219
- this.studyDate = this.date(0x0008, 0x0020);
220
- this.studyTime = this.time(0x0008, 0x0030);
221
- this.accessionNumber = this.string(0x0008, 0x0050);
222
- this.imageType = this.get(0x0008, 0x0008);
223
- this.modality = this.get(0x0008, 0x0060);
224
- this.seriesDescription = this.string(0x0008, 0x103E);
225
- this.patientSex = this.get(0x0010, 0x0040);
226
- this.voiLUTModule = this.getVOILutModule();
227
- this.patientModule = this.getPatientModule();
228
- this.pixelModule = this.getPixelModule();
229
- this.scalingModule = this.getScalingModule();
230
- this.start = start;
231
- this.end = end;
232
- }
233
- Object.defineProperty(Dataset.prototype, "hasPixelData", {
234
- enumerable: false,
235
- configurable: true,
236
- writable: true,
237
- value: function () {
238
- if (this.tags['0x7FE00010']
239
- || this.tags['0x7FE00008']
240
- || this.tags['0x7FE00009']) {
241
- return true;
242
- }
243
- return false;
244
- }
245
- });
246
- Object.defineProperty(Dataset.prototype, "getPixelData", {
247
- enumerable: false,
248
- configurable: true,
249
- writable: true,
250
- value: function () {
251
- return __awaiter(this, arguments, void 0, function (frame) {
252
- if (frame === void 0) { frame = 0; }
253
- return __generator(this, function (_a) {
254
- switch (_a.label) {
255
- case 0: return [4 /*yield*/, PixelData.get(this, frame)];
256
- case 1: return [2 /*return*/, _a.sent()];
257
- }
258
- });
259
- });
260
- }
261
- });
262
- Object.defineProperty(Dataset.prototype, "getVOILutModule", {
263
- enumerable: false,
264
- configurable: true,
265
- writable: true,
266
- value: function () {
267
- return {
268
- voiLUTFunction: this.get(0x0028, 0x1056),
269
- windowWidth: this.int(0x0028, 0x1051),
270
- windowCenter: this.int(0x0028, 0x1050),
271
- voiLUTSequence: this.get(0x0028, 0x3010),
272
- lutDescriptor: this.get(0x0028, 0x3002),
273
- lutExplanation: this.get(0x0028, 0x3003),
274
- lutData: this.get(0x0028, 0x3006),
275
- windowCenterAndWidthExplanation: this.get(0x0028, 0x1055),
276
- };
277
- }
278
- });
279
- Object.defineProperty(Dataset.prototype, "getPatientModule", {
280
- enumerable: false,
281
- configurable: true,
282
- writable: true,
283
- value: function () {
284
- return {
285
- patientName: this.get(0x0010, 0x0010),
286
- patientID: this.get(0x0010, 0x0020),
287
- typeofPatientID: this.get(0x0010, 0x0022),
288
- patientSex: this.get(0x0010, 0x0040),
289
- patientBirthDate: this.get(0x0010, 0x0030),
290
- patientAge: this.get(0x0010, 0x1010),
291
- patientSize: this.get(0x0010, 0x1020),
292
- otherPatientIDs: this.get(0x0010, 0x1000),
293
- otherPatientNames: this.get(0x0010, 0x1001),
294
- patientWeight: this.get(0x0010, 0x1030),
295
- };
296
- }
297
- });
298
- Object.defineProperty(Dataset.prototype, "getPixelModule", {
299
- enumerable: false,
300
- configurable: true,
301
- writable: true,
302
- value: function () {
303
- return {
304
- photometricInterpretation: this.get(0x0028, 0x0004),
305
- numberOfFrames: this.int(0x0028, 0x0008),
306
- pixelRepresentation: this.int(0x0028, 0x0103),
307
- pixeSpacing: this.get(0x0028, 0x0030),
308
- rows: this.int(0x0028, 0x0010),
309
- columns: this.int(0x0028, 0x0011),
310
- bitsAllocated: this.int(0x0028, 0x0100),
311
- highBit: this.int(0x0028, 0x0102),
312
- bitsStored: this.int(0x0028, 0x0101),
313
- samplesPerPixel: this.int(0x0028, 0x0002),
314
- pixelDataProviderURL: this.get(0x0028, 0x7FE0),
315
- pixelPaddingRangeLimit: this.get(0x0028, 0x0121),
316
- extendedOffsetTable: this.get(0x7FE0, 0x0001),
317
- extendedOffsetTableLengths: this.get(0x7FE0, 0x0002),
318
- pixelAspectRatio: this.get(0x0028, 0x0034)
319
- };
320
- }
321
- });
322
- Object.defineProperty(Dataset.prototype, "getScalingModule", {
323
- enumerable: false,
324
- configurable: true,
325
- writable: true,
326
- value: function () {
327
- return {
328
- rescaleSlope: this.int(0x0028, 0x1053),
329
- rescaleIntercept: this.int(0x0028, 0x1052),
330
- modality: this.modality,
331
- };
332
- }
333
- });
334
- Object.defineProperty(Dataset.prototype, "date", {
335
- enumerable: false,
336
- configurable: true,
337
- writable: true,
338
- value: function (group, element) {
339
- var dateValue = this.get(group, element);
340
- if (/^[0-9]{4}\-[0-9]{2}\-[0-9]{2}$/.exec(dateValue)) {
341
- var dateVaues = dateValue.split('-');
342
- return {
343
- year: dateVaues[0],
344
- month: dateVaues[1],
345
- day: dateVaues[2],
346
- };
347
- }
348
- return dateValue;
349
- }
350
- });
351
- Object.defineProperty(Dataset.prototype, "time", {
352
- enumerable: false,
353
- configurable: true,
354
- writable: true,
355
- value: function (group, element) {
356
- var dateValue = this.get(group, element);
357
- if (/^[0-9]{2}\:[0-9]{2}\:[0-9]{2}$/.exec(dateValue)) {
358
- var dateVaues = dateValue.split(':');
359
- return {
360
- hour: dateVaues[0],
361
- minute: dateVaues[1],
362
- second: dateVaues[2],
363
- };
364
- }
365
- return dateValue;
366
- }
367
- });
368
- Object.defineProperty(Dataset.prototype, "int", {
369
- enumerable: false,
370
- configurable: true,
371
- writable: true,
372
- value: function (group, element) {
373
- var is = this.get(group, element);
374
- if (typeof is === "number") {
375
- return is;
376
- }
377
- else if (Array.isArray(is) && typeof is[0] === "number") {
378
- return is[0];
379
- }
380
- else {
381
- return undefined;
382
- }
383
- }
384
- });
385
- Object.defineProperty(Dataset.prototype, "get", {
386
- enumerable: false,
387
- configurable: true,
388
- writable: true,
389
- value: function (group, element) {
390
- var value = this.getValue(group, element);
391
- return value;
392
- }
393
- });
394
- Object.defineProperty(Dataset.prototype, "string", {
395
- enumerable: false,
396
- configurable: true,
397
- writable: true,
398
- value: function (group, element) {
399
- return this.getValue(group, element) + "";
400
- }
401
- });
402
- Object.defineProperty(Dataset.prototype, "getValue", {
403
- enumerable: false,
404
- configurable: true,
405
- writable: true,
406
- value: function (element, elementId, vr) {
407
- var _a;
408
- if (!element && !elementId) {
409
- return "";
410
- }
411
- var _group, _element = "";
412
- if (typeof element === 'string' && element.length >= 8) {
413
- var el = element.replace(/^0[xX]/, '');
414
- if (el.length !== 8) {
415
- return "";
416
- }
417
- _group = el.slice(0, 3);
418
- _element = el.slice(4, 7);
419
- }
420
- else if (typeof element === 'number' && element > 0xffff) {
421
- var el = Tag.intTo4digitString(element);
422
- _group = el.slice(0, 3);
423
- _element = el.slice(4, 7);
424
- }
425
- else {
426
- _group = this._reformatToString(element);
427
- _element = this._reformatToString(elementId);
428
- if (!_group || !_element)
429
- return "";
430
- }
431
- var key = "0x".concat(_group).concat(_element);
432
- if (!this.tags[key]) {
433
- return "";
434
- }
435
- var _vr = vr || ((_a = this.tags[key]) === null || _a === void 0 ? void 0 : _a.vr) || Tag.getTagVRFromDictionary(_group, _element) || "AA";
436
- return this._getValue(this.tags[key], _vr);
437
- }
438
- });
439
- Object.defineProperty(Dataset.prototype, "_getValue", {
440
- enumerable: false,
441
- configurable: true,
442
- writable: true,
443
- value: function (tag, vr) {
444
- if (vr === void 0) { vr = "AA"; }
445
- var offset = tag.offset;
446
- if (!offset)
447
- return "";
448
- var len = tag.valueLength;
449
- var value = Value.byVr(this.dataView, offset, len, vr, this.littleEndian);
450
- tag.value = value;
451
- return value;
452
- }
453
- });
454
- Object.defineProperty(Dataset.prototype, "_reformatToString", {
455
- enumerable: false,
456
- configurable: true,
457
- writable: true,
458
- value: function (input) {
459
- if (!input)
460
- return "";
461
- if (typeof input === "string") {
462
- return input.replace(/^0[xX]/, '');
463
- }
464
- return Tag.intTo4digitString(input);
465
- }
466
- });
467
- return Dataset;
468
- }());
469
- export default Dataset;
package/Loader.d.ts DELETED
@@ -1,8 +0,0 @@
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;