@abasb75/dicom-parser 0.0.0-test23 → 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/README.md +13 -77
- package/{types.d.ts → dist/index.d.mts} +66 -27
- package/dist/index.d.ts +137 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/package.json +22 -32
- package/Dataset.d.ts +0 -48
- package/Dataset.js +0 -558
- package/Loader.d.ts +0 -8
- package/Loader.js +0 -105
- package/Parser.d.ts +0 -33
- package/Parser.js +0 -317
- package/Tag.d.ts +0 -17
- package/Tag.js +0 -128
- package/Value.d.ts +0 -15
- package/Value.js +0 -220
- package/enums/TagsDictionary.d.ts +0 -8
- package/enums/TagsDictionary.js +0 -3612
- package/enums/TransferSyntax.d.ts +0 -17
- package/enums/TransferSyntax.js +0 -17
- package/enums/ValueRepresentations.d.ts +0 -2
- package/enums/ValueRepresentations.js +0 -2
- package/enums/index.d.ts +0 -12
- package/enums/index.js +0 -9
- package/index.d.ts +0 -10
- package/index.js +0 -49
- package/tsconfig.tsbuildinfo +0 -1
- package/types.js +0 -1
- package/utils/PaletteColor.d.ts +0 -10
- package/utils/PaletteColor.js +0 -151
- package/utils/PixelData.d.ts +0 -14
- package/utils/PixelData.js +0 -285
package/package.json
CHANGED
|
@@ -1,34 +1,24 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
|
|
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,48 +0,0 @@
|
|
|
1
|
-
import { DicomDate, DicomPatientModule, DicomPixelModule, DicomScalingModule, DicomTime, DicomVOILutModule, Tags } from "./types";
|
|
2
|
-
declare class Dataset {
|
|
3
|
-
static Float: string;
|
|
4
|
-
static Integer: string;
|
|
5
|
-
/** duration of parse */
|
|
6
|
-
start: number;
|
|
7
|
-
end: number | undefined;
|
|
8
|
-
tags: Tags;
|
|
9
|
-
transferSyntaxUID: string;
|
|
10
|
-
dataView: DataView;
|
|
11
|
-
studyInstanceUID: string;
|
|
12
|
-
studyID: string;
|
|
13
|
-
seriesInstanceUID: string;
|
|
14
|
-
seriesNumber: number | string | undefined;
|
|
15
|
-
studyDate: string | DicomDate;
|
|
16
|
-
studyTime: number | DicomTime | string | undefined;
|
|
17
|
-
littleEndian: boolean;
|
|
18
|
-
accessionNumber: string;
|
|
19
|
-
imageType: number | string | number[] | string[] | undefined;
|
|
20
|
-
modality: number | string | number[] | string[] | undefined;
|
|
21
|
-
seriesDescription: string;
|
|
22
|
-
basicOffsetTable: number[] | undefined;
|
|
23
|
-
/** modules */
|
|
24
|
-
voiLUTModule: DicomVOILutModule;
|
|
25
|
-
patientModule: DicomPatientModule;
|
|
26
|
-
pixelModule: DicomPixelModule;
|
|
27
|
-
scalingModule: DicomScalingModule;
|
|
28
|
-
constructor(tags: Tags, dataView: DataView, littleEndian: boolean, start: number, end: number);
|
|
29
|
-
hasPixelData(): boolean;
|
|
30
|
-
getPixelTypes(): string | null;
|
|
31
|
-
getPixelData(frame?: number): Promise<DataView>;
|
|
32
|
-
getVOILutModule(): DicomVOILutModule;
|
|
33
|
-
getPatientModule(): DicomPatientModule;
|
|
34
|
-
getPixelModule(): DicomPixelModule;
|
|
35
|
-
getPixelSpacing(): any;
|
|
36
|
-
getScalingModule(): DicomScalingModule;
|
|
37
|
-
date(group: number, element: number): any;
|
|
38
|
-
time(group: number, element: number): any;
|
|
39
|
-
int(group: number, element: number): number | undefined;
|
|
40
|
-
get(group: number, element: number): any;
|
|
41
|
-
string(group: number, element: number): string;
|
|
42
|
-
getValue(element: number | string, elementId?: number | string, vr?: string): any;
|
|
43
|
-
getPaletteColorData(): import("./types").PaletteColorData | undefined;
|
|
44
|
-
private _findTagsByKey;
|
|
45
|
-
private _getValue;
|
|
46
|
-
private _reformatToString;
|
|
47
|
-
}
|
|
48
|
-
export default Dataset;
|
package/Dataset.js
DELETED
|
@@ -1,558 +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 "./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, "getPixelTypes", {
|
|
205
|
-
enumerable: false,
|
|
206
|
-
configurable: true,
|
|
207
|
-
writable: true,
|
|
208
|
-
value: function () {
|
|
209
|
-
if (this.tags['0x7FE00008']
|
|
210
|
-
|| this.tags['0x7FE00009']) {
|
|
211
|
-
return Dataset.Float;
|
|
212
|
-
}
|
|
213
|
-
else if (this.tags['0x7FE00010']) {
|
|
214
|
-
return Dataset.Integer;
|
|
215
|
-
}
|
|
216
|
-
return null;
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
Object.defineProperty(Dataset.prototype, "getPixelData", {
|
|
220
|
-
enumerable: false,
|
|
221
|
-
configurable: true,
|
|
222
|
-
writable: true,
|
|
223
|
-
value: function () {
|
|
224
|
-
return __awaiter(this, arguments, void 0, function (frame) {
|
|
225
|
-
if (frame === void 0) { frame = 0; }
|
|
226
|
-
return __generator(this, function (_a) {
|
|
227
|
-
switch (_a.label) {
|
|
228
|
-
case 0: return [4 /*yield*/, PixelData.get(this, frame)];
|
|
229
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
230
|
-
}
|
|
231
|
-
});
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
});
|
|
235
|
-
Object.defineProperty(Dataset.prototype, "getVOILutModule", {
|
|
236
|
-
enumerable: false,
|
|
237
|
-
configurable: true,
|
|
238
|
-
writable: true,
|
|
239
|
-
value: function () {
|
|
240
|
-
return {
|
|
241
|
-
voiLUTFunction: this.get(0x0028, 0x1056),
|
|
242
|
-
windowWidth: this.int(0x0028, 0x1051),
|
|
243
|
-
windowCenter: this.int(0x0028, 0x1050),
|
|
244
|
-
voiLUTSequence: this.get(0x0028, 0x3010),
|
|
245
|
-
lutDescriptor: this.get(0x0028, 0x3002),
|
|
246
|
-
lutExplanation: this.get(0x0028, 0x3003),
|
|
247
|
-
lutData: this.get(0x0028, 0x3006),
|
|
248
|
-
windowCenterAndWidthExplanation: this.get(0x0028, 0x1055),
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
Object.defineProperty(Dataset.prototype, "getPatientModule", {
|
|
253
|
-
enumerable: false,
|
|
254
|
-
configurable: true,
|
|
255
|
-
writable: true,
|
|
256
|
-
value: function () {
|
|
257
|
-
return {
|
|
258
|
-
patientName: this.get(0x0010, 0x0010),
|
|
259
|
-
patientID: this.get(0x0010, 0x0020),
|
|
260
|
-
typeofPatientID: this.get(0x0010, 0x0022),
|
|
261
|
-
patientSex: this.get(0x0010, 0x0040),
|
|
262
|
-
patientBirthDate: this.get(0x0010, 0x0030),
|
|
263
|
-
patientAge: this.get(0x0010, 0x1010),
|
|
264
|
-
patientSize: this.get(0x0010, 0x1020),
|
|
265
|
-
otherPatientIDs: this.get(0x0010, 0x1000),
|
|
266
|
-
otherPatientNames: this.get(0x0010, 0x1001),
|
|
267
|
-
patientWeight: this.get(0x0010, 0x1030),
|
|
268
|
-
};
|
|
269
|
-
}
|
|
270
|
-
});
|
|
271
|
-
Object.defineProperty(Dataset.prototype, "getPixelModule", {
|
|
272
|
-
enumerable: false,
|
|
273
|
-
configurable: true,
|
|
274
|
-
writable: true,
|
|
275
|
-
value: function () {
|
|
276
|
-
var pixelMeasuresSequence = this.get(0x0028, 0x9110);
|
|
277
|
-
return {
|
|
278
|
-
pixelMeasuresSequence: pixelMeasuresSequence,
|
|
279
|
-
photometricInterpretation: this.get(0x0028, 0x0004),
|
|
280
|
-
numberOfFrames: this.int(0x0028, 0x0008),
|
|
281
|
-
pixelRepresentation: this.int(0x0028, 0x0103),
|
|
282
|
-
pixelSpacing: this.getPixelSpacing(),
|
|
283
|
-
rows: this.int(0x0028, 0x0010),
|
|
284
|
-
columns: this.int(0x0028, 0x0011),
|
|
285
|
-
bitsAllocated: this.int(0x0028, 0x0100),
|
|
286
|
-
highBit: this.int(0x0028, 0x0102),
|
|
287
|
-
bitsStored: this.int(0x0028, 0x0101),
|
|
288
|
-
samplesPerPixel: this.int(0x0028, 0x0002),
|
|
289
|
-
pixelDataProviderURL: this.get(0x0028, 0x7FE0),
|
|
290
|
-
pixelPaddingRangeLimit: this.get(0x0028, 0x0121),
|
|
291
|
-
extendedOffsetTable: this.get(0x7FE0, 0x0001),
|
|
292
|
-
extendedOffsetTableLengths: this.get(0x7FE0, 0x0002),
|
|
293
|
-
pixelAspectRatio: this.get(0x0028, 0x0034),
|
|
294
|
-
planarConfiguration: this.int(0x0028, 0x0006),
|
|
295
|
-
redPaletteColorLookupTableDescriptor: this.get(0x0028, 0x1101),
|
|
296
|
-
greenPaletteColorLookupTableDescriptor: this.get(0x0028, 0x1102),
|
|
297
|
-
bluePaletteColorLookupTableDescriptor: this.get(0x0028, 0x1103),
|
|
298
|
-
alphaPaletteColorLookupTableDescriptor: this.get(0x0028, 0x1104),
|
|
299
|
-
redPaletteColorLookupTableData: this.get(0x0028, 0x1201),
|
|
300
|
-
greenPaletteColorLookupTableData: this.get(0x0028, 0x1202),
|
|
301
|
-
bluePaletteColorLookupTableData: this.get(0x0028, 0x1203),
|
|
302
|
-
alphaPaletteColorLookupTableData: this.get(0x0028, 0x1204),
|
|
303
|
-
segmentedRedPaletteColorLookupTableData: this.get(0x0028, 0x1221),
|
|
304
|
-
segmentedGreenPaletteColorLookupTableData: this.get(0x0028, 0x1222),
|
|
305
|
-
segmentedBluePaletteColorLookupTableData: this.get(0x0028, 0x1223),
|
|
306
|
-
segmentedAlphaPaletteColorLookupTableData: this.get(0x0028, 0x1224),
|
|
307
|
-
};
|
|
308
|
-
}
|
|
309
|
-
});
|
|
310
|
-
// TODO: need to add more login to advance
|
|
311
|
-
Object.defineProperty(Dataset.prototype, "getPixelSpacing", {
|
|
312
|
-
enumerable: false,
|
|
313
|
-
configurable: true,
|
|
314
|
-
writable: true,
|
|
315
|
-
value: function () {
|
|
316
|
-
var pixelSpacing = this.get(0x0028, 0x0030);
|
|
317
|
-
if (pixelSpacing)
|
|
318
|
-
return pixelSpacing;
|
|
319
|
-
var sharedFunctionalGroupsSequence = this.tags["0x52009229"];
|
|
320
|
-
console.log({ sharedFunctionalGroupsSequence: sharedFunctionalGroupsSequence });
|
|
321
|
-
if (sharedFunctionalGroupsSequence
|
|
322
|
-
&& sharedFunctionalGroupsSequence.vr === "SQ"
|
|
323
|
-
&& typeof sharedFunctionalGroupsSequence.value) {
|
|
324
|
-
var pixelSpacing_1 = this._findTagsByKey('0x00280030', sharedFunctionalGroupsSequence.value, 1024);
|
|
325
|
-
if (pixelSpacing_1) {
|
|
326
|
-
return Value.byVr(this.dataView, pixelSpacing_1.offset, pixelSpacing_1.valueLength, pixelSpacing_1.vr, this.littleEndian);
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
});
|
|
331
|
-
Object.defineProperty(Dataset.prototype, "getScalingModule", {
|
|
332
|
-
enumerable: false,
|
|
333
|
-
configurable: true,
|
|
334
|
-
writable: true,
|
|
335
|
-
value: function () {
|
|
336
|
-
return {
|
|
337
|
-
rescaleSlope: this.int(0x0028, 0x1053),
|
|
338
|
-
rescaleIntercept: this.int(0x0028, 0x1052),
|
|
339
|
-
modality: this.modality,
|
|
340
|
-
};
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
Object.defineProperty(Dataset.prototype, "date", {
|
|
344
|
-
enumerable: false,
|
|
345
|
-
configurable: true,
|
|
346
|
-
writable: true,
|
|
347
|
-
value: function (group, element) {
|
|
348
|
-
var dateValue = this.get(group, element);
|
|
349
|
-
if (/^[0-9]{4}\-[0-9]{2}\-[0-9]{2}$/.exec(dateValue)) {
|
|
350
|
-
var dateVaues = dateValue.split('-');
|
|
351
|
-
return {
|
|
352
|
-
year: dateVaues[0],
|
|
353
|
-
month: dateVaues[1],
|
|
354
|
-
day: dateVaues[2],
|
|
355
|
-
};
|
|
356
|
-
}
|
|
357
|
-
return dateValue;
|
|
358
|
-
}
|
|
359
|
-
});
|
|
360
|
-
Object.defineProperty(Dataset.prototype, "time", {
|
|
361
|
-
enumerable: false,
|
|
362
|
-
configurable: true,
|
|
363
|
-
writable: true,
|
|
364
|
-
value: function (group, element) {
|
|
365
|
-
var dateValue = this.get(group, element);
|
|
366
|
-
if (/^[0-9]{2}\:[0-9]{2}\:[0-9]{2}$/.exec(dateValue)) {
|
|
367
|
-
var dateVaues = dateValue.split(':');
|
|
368
|
-
return {
|
|
369
|
-
hour: dateVaues[0],
|
|
370
|
-
minute: dateVaues[1],
|
|
371
|
-
second: dateVaues[2],
|
|
372
|
-
};
|
|
373
|
-
}
|
|
374
|
-
return dateValue;
|
|
375
|
-
}
|
|
376
|
-
});
|
|
377
|
-
Object.defineProperty(Dataset.prototype, "int", {
|
|
378
|
-
enumerable: false,
|
|
379
|
-
configurable: true,
|
|
380
|
-
writable: true,
|
|
381
|
-
value: function (group, element) {
|
|
382
|
-
var is = this.get(group, element);
|
|
383
|
-
if (typeof is === "number") {
|
|
384
|
-
return is;
|
|
385
|
-
}
|
|
386
|
-
else if (Array.isArray(is) && typeof is[0] === "number") {
|
|
387
|
-
return is[0];
|
|
388
|
-
}
|
|
389
|
-
else {
|
|
390
|
-
return undefined;
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
});
|
|
394
|
-
Object.defineProperty(Dataset.prototype, "get", {
|
|
395
|
-
enumerable: false,
|
|
396
|
-
configurable: true,
|
|
397
|
-
writable: true,
|
|
398
|
-
value: function (group, element) {
|
|
399
|
-
var value = this.getValue(group, element);
|
|
400
|
-
return value;
|
|
401
|
-
}
|
|
402
|
-
});
|
|
403
|
-
Object.defineProperty(Dataset.prototype, "string", {
|
|
404
|
-
enumerable: false,
|
|
405
|
-
configurable: true,
|
|
406
|
-
writable: true,
|
|
407
|
-
value: function (group, element) {
|
|
408
|
-
return this.getValue(group, element, 'string') + "";
|
|
409
|
-
}
|
|
410
|
-
});
|
|
411
|
-
Object.defineProperty(Dataset.prototype, "getValue", {
|
|
412
|
-
enumerable: false,
|
|
413
|
-
configurable: true,
|
|
414
|
-
writable: true,
|
|
415
|
-
value: function (element, elementId, vr) {
|
|
416
|
-
if (!element && !elementId) {
|
|
417
|
-
return "";
|
|
418
|
-
}
|
|
419
|
-
var _group, _element = "";
|
|
420
|
-
if (typeof element === 'string' && element.length >= 8) {
|
|
421
|
-
var el = element.replace(/^0[xX]/, '');
|
|
422
|
-
if (el.length !== 8) {
|
|
423
|
-
return "";
|
|
424
|
-
}
|
|
425
|
-
_group = el.slice(0, 3);
|
|
426
|
-
_element = el.slice(4, 7);
|
|
427
|
-
}
|
|
428
|
-
else if (typeof element === 'number' && element > 0xffff) {
|
|
429
|
-
var el = Tag.intTo4digitString(element);
|
|
430
|
-
_group = el.slice(0, 3);
|
|
431
|
-
_element = el.slice(4, 7);
|
|
432
|
-
}
|
|
433
|
-
else {
|
|
434
|
-
_group = this._reformatToString(element);
|
|
435
|
-
_element = this._reformatToString(elementId);
|
|
436
|
-
if (!_group || !_element)
|
|
437
|
-
return "";
|
|
438
|
-
}
|
|
439
|
-
var key = "0x".concat(_group).concat(_element);
|
|
440
|
-
var tag = this._findTagsByKey(key, this.tags);
|
|
441
|
-
if (!tag) {
|
|
442
|
-
return "";
|
|
443
|
-
}
|
|
444
|
-
var _vr = vr || (tag === null || tag === void 0 ? void 0 : tag.vr) || Tag.getTagVRFromDictionary(_group, _element) || "AA";
|
|
445
|
-
if (_vr === "SQ") {
|
|
446
|
-
return tag.value;
|
|
447
|
-
}
|
|
448
|
-
return this._getValue(tag, _vr);
|
|
449
|
-
}
|
|
450
|
-
});
|
|
451
|
-
Object.defineProperty(Dataset.prototype, "getPaletteColorData", {
|
|
452
|
-
enumerable: false,
|
|
453
|
-
configurable: true,
|
|
454
|
-
writable: true,
|
|
455
|
-
value: function () {
|
|
456
|
-
return PaletteColor.get(this);
|
|
457
|
-
}
|
|
458
|
-
});
|
|
459
|
-
Object.defineProperty(Dataset.prototype, "_findTagsByKey", {
|
|
460
|
-
enumerable: false,
|
|
461
|
-
configurable: true,
|
|
462
|
-
writable: true,
|
|
463
|
-
value: function (key, tags, depth) {
|
|
464
|
-
if (depth === void 0) { depth = 1; }
|
|
465
|
-
if (tags[key]) {
|
|
466
|
-
return tags[key];
|
|
467
|
-
}
|
|
468
|
-
if (depth === 1) {
|
|
469
|
-
return null;
|
|
470
|
-
}
|
|
471
|
-
var keys = Object.keys(tags);
|
|
472
|
-
var sqs = [];
|
|
473
|
-
keys.forEach(function (key) {
|
|
474
|
-
if (tags[key].vr === 'SQ' && typeof tags[key].value === "object") {
|
|
475
|
-
sqs.push(tags[key].value);
|
|
476
|
-
}
|
|
477
|
-
});
|
|
478
|
-
for (var i = 0; i < sqs.length; i++) {
|
|
479
|
-
var finded = this._findTagsByKey(key, sqs[i], depth - 1);
|
|
480
|
-
if (finded) {
|
|
481
|
-
return finded;
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
return null;
|
|
485
|
-
}
|
|
486
|
-
});
|
|
487
|
-
Object.defineProperty(Dataset.prototype, "_getValue", {
|
|
488
|
-
enumerable: false,
|
|
489
|
-
configurable: true,
|
|
490
|
-
writable: true,
|
|
491
|
-
value: function (tag, vr) {
|
|
492
|
-
if (vr === void 0) { vr = "AA"; }
|
|
493
|
-
var offset = tag.offset;
|
|
494
|
-
if (!offset)
|
|
495
|
-
return "";
|
|
496
|
-
var len = tag.valueLength;
|
|
497
|
-
var value = Value.byVr(this.dataView, offset, len, vr, this.littleEndian);
|
|
498
|
-
tag.value = value;
|
|
499
|
-
return value;
|
|
500
|
-
}
|
|
501
|
-
});
|
|
502
|
-
// private _getSqValues(key:string){
|
|
503
|
-
// const sqValues:object = {};
|
|
504
|
-
// const values = this.tags[key]?.value as Tags;
|
|
505
|
-
// console.log({values})
|
|
506
|
-
// if(!values) return {};
|
|
507
|
-
// const keys = Object.keys(values as object);
|
|
508
|
-
// if(!keys || !Array.isArray(keys) || keys.length<1){
|
|
509
|
-
// return {};
|
|
510
|
-
// }
|
|
511
|
-
// keys.forEach((key:string)=>{
|
|
512
|
-
// //@ts-ignore
|
|
513
|
-
// if(typeof values[key] === "object"){
|
|
514
|
-
// const name = (values[key])?.name as string;
|
|
515
|
-
// if(typeof name === "string" && name.length>0){
|
|
516
|
-
// const offset = (values[key])?.offset;
|
|
517
|
-
// const vr = (values[key])?.vr;
|
|
518
|
-
// const len = (values[key])?.valueLength;
|
|
519
|
-
// //@ts-ignore
|
|
520
|
-
// sqValues[name] = Value.byVr(
|
|
521
|
-
// this.dataView,
|
|
522
|
-
// offset,
|
|
523
|
-
// len,
|
|
524
|
-
// vr,
|
|
525
|
-
// this.littleEndian
|
|
526
|
-
// );
|
|
527
|
-
// }
|
|
528
|
-
// }
|
|
529
|
-
// })
|
|
530
|
-
// }
|
|
531
|
-
Object.defineProperty(Dataset.prototype, "_reformatToString", {
|
|
532
|
-
enumerable: false,
|
|
533
|
-
configurable: true,
|
|
534
|
-
writable: true,
|
|
535
|
-
value: function (input) {
|
|
536
|
-
if (!input)
|
|
537
|
-
return "";
|
|
538
|
-
if (typeof input === "string") {
|
|
539
|
-
return input.replace(/^0[xX]/, '');
|
|
540
|
-
}
|
|
541
|
-
return Tag.intTo4digitString(input);
|
|
542
|
-
}
|
|
543
|
-
});
|
|
544
|
-
Object.defineProperty(Dataset, "Float", {
|
|
545
|
-
enumerable: true,
|
|
546
|
-
configurable: true,
|
|
547
|
-
writable: true,
|
|
548
|
-
value: "Float"
|
|
549
|
-
});
|
|
550
|
-
Object.defineProperty(Dataset, "Integer", {
|
|
551
|
-
enumerable: true,
|
|
552
|
-
configurable: true,
|
|
553
|
-
writable: true,
|
|
554
|
-
value: "Integer"
|
|
555
|
-
});
|
|
556
|
-
return Dataset;
|
|
557
|
-
}());
|
|
558
|
-
export default Dataset;
|