How to load a volume with local file like Stack?

Hello everyone, i am using cornerstonejs to experiment Stack and Volume loading in a simple viewport with local file () and not with a enhanced DICOM server.
For the StackViewport , it’s working , just loading the file and creating imageIds
using

...
const imageId =
                cornerstoneDICOMImageLoader.wadouri.fileManager.add(file);
...
 await prefetchMetadataInformation(imageIds);
const stack = convertMultiframeImageIds(imageIds);

viewport
.setStack(stack)

viewport.render()

But for Volume rendering it’s not working

here is my loadVolume function code :

const loadVolume = async (imageIds: any) => {
        try {
        const volume = await volumeLoader.createAndCacheVolume(
            activeViewportId,
            {
                imageIds
            }
        );

        console.log("volume", volume);

        const re = getRenderingEngine(activeRenderingEngineId);
        const viewport = re?.getViewport(activeViewportId) as VolumeViewport;

        if (!viewport) return;

        // Set the volume to load
        volume.load();
        const windowWidth = 400;
        const windowCenter = 40;

        const lower = windowCenter - windowWidth / 2.0;
        const upper = windowCenter + windowWidth / 2.0;

        // Set the volume on the viewport and it's default properties
        viewport
            .setVolumes([
                {
                    volumeId: activeViewportId,
                    callback: ({ volumeActor }) => {
                        volumeActor
                            .getProperty()
                            .getRGBTransferFunction(0)
                            .setMappingRange(lower, upper);
                    }
                }
            ])
            .then(() => {
                viewport.setProperties({
                    voiRange: { lower: -160, upper: 240 },
                    VOILUTFunction: VOILUTFunctionType.LINEAR,
                    colormap: { name: "Grayscale" },
                    slabThickness: 0.1
                });
            });

        // Render the image
        viewport.render();
        } catch (error) {
            console.error("error occured while loading the volume", error)
        }

    };

Any idea why ?

1 Like

Hi, @themooneer

I am facing the same issue as you. Did you manage to resolve this problem?
If so, could you share how you solved it?

Thank you!

I’m not suer what is the question, can you re-iterate please

Hi,
I am facing the same issue as well, do we have to extract metadata from the set of dicom files manually and add it to the imageIds using
dicomImageLoader.wadors.metaDataManager.add(imageId, metadata);
in order to load the volume?
I dont know if im making sense of not, im completely new to cornerstonejs.
please help me if possible

Hello, I have the same problem, is it solved

I tried to load the dcm file with ‘await imageLoader.loadImage(imageIds[0])’
I can confirm that the file was retrieved normally, but there was a problem when parsing it

This is an anomaly.

TypeError: Cannot read properties of undefined (reading '0')
    at RequestPoolManager.addRequest (http://192.168.110.49:3000/_nuxt/node_modules/.cache/vite/client/deps/chunk-MTKSKRDC.js?v=8d285b6a:4694:31)
    at http://192.168.110.49:3000/_nuxt/node_modules/.cache/vite/client/deps/chunk-CYLWABI2.js?v=8d285b6a:44912:30
    at new Promise (<anonymous>)
    at CentralizedWorkerManager.executeTask (http://192.168.110.49:3000/_nuxt/node_modules/.cache/vite/client/deps/chunk-CYLWABI2.js?v=8d285b6a:44878:12)
    at processDecodeTask (http://192.168.110.49:3000/_nuxt/node_modules/@cornerstonejs/dicom-image-loader/dist/esm/imageLoader/decodeImageFrame.js?v=8d285b6a:12:29)
    at decodeImageFrame (http://192.168.110.49:3000/_nuxt/node_modules/@cornerstonejs/dicom-image-loader/dist/esm/imageLoader/decodeImageFrame.js?v=8d285b6a:28:20)
    at createImage (http://192.168.110.49:3000/_nuxt/node_modules/@cornerstonejs/dicom-image-loader/dist/esm/imageLoader/createImage.js?v=8d285b6a:71:27)
    at dataSetPromise.then.reject.error.error (http://192.168.110.49:3000/_nuxt/node_modules/@cornerstonejs/dicom-image-loader/dist/esm/imageLoader/wadouri/loadImage.js?v=8d285b6a:24:34)

Can you check the latest OHIF viewer, which now includes Cornerstone 3D 2.0?

Here are the migration guides:

Try OHIF locally: OHIF Viewer
Try Cornerstone3D 2.0 locally: https://www.cornerstonejs.org/live-examples/local.html