@cosyte/dicom 0.1.5 → 0.1.6
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/CHANGELOG.md +8 -0
- package/dist/index.cjs +32 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +32 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -9,7 +9,7 @@ var __export = (target, all) => {
|
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
// src/version.ts
|
|
12
|
-
var VERSION = "0.1.
|
|
12
|
+
var VERSION = "0.1.6";
|
|
13
13
|
|
|
14
14
|
// src/dictionary/index.ts
|
|
15
15
|
var dictionary_exports = {};
|
|
@@ -11139,8 +11139,24 @@ function directoryRecords(source) {
|
|
|
11139
11139
|
}
|
|
11140
11140
|
function csValues(el) {
|
|
11141
11141
|
if (el === void 0) return void 0;
|
|
11142
|
-
const text = el.rawBytes.toString("latin1")
|
|
11143
|
-
return Object.freeze(text === "" ? [] : text.split("\\").map(
|
|
11142
|
+
const text = stripTrailingPad(el.rawBytes.toString("latin1"));
|
|
11143
|
+
return Object.freeze(text === "" ? [] : text.split("\\").map(trimSpaces));
|
|
11144
|
+
}
|
|
11145
|
+
function stripTrailingPad(text) {
|
|
11146
|
+
let end = text.length;
|
|
11147
|
+
while (end > 0) {
|
|
11148
|
+
const code = text.charCodeAt(end - 1);
|
|
11149
|
+
if (code !== 0 && code !== 32) break;
|
|
11150
|
+
end--;
|
|
11151
|
+
}
|
|
11152
|
+
return text.slice(0, end);
|
|
11153
|
+
}
|
|
11154
|
+
function trimSpaces(value) {
|
|
11155
|
+
let start = 0;
|
|
11156
|
+
let end = value.length;
|
|
11157
|
+
while (start < end && value.charCodeAt(start) === 32) start++;
|
|
11158
|
+
while (end > start && value.charCodeAt(end - 1) === 32) end--;
|
|
11159
|
+
return value.slice(start, end);
|
|
11144
11160
|
}
|
|
11145
11161
|
function analyzeDirectory(source) {
|
|
11146
11162
|
if (!isDicomdir(source.fileMeta)) return void 0;
|
|
@@ -13799,7 +13815,7 @@ function stripPad(bytes, tag, vr, position, warnings) {
|
|
|
13799
13815
|
}
|
|
13800
13816
|
return bytes.subarray(0, end);
|
|
13801
13817
|
}
|
|
13802
|
-
function
|
|
13818
|
+
function trimSpaces2(value) {
|
|
13803
13819
|
let start = 0;
|
|
13804
13820
|
let end = value.length;
|
|
13805
13821
|
while (start < end && value.charCodeAt(start) === SPACE2) start++;
|
|
@@ -13858,7 +13874,7 @@ function decodeElementValue(element) {
|
|
|
13858
13874
|
}
|
|
13859
13875
|
if (vr === "LO" || vr === "SH" || vr === "UC") {
|
|
13860
13876
|
const text = decodeCharsetString(trimmed, tag, vr, charset, position, warnings);
|
|
13861
|
-
const values = text.split("\\").map(
|
|
13877
|
+
const values = text.split("\\").map(trimSpaces2);
|
|
13862
13878
|
return attachWarnings({ kind: "strings", values }, warnings);
|
|
13863
13879
|
}
|
|
13864
13880
|
if (vr === "LT" || vr === "ST" || vr === "UT") {
|
|
@@ -13871,7 +13887,7 @@ function decodeElementValue(element) {
|
|
|
13871
13887
|
}
|
|
13872
13888
|
if (vr === "AE" || vr === "CS" || vr === "AS" || vr === "UI") {
|
|
13873
13889
|
const text = decodeAsciiString(trimmed, tag, vr, position, warnings);
|
|
13874
|
-
const values = text.split("\\").map(
|
|
13890
|
+
const values = text.split("\\").map(trimSpaces2);
|
|
13875
13891
|
return attachWarnings({ kind: "strings", values }, warnings);
|
|
13876
13892
|
}
|
|
13877
13893
|
if (vr === "DS") {
|
|
@@ -16764,14 +16780,19 @@ function dummyBytes(vr) {
|
|
|
16764
16780
|
const buf = Buffer.from(text, "latin1");
|
|
16765
16781
|
return buf.length % 2 === 0 ? buf : Buffer.concat([buf, Buffer.from([32])]);
|
|
16766
16782
|
}
|
|
16783
|
+
function stripTrailingNulls(text) {
|
|
16784
|
+
let end = text.length;
|
|
16785
|
+
while (end > 0 && text.charCodeAt(end - 1) === 0) end--;
|
|
16786
|
+
return text.slice(0, end);
|
|
16787
|
+
}
|
|
16767
16788
|
function remapUidBytes(rawBytes, remap) {
|
|
16768
|
-
const raw = rawBytes.toString("latin1")
|
|
16789
|
+
const raw = stripTrailingNulls(rawBytes.toString("latin1"));
|
|
16769
16790
|
const remapped = raw.split("\\").map((uid2) => remap(uid2.trim())).join("\\");
|
|
16770
16791
|
const buf = Buffer.from(remapped, "latin1");
|
|
16771
16792
|
return buf.length % 2 === 0 ? buf : Buffer.concat([buf, Buffer.from([0])]);
|
|
16772
16793
|
}
|
|
16773
16794
|
function uidValueMultiplicity(rawBytes) {
|
|
16774
|
-
const raw = rawBytes.toString("latin1")
|
|
16795
|
+
const raw = stripTrailingNulls(rawBytes.toString("latin1"));
|
|
16775
16796
|
if (raw.length === 0) return 0;
|
|
16776
16797
|
return raw.split("\\").length;
|
|
16777
16798
|
}
|
|
@@ -17173,7 +17194,7 @@ function insertedSequence(tag, items, encoding) {
|
|
|
17173
17194
|
});
|
|
17174
17195
|
}
|
|
17175
17196
|
function decodeCreator(el) {
|
|
17176
|
-
return el.rawBytes.toString("latin1").
|
|
17197
|
+
return trimTrailingPad(el.rawBytes).toString("latin1").trim();
|
|
17177
17198
|
}
|
|
17178
17199
|
function isPrivateCreatorElement(tag) {
|
|
17179
17200
|
const { element } = splitTag(tag);
|
|
@@ -17301,7 +17322,7 @@ function declarationKey(group, creator) {
|
|
|
17301
17322
|
return `${String(group)}:${creator}`;
|
|
17302
17323
|
}
|
|
17303
17324
|
function decodeEnumerated(el) {
|
|
17304
|
-
return el.rawBytes.toString("latin1").
|
|
17325
|
+
return trimTrailingPad(el.rawBytes).toString("latin1").trim();
|
|
17305
17326
|
}
|
|
17306
17327
|
function readUnsignedShorts(el) {
|
|
17307
17328
|
const values = [];
|
|
@@ -17738,7 +17759,7 @@ function hasUncleanedBurnedIn(ds) {
|
|
|
17738
17759
|
if (!ds.has(TAG_PIXEL_DATA)) return false;
|
|
17739
17760
|
const flag = ds.get(TAG_BURNED_IN_ANNOTATION);
|
|
17740
17761
|
if (flag === void 0) return true;
|
|
17741
|
-
return flag.rawBytes.toString("latin1").
|
|
17762
|
+
return trimTrailingPad(flag.rawBytes).toString("latin1").trim().toUpperCase() !== "NO";
|
|
17742
17763
|
}
|
|
17743
17764
|
function deidentify(ds, options = {}) {
|
|
17744
17765
|
if (isRefusedTransferSyntax(ds.fileMeta?.transferSyntaxUID)) {
|