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

@vindr/dicom-image-loader

v1.28.4

Published

Cornerstone Image Loader for DICOM WADO-URI and WADO-RS and Local file

Downloads

55

Readme

DICOM Image Loader

This package provides a DICOM image loader for the Cornerstone library. This is the successor to the [cornerstoneDICOMImageLoader] which provides the following added features:

  • Typescript support (and type definitions)
  • Better developer experience (e.g. mono repo, linting, etc)

A cornerstone Image Loader for DICOM P10 instances over HTTP (WADO-URI) or DICOMWeb (WADO-RS) and Local filedisk. This can be used to integrate cornerstone with WADO-URI servers, DICOMWeb servers or any other HTTP based server that returns DICOM P10 instances (e.g. Orthanc or custom servers)

Key Features

  • Implements a cornerstone ImageLoader for DICOM P10 Instances via a HTTP get request.
    • Can be used with a WADO-URI server
    • Can be used with Orthanc's file endpoint
    • Can be used with any server that returns DICOM P10 instances via HTTP GET
  • Implements a cornerstone ImageLoader for WADO-RS (DICOMWeb)
  • Supports many popular transfer syntaxes and photometric interpretations see full list and codec for more information.
  • Dynamicly Utilizes WebAssembly (WASM) builds of each codec which sgnificantly improves image decoding performance and enables us to load codec at runtime when needed dynamically, which reduces the build time and complexity.
  • Framework to execute CPU intensive tasks in web workers
    • Used for image decoding
    • Can be used for your own CPU intensive tasks (e.g. image processing)

Install

NPM

yarn add @cornerstonejs/dicom-image-loader

Usage

Specify the cornerstone instance you want to register the loader with.

cornerstoneDICOMImageLoader.external.cornerstone = cornerstone;

Have your code configure the web worker framework:

var config = {
  maxWebWorkers: navigator.hardwareConcurrency || 1,
  startWebWorkersOnDemand: true,
};
cornerstoneDICOMImageLoader.webWorkerManager.initialize(config);

See the web workers documentation for more details on configuring.

Dynamic Import

To be able to use the dynamic import feature for CDIL, instead of

import cornerstoneDICOMImageLoader from '@cornerstonejs/dicom-image-loader';

you need to do:

import cornerstoneDICOMImageLoader from '@cornerstonejs/dicom-image-loader/dist/dynamic-import/cornerstoneDICOMImageLoader.min.js';

This way, codecs are loaded dynamically when needed. You have another option to create an alias in the webpack config file:

resolve: {
  alias: {
    '@cornerstonejs/dicom-image-loader':
      '@cornerstonejs/dicom-image-loader/dist/dynamic-import/cornerstoneDICOMImageLoader.min.js',
  },
},

In addition WASM builds of the codec files should be made available in the build folder. You can use CopyWebpackPlugin to copy the WASM files to the build folder.

 plugins: [
  new CopyWebpackPlugin([
    {
      from:
        '../../../node_modules/@cornerstonejs/dicom-image-loader/dist/dynamic-import',
      to: DIST_DIR,
    },
  ]),

Note 1: You need to give the correct path in the CopyWebpackPlugin, the above path is relative to the node_modules folder in the OHIF Viewer.

Note 2: For other http servers like IIS, you need to configure it to serve WASM files with the correct MIME type.

Loading

Alt text

Backlog

  • ESM build for the library
  • Make the examples work again
  • Free up DICOM P10 instance after decoding to reduce memory consumption
  • Look at using EMSCRIPTEN based build of IJG for JPEG
  • Add support for bulk data items to WADO-RS Loader
  • WebWorker Manager
    • Better handling of web worker loading
    • Add events to webWorkerManager so its activity can be monitored
    • Add support for issuing progress events from web worker tasks

FAQ

Why is this a separate library from cornerstone?

Mainly to avoid adding a dependency to cornerstone for the DICOM parsing library. While cornerstone is intended to be used to display medical images that are stored in DICOM, cornerstone aims to simplify the use of medical imaging and therefore tries to hide some of the complexity that exists within DICOM. It is also desirable to support display of non DICOM images so a DICOM independent image model makes sense.

How do I build this library myself?

See the documentation here

How do I add my own custom web worker tasks?

See the documentation here

How do I create imageIds that work with this image loader?

See the documentation here

What Transfer Syntaxes are supported?

See transfer syntaxes