Skip to content

Commit

Permalink
replace cswado with csdicom loader
Browse files Browse the repository at this point in the history
  • Loading branch information
sedghi committed Mar 1, 2023
1 parent 8adf346 commit 1e6b315
Show file tree
Hide file tree
Showing 24 changed files with 67 additions and 96 deletions.
2 changes: 1 addition & 1 deletion .webpack/excludeNodeModulesExcept.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function excludeNodeModulesExcept(modules) {
});

return function (modulePath) {
if (/cornerstoneWADOImageLoader/.test(modulePath)) {
if (/cornerstoneDICOMImageLoader/.test(modulePath)) {
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions .webpack/webpack.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ module.exports = (env, argv, { DIST_DIR }) => {
modules: [path.resolve(PROJECT_ROOT, './node_modules'), SRC_PATH],
extensions: ['.ts', '.tsx', '.js', '.jsx'],
alias: {
'cornerstone-wado-image-loader':
'cornerstone-wado-image-loader/dist/dynamic-import/cornerstoneWADOImageLoader.min.js',
'@cornerstonejs/dicom-image-loader':
'@cornerstonejs/dicom-image-loader/dist/dynamic-import/cornerstoneDICOMImageLoader.min.js',
},
fallback: {
fs: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/adapters/examples/cornerstoneDICOMSR/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ <h1>
<script src="https://unpkg.com/cornerstone-tools@4.16.1/dist/cornerstoneTools.js"></script>

<script src="https://unpkg.com/dicom-parser/dist/dicomParser.js"></script>
<script src="https://unpkg.com/@cornerstonejs/dicom-image-loader@3.0.2/dist/cornerstoneWADOImageLoader.min.js"></script>
<script src="https://unpkg.com/@cornerstonejs/dicom-image-loader@3.0.2/dist/cornerstoneDICOMImageLoader.min.js"></script>
<script src="https://unpkg.com/hammerjs/hammer.min.js"></script>

<script src="/js/initCornerstone.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ function getImageIdOfReferencedFrame(
const imageIdFrameNumber = Number(imageId.split("frame=")[1]);

return (
//frameNumber is zero indexed for cornerstoneWADOImageLoader image Ids.
//frameNumber is zero indexed for cornerstoneDICOMImageLoader image Ids.
sopCommonModule.sopInstanceUID === sopInstanceUid &&
imageIdFrameNumber === frameNumber - 1
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1408,7 +1408,7 @@ function getImageIdOfReferencedFrame(
const imageIdFrameNumber = Number(imageId.split("frame=")[1]);

return (
//frameNumber is zero indexed for cornerstoneWADOImageLoader image Ids.
//frameNumber is zero indexed for cornerstoneDICOMImageLoader image Ids.
sopCommonModule.sopInstanceUID === sopInstanceUid &&
imageIdFrameNumber === frameNumber - 1
);
Expand Down
4 changes: 2 additions & 2 deletions packages/core/examples/wadouri/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
setTitleAndDescription,
ctVoiRange,
} from '../../../../utils/demo/helpers';
import initCornerstoneWADOImageLoader from '../../../../utils/demo/helpers/initCornerstoneWADOImageLoader';
import initCornerstoneDICOMImageLoader from '../../../../utils/demo/helpers/initCornerstoneDICOMImageLoader';
import { init as csRenderInit } from '@cornerstonejs/core';

// This is for debugging purposes
Expand Down Expand Up @@ -99,7 +99,7 @@ addButtonToToolbar({
*/
async function run() {
// Init Cornerstone and related libraries
initCornerstoneWADOImageLoader();
initCornerstoneDICOMImageLoader();
await csRenderInit();

const renderingEngine = new RenderingEngine(renderingEngineId);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/examples/webLoader/registerWebImageLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ function registerWebImageLoader(imageLoader): void {
}

/**
* Small stripped down loader from cornerstoneWADOImageLoader
* Small stripped down loader from cornerstoneDICOMImageLoader
* Which doesn't create cornerstone images that we don't need
*/
function _loadImageIntoBuffer(
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/RenderingEngine/StackViewport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ class StackViewport extends Viewport implements IStackViewport {
windowCenter = windowCenter[0];
}

// when cornerstoneWADOImageLoader uses cornerstonejs/core types
// when cornerstoneDICOMImageLoader uses cornerstonejs/core types
// this marshalling step can be removed.
if (Object.values(VOILUTFunctionType).indexOf(voiLUTFunction) === -1) {
voiLUTFunction = VOILUTFunctionType.LINEAR;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/enums/Events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ enum Events {
IMAGE_SPACING_CALIBRATED = 'CORNERSTONE_IMAGE_SPACING_CALIBRATED',
/**
* Triggers on the eventTarget when there is a progress in the image load process. Note: this event
* is being used in the Cornerstone-WADO-Image-Loader repository. See {@link https://github.com/cornerstonejs/cornerstoneWADOImageLoader/blob/master/src/imageLoader/internal/xhrRequest.js | here}
* is being used in the dicom-image-loader repository. See {@link https://github.com/cornerstonejs/cornerstoneDICOMImageLoader/blob/master/src/imageLoader/internal/xhrRequest.js | here}
*
* Make use of {@link EventTypes.ImageLoadProgress | ImageLoadProgress Event Type } for typing your event listeners for IMAGE_LOAD_PROGRESS event,
* and see what event detail is included in {@link EventTypes.ImageLoadProgressEventDetail | ImageLoadProgress Event Detail }
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
"@cornerstonejs/core": "^0.32.0",
"@cornerstonejs/streaming-image-volume-loader": "^0.13.0",
"@cornerstonejs/tools": "^0.47.0",
"@cornerstonejs/dicom-image-loader": "^0.1.5",
"@docusaurus/core": "2.3.1",
"@docusaurus/module-type-aliases": "2.3.1",
"@docusaurus/preset-classic": "2.3.1",
"@kitware/vtk.js": "26.5.6",
"@mdx-js/react": "^1.6.21",
"@svgr/webpack": "^6.2.1",
"clsx": "^1.1.1",
"cornerstone-wado-image-loader": "^4.8.0",
"dcmjs": "^0.24.4",
"detect-gpu": "^4.0.45",
"dicom-parser": "^1.8.11",
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/webpackConfigurationPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const CopyPlugin = require('copy-webpack-plugin');
// ),
// // We use this alias and the CopyPlugin to support using the dynamic-import version
// // of WADO Image Loader
// 'cornerstone-wado-image-loader': 'cornerstone-wado-image-loader/dist/dynamic-import/cornerstoneWADOImageLoader.min.js',
// 'cornerstone-wado-image-loader': 'cornerstone-wado-image-loader/dist/dynamic-import/cornerstoneDICOMImageLoader.min.js',
// },
// },
// devServer: {
Expand Down
4 changes: 2 additions & 2 deletions packages/streaming-image-volume-loader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
},
"dependencies": {
"@cornerstonejs/core": "^0.32.0",
"cornerstone-wado-image-loader": "^4.10.0"
"@cornerstonejs/dicom-image-loader": "^0.1.5"
},
"peerDependencies": {
"@cornerstonejs/calculate-suv": "1.0.2"
},
"devDependencies": {
"@cornerstonejs/calculate-suv": "1.0.2",
"cornerstone-wado-image-loader": "^4.10.0"
"@cornerstonejs/dicom-image-loader": "^0.1.5"
},
"contributors": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ export default class BaseStreamingImageVolume extends ImageVolume {
return imageLoader.loadImage(imageId, options).then(
(image) => {
// scalarData is the volume container we are progressively loading into
// image is the pixelData decoded from workers in cornerstoneWADOImageLoader
// image is the pixelData decoded from workers in cornerstoneDICOMImageLoader
handleArrayBufferLoad(scalarData, image, options);
successCallback(imageIdIndex, imageId, scalingParameters);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default function makeVolumeMetadata(
} = metaData.get('imagePlaneModule', imageId0);

// Map to dcmjs-style keywords. This is becoming the standard and makes it
// Easier to swap out cornerstoneWADOImageLoader at a later date.
// Easier to swap out cornerstoneDICOMImageLoader at a later date.
return {
BitsAllocated: bitsAllocated,
BitsStored: bitsStored,
Expand Down
4 changes: 2 additions & 2 deletions packages/tools/examples/dynamicPetCt/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import cornerstoneWADOImageLoader from 'cornerstone-wado-image-loader';
import cornerstoneDICOMImageLoader from '@cornerstonejs/dicom-image-loader';
import {
RenderingEngine,
Types,
Expand Down Expand Up @@ -522,7 +522,7 @@ function setUpSynchronizers() {
}

async function setUpDisplay() {
const { metaDataManager } = cornerstoneWADOImageLoader.wadors;
const { metaDataManager } = cornerstoneDICOMImageLoader.wadors;
const wadoRsRoot = 'https://d28o5kq0jsoob5.cloudfront.net/dicomweb';
const StudyInstanceUID =
'1.3.6.1.4.1.12842.1.1.14.3.20220915.105557.468.2963630849';
Expand Down
6 changes: 3 additions & 3 deletions packages/tools/examples/local/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { RenderingEngine, Types, Enums, metaData } from '@cornerstonejs/core';
import cornerstoneWADOImageLoader from 'cornerstone-wado-image-loader';
import cornerstoneDICOMImageLoader from '@cornerstonejs/dicom-image-loader';
import * as cornerstoneTools from '@cornerstonejs/tools';
import htmlSetup from './htmlSetup';
import uids from './uids';
Expand Down Expand Up @@ -55,7 +55,7 @@ document
// Add the file to the cornerstoneFileImageLoader and get unique
// number for that file
const file = e.target.files[0];
const imageId = cornerstoneWADOImageLoader.wadouri.fileManager.add(file);
const imageId = cornerstoneDICOMImageLoader.wadouri.fileManager.add(file);
loadAndViewImage(imageId);
});

Expand Down Expand Up @@ -143,7 +143,7 @@ function handleFileSelect(evt) {

// this UI is only built for a single file so just dump the first one
const file = files[0];
const imageId = cornerstoneWADOImageLoader.wadouri.fileManager.add(file);
const imageId = cornerstoneDICOMImageLoader.wadouri.fileManager.add(file);
loadAndViewImage(imageId);
}

Expand Down
10 changes: 5 additions & 5 deletions packages/tools/examples/localCPU/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { RenderingEngine, Types, Enums, metaData } from '@cornerstonejs/core';
import cornerstoneWADOImageLoader from 'cornerstone-wado-image-loader';
import cornerstoneDICOMImageLoader from '@cornerstonejs/dicom-image-loader';
import * as cornerstoneTools from '@cornerstonejs/tools';
import htmlSetup from '../local/htmlSetup';
import uids from '../local/uids';

import initProviders from '../../../../utils/demo/helpers/initProviders';
import initCornerstoneWADOImageLoader from '../../../../utils/demo/helpers/initCornerstoneWADOImageLoader';
import initCornerstoneDICOMImageLoader from '../../../../utils/demo/helpers/initCornerstoneDICOMImageLoader';
import initVolumeLoader from './../../../../utils/demo/helpers/initVolumeLoader';
import { setUseCPURendering } from '@cornerstonejs/core';

Expand Down Expand Up @@ -53,7 +53,7 @@ document
// Add the file to the cornerstoneFileImageLoader and get unique
// number for that file
const file = e.target.files[0];
const imageId = cornerstoneWADOImageLoader.wadouri.fileManager.add(file);
const imageId = cornerstoneDICOMImageLoader.wadouri.fileManager.add(file);
loadAndViewImage(imageId);
});

Expand All @@ -62,7 +62,7 @@ document
*/
async function run() {
// Init Cornerstone and related libraries
await initCornerstoneWADOImageLoader();
await initCornerstoneDICOMImageLoader();
await initVolumeLoader();
await initProviders();

Expand Down Expand Up @@ -145,7 +145,7 @@ function handleFileSelect(evt) {

// this UI is only built for a single file so just dump the first one
const file = files[0];
const imageId = cornerstoneWADOImageLoader.wadouri.fileManager.add(file);
const imageId = cornerstoneDICOMImageLoader.wadouri.fileManager.add(file);
loadAndViewImage(imageId);
}

Expand Down
4 changes: 2 additions & 2 deletions utils/ExampleRunner/template-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module.exports = {
patterns: [
{
from:
'../../../node_modules/cornerstone-wado-image-loader/dist/dynamic-import',
'../../../node_modules/@cornerstonejs/dicom-image-loader/dist/dynamic-import',
to: '${destPath.replace(/\\/g, '/')}',
},
],
Expand Down Expand Up @@ -71,7 +71,7 @@ module.exports = {
)}',
// We use this alias and the CopyPlugin to support using the dynamic-import version
// of WADO Image Loader
'cornerstone-wado-image-loader': 'cornerstone-wado-image-loader/dist/dynamic-import/cornerstoneWADOImageLoader.min.js',
'@cornerstonejs/dicom-image-loader': '@cornerstonejs/dicom-image-loader/dist/dynamic-import/cornerstoneDICOMImageLoader.min.js',
},
modules,
extensions: ['.ts', '.tsx', '.js', '.jsx'],
Expand Down
4 changes: 2 additions & 2 deletions utils/ExampleRunner/template-multiexample-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ module.exports = {
)}" },
{
from:
'../../../node_modules/cornerstone-wado-image-loader/dist/dynamic-import',
'../../../node_modules/@cornerstonejs/dicom-image-loader/dist/dynamic-import',
to: '${destPath.replace(/\\/g, '/')}',
},
],
Expand All @@ -100,7 +100,7 @@ module.exports = {
)}',
// We use this alias and the CopyPlugin to support using the dynamic-import version
// of WADO Image Loader
'cornerstone-wado-image-loader': 'cornerstone-wado-image-loader/dist/dynamic-import/cornerstoneWADOImageLoader.min.js',
'@cornerstonejs/dicom-image-loader': '@cornerstonejs/dicom-image-loader/dist/dynamic-import/cornerstoneDICOMImageLoader.min.js',
},
modules,
extensions: ['.ts', '.tsx', '.js', '.jsx'],
Expand Down
4 changes: 2 additions & 2 deletions utils/demo/helpers/convertMultiframeImageIds.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { metaData } from '@cornerstonejs/core';
import cornerstoneWADOImageLoader from 'cornerstone-wado-image-loader';
import cornerstoneDICOMImageLoader from '@cornerstonejs/dicom-image-loader';

/**
* preloads imageIds metadata in memory
**/
async function prefetchMetadataInformation(imageIdsToPrefetch) {
for (let i = 0; i < imageIdsToPrefetch.length; i++) {
await cornerstoneWADOImageLoader.wadouri.loadImage(imageIdsToPrefetch[i])
await cornerstoneDICOMImageLoader.wadouri.loadImage(imageIdsToPrefetch[i])
.promise;
}
}
Expand Down
6 changes: 3 additions & 3 deletions utils/demo/helpers/createImageIdsAndCacheMetaData.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import dcmjs from 'dcmjs';
import { calculateSUVScalingFactors } from '@cornerstonejs/calculate-suv';
import { getPTImageIdInstanceMetadata } from './getPTImageIdInstanceMetadata';
import { utilities } from '@cornerstonejs/core';
import cornerstoneWADOImageLoader from 'cornerstone-wado-image-loader';
import cornerstoneDICOMImageLoader from '@cornerstonejs/dicom-image-loader';

import ptScalingMetaDataProvider from './ptScalingMetaDataProvider';
import getPixelSpacingInformation from './getPixelSpacingInformation';
Expand Down Expand Up @@ -59,7 +59,7 @@ export default async function createImageIdsAndCacheMetaData({
SOPInstanceUID +
'/frames/1';

cornerstoneWADOImageLoader.wadors.metaDataManager.add(
cornerstoneDICOMImageLoader.wadors.metaDataManager.add(
imageId,
instanceMetaData
);
Expand All @@ -72,7 +72,7 @@ export default async function createImageIdsAndCacheMetaData({

imageIds.forEach((imageId) => {
let instanceMetaData =
cornerstoneWADOImageLoader.wadors.metaDataManager.get(imageId);
cornerstoneDICOMImageLoader.wadors.metaDataManager.get(imageId);

// It was using JSON.parse(JSON.stringify(...)) before but it is 8x slower
instanceMetaData = removeInvalidTags(instanceMetaData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import dicomParser from 'dicom-parser';
import * as cornerstone from '@cornerstonejs/core';
import * as cornerstoneTools from '@cornerstonejs/tools';

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

window.cornerstone = cornerstone;
window.cornerstoneTools = cornerstoneTools;

export default function initCornerstoneWADOImageLoader() {
cornerstoneWADOImageLoader.external.cornerstone = cornerstone;
cornerstoneWADOImageLoader.external.dicomParser = dicomParser;
cornerstoneWADOImageLoader.configure({
export default function initCornerstoneDICOMImageLoader() {
cornerstoneDICOMImageLoader.external.cornerstone = cornerstone;
cornerstoneDICOMImageLoader.external.dicomParser = dicomParser;
cornerstoneDICOMImageLoader.configure({
useWebWorkers: true,
decodeConfig: {
convertFloatPixelDataToInt: false,
Expand All @@ -34,5 +34,5 @@ export default function initCornerstoneWADOImageLoader() {
},
};

cornerstoneWADOImageLoader.webWorkerManager.initialize(config);
cornerstoneDICOMImageLoader.webWorkerManager.initialize(config);
}
4 changes: 2 additions & 2 deletions utils/demo/helpers/initDemo.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import initProviders from './initProviders';
import initCornerstoneWADOImageLoader from './initCornerstoneWADOImageLoader';
import initCornerstoneDICOMImageLoader from './initCornerstoneDICOMImageLoader';
import initVolumeLoader from './initVolumeLoader';
import { init as csRenderInit } from '@cornerstonejs/core';
import { init as csToolsInit } from '@cornerstonejs/tools';

export default async function initDemo() {
initProviders();
initCornerstoneWADOImageLoader();
initCornerstoneDICOMImageLoader();
initVolumeLoader();
await csRenderInit();
await csToolsInit();
Expand Down

0 comments on commit 1e6b315

Please sign in to comment.