Coder Social home page Coder Social logo

gdcm-js's Introduction

GDCM

NPM

This is the GDCM Library ported to JavaScript using Emscripten. It is useful to convert DICOMs between formats inside browser, ionic, hybrid apps, node... I personally created this to convert and decompress some exotic DICOM types.

Building

In order to build it, just run the buildLinuxMac.sh or buildwin.bat. It generates the javascript version of the malaterre's gdcm built with emscripten then transpiled to JavaScript. For each application it will create two files: gdcmXXX.js and gdcmXXX.mem where is XXX is the original app name.

Using

I created a npm wrapper that

  • Receives the dicom files as Uint8Array through MEMFS and the array of terminal parameters;
  • Returns the MEMFS with converted files as Uint8Array;
  • Stdout and Stderr with console output;

Using GDCM End User Applications

You can use it in same way you you use in the terminal. Please read how to use them here: gdcm referece

Example via node

var fs = require("fs");
var gdcm = require("gdcm-js");
// read dicom bytes
var dicomoriginal = new Uint8Array(fs.readFileSync('data/deflated.dcm')); 
// create a memfs with the file
var memfs = [{name: "input.dcm", data: dicomoriginal}]
// write down the params you have to write into terminal
var args = ["-i", "input.dcm", "-o", "output.dcm", "-w"]
// run the app
var result = gdcm.gdcmconv({MEMFS:memfs,arguments:args});
// get results from result
// output files will be stored into MEMFS variable
console.log("input size: " + dicomoriginal.length + ", output size: " + result.MEMFS[0].data.length);

Using directly from browser

You can load directly the desired application instead of the app from npm version. Just download and serve both files "appname.js" and "appname.mem" and use like this:

For this instance my appname is gdcmconv.

<script src="https://raw.githubusercontent.com/InfiniBrains/gdcm-js/master/gdcmconv.js"></script>

And use it:

var dicomoriginal = new Uint8Array(????); // you must provide this
var memfs = [{name: "input.dcm", data: dicomoriginal}]; 
var args = ["-i", "input.dcm", "-o", "output.dcm", "-w"]; // the very same arguments you should pass via terminal
var result =  gdcmFunc({MEMFS:memfs,arguments:args}); // run the app
console.log(result.MEMFS[0].data); // print the file output contents

Running Example

ToDo:

If you are planning to use more than one application, all of them will have the functioname gdcmFunc so be careful when importing many apps via browser. Via node this must be fine.

Authors

  • Alexandre Tolstenko
  • Cândido Sales

gdcm-js's People

Contributors

tolstenko avatar

Watchers

 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.