import dicom in javascript

To import DICOM files in JavaScript, the cornerstone library can be used. This library provides a set of tools to display medical images in web pages.

To get started, the cornerstone package needs to first be installed using npm:

index.tsx
npm install cornerstone-core cornerstone-math cornerstone-tools cornerstone-wado-image-loader
94 chars
2 lines

Once installed, the library can be imported and called as follows:

index.tsx
// Import cornerstone library
import * as cornerstone from 'cornerstone-core';
import { ImageLoader } from 'cornerstone-wado-image-loader';

// Set the image loader
cornerstone.registerImageLoader('wado', ImageLoader);

// Load the DICOM image
const imageId = 'wado://myserver.com/path/to/my/image.dcm';
cornerstone.loadAndCacheImage(imageId).then((image) => {
  // Display the image in a web viewer
});
404 chars
13 lines

The cornerstone-wado-image-loader package is used to read DICOM files from a DICOMweb server using the WADO-RS protocol. The image can be loaded by specifying its URL as the imageId parameter in the loadAndCacheImage method.

Once the image is loaded, it can be displayed in a web viewer by using additional tools provided by the cornerstone library.

gistlibby LogSnag