@cornerstonejs/dicom-image-loader 3.0.0-beta.6 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,173 +1,3 @@
1
1
  # DICOM Image Loader
2
2
 
3
- This package provides a DICOM image loader for the Cornerstone library.
4
- This is the successor to the [cornerstoneDICOMImageLoader] which provides the following
5
- added features:
6
-
7
- - Typescript support (and type definitions)
8
- - Better developer experience (e.g. mono repo, linting, etc)
9
-
10
-
11
-
12
- A [cornerstone](https://github.com/cornerstonejs/cornerstone) Image Loader for
13
- DICOM P10 instances over HTTP (WADO-URI) or DICOMWeb (WADO-RS) and Local filedisk. This can be used
14
- to integrate cornerstone with WADO-URI servers, DICOMWeb servers or any other
15
- HTTP based server that returns DICOM P10 instances (e.g.
16
- [Orthanc](http://www.orthanc-server.com/) or custom servers)
17
-
18
- ## Key Features
19
-
20
- - Implements a
21
- [cornerstone ImageLoader](https://www.cornerstonejs.org/docs/concepts/cornerstone-core/imageLoader)
22
- for DICOM P10 Instances via a HTTP get request.
23
- - Can be used with a WADO-URI server
24
- - Can be used with Orthanc's file endpoint
25
- - Can be used with any server that returns DICOM P10 instances via HTTP GET
26
- - Implements a
27
- [cornerstone ImageLoader](https://www.cornerstonejs.org/docs/concepts/cornerstone-core/imageLoader)
28
- for WADO-RS (DICOMWeb)
29
- - Supports many popular transfer syntaxes and photometric interpretations
30
- [see full list](docs/TransferSyntaxes.md)
31
- and [codec](docs/Codecs.md) for more information.
32
- - 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.
33
- - Framework to execute CPU intensive tasks in [web workers](docs/WebWorkers.md)
34
- - Used for image decoding
35
- - Can be used for your own CPU intensive tasks (e.g. image processing)
36
-
37
-
38
- ## Install
39
-
40
- ### NPM
41
-
42
- ```bash
43
- yarn add @cornerstonejs/dicom-image-loader
44
- ```
45
-
46
-
47
-
48
- ## Usage
49
-
50
- Specify the cornerstone instance you want to register the loader with.
51
-
52
- ```javascript
53
- cornerstoneDICOMImageLoader.external.cornerstone = cornerstone;
54
- ```
55
-
56
- Have your code configure the web worker framework:
57
-
58
- ```javascript
59
- var config = {
60
- maxWebWorkers: navigator.hardwareConcurrency || 1,
61
- startWebWorkersOnDemand: true,
62
- };
63
- cornerstoneDICOMImageLoader.webWorkerManager.initialize(config);
64
- ```
65
-
66
- See the [web workers](docs/WebWorkers.md) documentation for more details on
67
- configuring.
68
-
69
-
70
-
71
- #### Dynamic Import
72
-
73
- To be able to use the dynamic import feature for CDIL, instead of
74
-
75
- ```js
76
- import cornerstoneDICOMImageLoader from '@cornerstonejs/dicom-image-loader';
77
- ```
78
-
79
- you need to do:
80
-
81
- ```js
82
- import cornerstoneDICOMImageLoader from '@cornerstonejs/dicom-image-loader/dist/dynamic-import/cornerstoneDICOMImageLoader.min.js';
83
- ```
84
-
85
- This way, codecs are loaded dynamically when needed. You have another option to
86
- create an alias in the webpack config file:
87
-
88
- ```js
89
- resolve: {
90
- alias: {
91
- '@cornerstonejs/dicom-image-loader':
92
- '@cornerstonejs/dicom-image-loader/dist/dynamic-import/cornerstoneDICOMImageLoader.min.js',
93
- },
94
- },
95
- ```
96
-
97
- In addition WASM builds of the codec files should be made available in the build
98
- folder. You can use `CopyWebpackPlugin` to copy the WASM files to the build folder.
99
-
100
-
101
- ```js
102
- plugins: [
103
- new CopyWebpackPlugin([
104
- {
105
- from:
106
- '../../../node_modules/@cornerstonejs/dicom-image-loader/dist/dynamic-import',
107
- to: DIST_DIR,
108
- },
109
- ]),
110
- ```
111
-
112
- Note 1: You need to give the correct path in the `CopyWebpackPlugin`, the above
113
- path is relative to the `node_modules` folder in the OHIF Viewer.
114
-
115
- Note 2: For other http servers like IIS, you need to configure it to serve WASM
116
- files with the correct MIME type.
117
-
118
- ## Loading
119
-
120
- ![Alt text](assets/load.png)
121
-
122
- ## Backlog
123
-
124
- - ESM build for the library
125
- - Make the examples work again
126
- - Free up DICOM P10 instance after decoding to reduce memory consumption
127
- - Look at using EMSCRIPTEN based build of IJG for JPEG
128
- - Add support for bulk data items to WADO-RS Loader
129
- - WebWorker Manager
130
- - Better handling of web worker loading
131
- - Add events to webWorkerManager so its activity can be monitored
132
- - Add support for issuing progress events from web worker tasks
133
-
134
- # FAQ
135
-
136
- _Why is this a separate library from cornerstone?_
137
-
138
- Mainly to avoid adding a dependency to cornerstone for the DICOM parsing
139
- library. While cornerstone is intended to be used to display medical images that
140
- are stored in DICOM, cornerstone aims to simplify the use of medical imaging and
141
- therefore tries to hide some of the complexity that exists within DICOM. It is
142
- also desirable to support display of non DICOM images so a DICOM independent
143
- image model makes sense.
144
-
145
- _How do I build this library myself?_
146
-
147
- See the documentation [here](docs/Building.md)
148
-
149
- _How do I add my own custom web worker tasks?_
150
-
151
- See the documentation [here](docs/WebWorkers.md)
152
-
153
- _How do I create imageIds that work with this image loader?_
154
-
155
- See the documentation [here](docs/ImageIds.md)
156
-
157
- # What Transfer Syntaxes are supported?
158
-
159
- See [transfer syntaxes](docs/TransferSyntaxes.md)
160
-
161
-
162
- [license-image]: http://img.shields.io/badge/license-MIT-blue.svg?style=flat
163
- [license-url]: LICENSE
164
-
165
- [npm-url]: https://npmjs.org/package/@cornerstonejs/dicom-image-loader
166
- [npm-version-image]: http://img.shields.io/npm/v/@cornerstonejs/dicom-image-loader.svg?style=flat
167
- [npm-downloads-image]: http://img.shields.io/npm/dm/@cornerstonejs/dicom-image-loader.svg?style=flat
168
-
169
- [travis-url]: http://travis-ci.org/cornerstonejs/cornerstoneDICOMImageLoader
170
- [travis-image]: https://travis-ci.org/cornerstonejs/cornerstoneDICOMImageLoader.svg?branch=master
171
-
172
- [coverage-url]: https://coveralls.io/github/cornerstonejs/cornerstoneDICOMImageLoader?branch=master
173
- [coverage-image]: https://coveralls.io/repos/github/cornerstonejs/cornerstoneDICOMImageLoader/badge.svg?branch=master
3
+ See full guide on [cornerstonejs.org](https://cornerstonejs.org/)
@@ -1,5 +1,4 @@
1
1
  import getMinMax from '../shared/getMinMax';
2
- import getPixelDataTypeFromMinMax from '../shared/getPixelDataTypeFromMinMax';
3
2
  import { canRenderFloatTextures, Enums, metaData, utilities, } from '@cornerstonejs/core';
4
3
  import convertColorSpace from './convertColorSpace';
5
4
  import isColorConversionRequired from './isColorConversionRequired';
@@ -8,35 +7,10 @@ import getImageFrame from './getImageFrame';
8
7
  import getScalingParameters from './getScalingParameters';
9
8
  import { getOptions } from './internal/options';
10
9
  import isColorImageFn from '../shared/isColorImage';
10
+ import removeAFromRGBA from './removeAFromRGBA';
11
+ import isModalityLUTForDisplay from './isModalityLutForDisplay';
12
+ import setPixelDataType from './setPixelDataType';
11
13
  let lastImageIdDrawn = '';
12
- function isModalityLUTForDisplay(sopClassUid) {
13
- return (sopClassUid !== '1.2.840.10008.5.1.4.1.1.12.1' &&
14
- sopClassUid !== '1.2.840.10008.5.1.4.1.1.12.2.1');
15
- }
16
- function setPixelDataType(imageFrame) {
17
- const minValue = imageFrame.smallestPixelValue;
18
- const maxValue = imageFrame.largestPixelValue;
19
- const TypedArray = getPixelDataTypeFromMinMax(minValue, maxValue);
20
- if (TypedArray) {
21
- const typedArray = new TypedArray(imageFrame.pixelData);
22
- imageFrame.pixelData = typedArray;
23
- }
24
- else {
25
- throw new Error('Could not apply a typed array to the pixel data');
26
- }
27
- }
28
- function removeAFromRGBA(pixelData, targetBuffer) {
29
- const numPixels = pixelData.length / 4;
30
- let rgbIndex = 0;
31
- let bufferIndex = 0;
32
- for (let i = 0; i < numPixels; i++) {
33
- targetBuffer[bufferIndex++] = pixelData[rgbIndex++];
34
- targetBuffer[bufferIndex++] = pixelData[rgbIndex++];
35
- targetBuffer[bufferIndex++] = pixelData[rgbIndex++];
36
- rgbIndex++;
37
- }
38
- return targetBuffer;
39
- }
40
14
  function createImage(imageId, pixelData, transferSyntax, options = {}) {
41
15
  const useRGBA = options.useRGBA;
42
16
  options.preScale = {
@@ -10,6 +10,11 @@ import { default as getMinMax } from '../shared/getMinMax';
10
10
  import { default as isColorImage } from '../shared/isColorImage';
11
11
  import { default as isJPEGBaseline8BitColor } from './isJPEGBaseline8BitColor';
12
12
  import { default as getPixelData } from './wadors/getPixelData';
13
+ import { default as getScalingParameters } from './getScalingParameters';
14
+ import { default as isColorConversionRequired } from './isColorConversionRequired';
15
+ import { default as removeAFromRGBA } from './removeAFromRGBA';
16
+ import { default as isModalityLUTForDisplay } from './isModalityLutForDisplay';
17
+ import { default as setPixelDataType } from './setPixelDataType';
13
18
  import { internal } from './internal/index';
14
19
  declare const cornerstoneDICOMImageLoader: {
15
20
  convertRGBColorByPixel: typeof convertRGBColorByPixel;
@@ -80,6 +85,11 @@ declare const cornerstoneDICOMImageLoader: {
80
85
  getMinMax: typeof getMinMax;
81
86
  isColorImage: typeof isColorImage;
82
87
  isJPEGBaseline8BitColor: typeof isJPEGBaseline8BitColor;
88
+ getScalingParameters: typeof getScalingParameters;
89
+ isColorConversionRequired: typeof isColorConversionRequired;
90
+ removeAFromRGBA: typeof removeAFromRGBA;
91
+ isModalityLUTForDisplay: typeof isModalityLUTForDisplay;
92
+ setPixelDataType: typeof setPixelDataType;
83
93
  internal: {
84
94
  xhrRequest: typeof import("./internal/xhrRequest").default;
85
95
  streamRequest: typeof import("./internal/streamRequest").default;
@@ -10,6 +10,11 @@ import { default as getMinMax } from '../shared/getMinMax';
10
10
  import { default as isColorImage } from '../shared/isColorImage';
11
11
  import { default as isJPEGBaseline8BitColor } from './isJPEGBaseline8BitColor';
12
12
  import { default as getPixelData } from './wadors/getPixelData';
13
+ import { default as getScalingParameters } from './getScalingParameters';
14
+ import { default as isColorConversionRequired } from './isColorConversionRequired';
15
+ import { default as removeAFromRGBA } from './removeAFromRGBA';
16
+ import { default as isModalityLUTForDisplay } from './isModalityLutForDisplay';
17
+ import { default as setPixelDataType } from './setPixelDataType';
13
18
  import { internal } from './internal/index';
14
19
  const cornerstoneDICOMImageLoader = {
15
20
  convertRGBColorByPixel,
@@ -28,6 +33,11 @@ const cornerstoneDICOMImageLoader = {
28
33
  getMinMax,
29
34
  isColorImage,
30
35
  isJPEGBaseline8BitColor,
36
+ getScalingParameters,
37
+ isColorConversionRequired,
38
+ removeAFromRGBA,
39
+ isModalityLUTForDisplay,
40
+ setPixelDataType,
31
41
  internal,
32
42
  };
33
43
  export { convertRGBColorByPixel, convertRGBColorByPlane, convertYBRFullByPixel, convertYBRFullByPlane, convertPALETTECOLOR, wadouri, wadors, init, convertColorSpace, createImage, decodeJPEGBaseline8BitColor, getImageFrame, getPixelData, getMinMax, isColorImage, isJPEGBaseline8BitColor, internal, };
@@ -0,0 +1,2 @@
1
+ declare function isModalityLUTForDisplay(sopClassUid: string): boolean;
2
+ export default isModalityLUTForDisplay;
@@ -0,0 +1,5 @@
1
+ function isModalityLUTForDisplay(sopClassUid) {
2
+ return (sopClassUid !== '1.2.840.10008.5.1.4.1.1.12.1' &&
3
+ sopClassUid !== '1.2.840.10008.5.1.4.1.1.12.2.1');
4
+ }
5
+ export default isModalityLUTForDisplay;
@@ -0,0 +1,3 @@
1
+ import type { Types } from '@cornerstonejs/core';
2
+ declare function removeAFromRGBA(pixelData: Types.PixelDataTypedArray, targetBuffer: Uint8ClampedArray | Uint8Array): Uint8Array | Uint8ClampedArray;
3
+ export default removeAFromRGBA;
@@ -0,0 +1,13 @@
1
+ function removeAFromRGBA(pixelData, targetBuffer) {
2
+ const numPixels = pixelData.length / 4;
3
+ let rgbIndex = 0;
4
+ let bufferIndex = 0;
5
+ for (let i = 0; i < numPixels; i++) {
6
+ targetBuffer[bufferIndex++] = pixelData[rgbIndex++];
7
+ targetBuffer[bufferIndex++] = pixelData[rgbIndex++];
8
+ targetBuffer[bufferIndex++] = pixelData[rgbIndex++];
9
+ rgbIndex++;
10
+ }
11
+ return targetBuffer;
12
+ }
13
+ export default removeAFromRGBA;
@@ -0,0 +1,2 @@
1
+ declare function setPixelDataType(imageFrame: any): void;
2
+ export default setPixelDataType;
@@ -0,0 +1,14 @@
1
+ import getPixelDataTypeFromMinMax from '../shared/getPixelDataTypeFromMinMax';
2
+ function setPixelDataType(imageFrame) {
3
+ const minValue = imageFrame.smallestPixelValue;
4
+ const maxValue = imageFrame.largestPixelValue;
5
+ const TypedArray = getPixelDataTypeFromMinMax(minValue, maxValue);
6
+ if (TypedArray) {
7
+ const typedArray = new TypedArray(imageFrame.pixelData);
8
+ imageFrame.pixelData = typedArray;
9
+ }
10
+ else {
11
+ throw new Error('Could not apply a typed array to the pixel data');
12
+ }
13
+ }
14
+ export default setPixelDataType;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/dicom-image-loader",
3
- "version": "3.0.0-beta.6",
3
+ "version": "3.0.1",
4
4
  "description": "Cornerstone Image Loader for DICOM WADO-URI and WADO-RS and Local file",
5
5
  "keywords": [
6
6
  "DICOM",
@@ -116,7 +116,7 @@
116
116
  "uuid": "^9.0.0"
117
117
  },
118
118
  "peerDependencies": {
119
- "@cornerstonejs/core": "^3.0.0-beta.6",
119
+ "@cornerstonejs/core": "^3.0.1",
120
120
  "dicom-parser": "^1.8.9"
121
121
  },
122
122
  "lint-staged": {
@@ -131,5 +131,5 @@
131
131
  "path": "./node_modules/cz-conventional-changelog"
132
132
  }
133
133
  },
134
- "gitHead": "c29fc0d8731f785f43184ab9fe43e59140e98386"
134
+ "gitHead": "ef8157e5e9c3135c34fe6194afde06b018c1655f"
135
135
  }