npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

daikon

v1.2.46

Published

A JavaScript DICOM reader.

Downloads

2,139

Readme

Daikon

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

  • Works in the browser and Node.js environments.
  • Parses DICOM headers and reads image data.
  • Supports compressed DICOM data.
  • Orders and concatenates multi-file image data.
  • Supports RGB and Palette data.
  • Supports Siemens "Mosaic" image data.
  • Parses Siemens CSA header.

Supported Transfer Syntax

Uncompressed:

  • 1.2.840.10008.1.2 (Implicit VR Little Endian)
  • 1.2.840.10008.1.2.1 (Explicit VR Little Endian)
  • 1.2.840.10008.1.2.2 (Explicit VR Big Endian)

Compressed:

  • 1.2.840.10008.1.2.1.99 (Deflated Explicit VR Little Endian)
  • 1.2.840.10008.1.2.4.50 (JPEG Baseline (Process 1) Lossy JPEG 8-bit)
  • 1.2.840.10008.1.2.4.51 (JPEG Baseline (Processes 2 & 4) Lossy JPEG 12-bit)
  • 1.2.840.10008.1.2.4.57 (JPEG Lossless, Nonhierarchical (Processes 14))
  • 1.2.840.10008.1.2.4.70 (JPEG Lossless, Nonhierarchical (Processes 14 [Selection 1]))
  • 1.2.840.10008.1.2.4.80 (JPEG-LS Image Compression (Lossless Only))
  • 1.2.840.10008.1.2.4.81 (JPEG-LS Image Compression)
  • 1.2.840.10008.1.2.4.90 (JPEG 2000 Image Compression (Lossless Only))
  • 1.2.840.10008.1.2.4.91 (JPEG 2000 Image Compression)
  • 1.2.840.10008.1.2.5 (RLE Lossless)

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.