Git Product home page Git Product logo

node-dicom's Introduction

Node.js DICOM

Build Status

The package provides the following:

  • Data dictionary according to the 2014a standard.
  • Streaming DICOM Decoder that reads a DICOM stream end emits DicomEvent instances.
  • Streaming JSON Encoder that turns a DicomEvent stream into a DICOM JSON Model
  • JSON Sink that consumes the JSON Model stream and produces an in-memory JSON Object.

Limitations:

  • ISO 2022 character sets are not in iconv-lite, this means the decoder does not currently support ISO 2022 encodings, multi-valued (0008,0005) Specific Character Set and DICOM characterset extensions.
  • Dicom Elements with a value length above a configurable threshold are not constructed in-memory, but emitted as start_element, a sequence of raw events with the encoded value and an end_element event. The JSON Encoder emits these as bulkdata URLs, but currently there is no way to use these urls (except parsing the url and extracting the bulkdata using offset and length from the url).
  • Other DICOM VRs (OB, OW, OF, OD, UN) do not provide a way to interpret the data, i.e. it's just passed on as a byte array, unchanged.

Examples:

Read a DICOM file, produce JSON Model, and print some data:

dicom = require "dicom"

decoder = dicom.decoder {guess_header: true}
encoder = new dicom.json.JsonEncoder()
sink = new dicom.json.JsonSink (err, json) ->
  if err
    console.log "Error:", err
    process.exit 10
  print_element json, dicom.tags.PatientID
  print_element json, dicom.tags.IssuerOfPatientID
  print_element json, dicom.tags.StudyInstanceUID
  print_element json, dicom.tags.AccessionNumber

print_element = (json, path...) ->
  console.log dicom.json.get_value(json, path...)

require("fs").createReadStream(process.argv[2]).pipe decoder
.pipe encoder
.pipe sink

And the same thing in Javascript:

"use strict";

var dicom = require("dicom");

var decoder = dicom.decoder({
    guess_header: true
});

var encoder = new dicom.json.JsonEncoder();

var print_element = function(json, elem) {
    console.log(dicom.json.get_value(json, elem));
};

var sink = new dicom.json.JsonSink(function(err, json) {
    if (err) {
      console.log("Error:", err);
      process.exit(10);
    }
    print_element(json, dicom.tags.PatientID);
    print_element(json, dicom.tags.IssuerOfPatientID);
    print_element(json, dicom.tags.StudyInstanceUID);
    print_element(json, dicom.tags.AccessionNumber);
});

require("fs").createReadStream(process.argv[2]).pipe(decoder).pipe(encoder).pipe(sink);

node-dicom's People

Contributors

grmble avatar anatolyg avatar soichih avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.