The package provides the following:
- Data dictionary according to the 2014a standard.
- Streaming DICOM Decoder that reads a DICOM stream and 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.
- 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 anend_elementevent. 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). OtherDICOM 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.
There is documentation for the various pieces in the doc directory. Most notably:
Read a DICOM file, produce JSON Model, and print some data:
dicom=require"dicom"decoder=dicom.decoder {guess_header:true}
encoder=newdicom.json.JsonEncoder()
sink=newdicom.json.JsonSink (err, json) ->if err
console.log"Error:", err
process.exit10print_element json, dicom.tags.PatientIDprint_element json, dicom.tags.IssuerOfPatientIDprint_element json, dicom.tags.StudyInstanceUIDprint_element json, dicom.tags.AccessionNumberprint_element= (json, path...) ->console.logdicom.json.get_value(json, path...)
require("fs").createReadStream(process.argv[2]).pipe decoder
.pipe encoder
.pipe sinkAnd the same thing in Javascript:
"use strict";vardicom=require("dicom");vardecoder=dicom.decoder({guess_header: true});varencoder=newdicom.json.JsonEncoder();varprint_element=function(json,elem){console.log(dicom.json.get_value(json,elem));};varsink=newdicom.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);