Home

Awesome

Daikon

Daikon is a pure JavaScript DICOM reader. Here are some of its features:

Supported Transfer Syntax

Uncompressed:

Compressed:

Usage

API and more examples

Simple Example

daikon.Parser.verbose = true;
var image = daikon.Series.parseImage(data);
var rawData = image.getRawData();  // ArrayBuffer
var interpretedData = image.getInterpretedData();  // Float32Array (handles byte order, datatype, scale, mask)
//var interpretedData = image.getInterpretedData(true);  // Array
//var interpretedData = image.getInterpretedData(false, true);  // Object with properties: data, min, max, minIndex, maxIndex, numCols, numRows

Series Example

var series = new daikon.Series();
var files = fs.readdirSync('./data/volume/');

// iterate over files
for (var ctr in files) {
    var name = './data/volume/' + files[ctr];
    var buf = fs.readFileSync(name);
    
    // parse DICOM file
    var image = daikon.Series.parseImage(new DataView(toArrayBuffer(buf)));

    if (image === null) {
        console.error(daikon.Series.parserError);
    } else if (image.hasPixelData()) {
        // if it's part of the same series, add it
        if ((series.images.length === 0) || 
                (image.getSeriesId() === series.images[0].getSeriesId())) {
            series.addImage(image);
        }
    }
}

// order the image files, determines number of frames, etc.
series.buildSeries();

// output some header info
console.log("Number of images read is " + series.images.length);
console.log("Each slice is " + series.images[0].getCols() + " x " + series.images[0].getRows());
console.log("Each voxel is " + series.images[0].getBitsAllocated() + " bits, " + 
    (series.images[0].littleEndian ? "little" : "big") + " endian");

// concat the image data into a single ArrayBuffer
series.concatenateImageData(null, function (imageData) {
    console.log("Total image data size is " + imageData.byteLength + " bytes");
});

Browser

See tests/browser.html for an example. For a more advanced example, see this class in Papaya.

Install

Get a packaged source file from the release folder:

Or install via NPM:

npm install daikon

Testing

npm test

Building

npm run build

This will output daikon.js and daikon-min.js to build/

Acknowledgments

Daikon makes use of JPEGLosslessDecoderJS for JPEG Lossless support as well as the following third-party libraries:

Also thanks to these contributors:

Disclaimer

The authors of this software have not sought nor received approval for clinical/diagnostic use of this software library.