@three-medical/dicom-loader
v0.0.7
Published
(WIP) three.js DICOM Loader
Downloads
3
Maintainers
Readme
dicom-loader
three.js DICOM loader
NOTE: This package is a work in progress and should not be used in production.
Usage
Install
npm install @three-medical/dicom-loader
loadImageSeries
Load a DICOM image series.
// A list of URLs pointing to .dcm files
const urls = [...];
const loader = new DicomLoader();
const volume = await loader.loadImageSeries(urls);
loadImage
Load a single DICOM image.
// A URL pointing to a .dcm file
const url = [...];
const loader = new DicomLoader();
const volume = await loader.loadImage(url);
processBufferCallback (method parameter)
Optional parameter for the loadImageSeries
and loadImage
methods.
A callback used to process the buffer received from the URL. For example, this can be useful if the buffer received is compressed.
import pako from 'pako';
// A list of URLs pointing to .dcm.gz files (NOTE: files are compressed)
const urls = [...];
const processBufferCallback = (buffer: ArrayBuffer) => {
// First we'll turn the buffer into a Uint8Array to make pako.inflate happy
const uint8 = new Uint8Array(buffer);
// Use pako to decompress the buffer
const decompressed = pako.inflate(uint8);
// Finally, return the buffer from the decompressed Uint8Array
return decompressed.buffer;
};
const loader = new DicomLoader();
const volume = await loader.loadImageSeries(urls, processBufferCallback);