Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let distance = ImageNormalizer.vec3Dot(positionVector, scanAxis);
distanceDatasetPairs.push([distance, dataset]);
});
distanceDatasetPairs.sort(function(a, b) {
return b[0] - a[0];
});
// assign array buffers
if (ds.BitsAllocated !== 16) {
log.error(
"Only works with 16 bit data, not " +
String(this.dataset.BitsAllocated)
);
}
if (referenceDataset._vrMap && !referenceDataset._vrMap.PixelData) {
log.warn("No vr map given for pixel data, using OW");
ds._vrMap = { PixelData: "OW" };
} else {
ds._vrMap = { PixelData: referenceDataset._vrMap.PixelData };
}
let frameSize = referenceDataset.PixelData.byteLength;
ds.PixelData = new ArrayBuffer(ds.NumberOfFrames * frameSize);
let frame = 0;
distanceDatasetPairs.forEach(function(pair) {
let dataset = pair[1];
let pixels = new Uint16Array(dataset.PixelData);
let frameView = new Uint16Array(
ds.PixelData,
frame * frameSize,
frameSize / 2
);
try {
vr.maxLength
}`
);
return value.slice(0, vr.maxLength);
} else {
return value;
}
});
}
var tag = DicomMetaDictionary.unpunctuateTag(entry.tag);
unnaturalDataset[tag] = dataItem;
} else {
const validMetaNames = ["_vrMap", "_meta"];
if (validMetaNames.indexOf(name) == -1) {
log.warn(
"Unknown name in dataset",
name,
":",
dataset[name]
);
}
}
});
return unnaturalDataset;
const pixelData = new Uint8Array(multiframe.PixelData);
const max = multiframe.MaximumFractionalValue;
const onlyMaxAndZero =
pixelData.find(element => element !== 0 && element !== max) ===
undefined;
if (!onlyMaxAndZero) {
log.warn(
"This is a fractional segmentation, which is not currently supported."
);
return;
}
log.warn(
"This segmentation object is actually binary... processing as such."
);
return pixelData;
}
function unpackPixelData(multiframe) {
const segType = multiframe.SegmentationType;
if (segType === "BINARY") {
return BitArray.unpack(multiframe.PixelData);
}
const pixelData = new Uint8Array(multiframe.PixelData);
const max = multiframe.MaximumFractionalValue;
const onlyMaxAndZero =
pixelData.find(element => element !== 0 && element !== max) ===
undefined;
if (!onlyMaxAndZero) {
log.warn(
"This is a fractional segmentation, which is not currently supported."
);
return;
}
log.warn(
"This segmentation object is actually binary... processing as such."
);
return pixelData;
}
dataItem.Value = dataItem.Value.map(value => {
if (value.length > vr.maxLength) {
log.warn(
`Truncating value ${value} of ${naturalName} because it is longer than ${
vr.maxLength
}`
);
return value.slice(0, vr.maxLength);
} else {
return value;
}
});
}