cornerstone3D icon indicating copy to clipboard operation
cornerstone3D copied to clipboard

[Bug] Unable to parse DICOM

Open kin3tik opened this issue 2 months ago • 2 comments

Describe the Bug

Apologies if this is the wrong place to post/not a bug but I'm at my wits end and would really appreciate any assistance.

I am attempting to load and render a DICOM file into the viewport, but I only receive a blank/black viewport. The browser console displays the error Cannot read properties of undefined (reading 'samplesPerPixel').

If I copy createImageIdsAndCacheMetaData from here and manually set the metadata I am able to get the DICOM image to render in the viewport. Is setting metadata manually mandatory to display DICOM?

Steps to Reproduce

The relevant js for my minimal repro below:

import {
    RenderingEngine,
    Enums,
    init as csRenderInit,
} from '@cornerstonejs/core';

import {
    init as csDICOMImageLoaderInit,
} from '@cornerstonejs/dicom-image-loader';

async function run() {    

    await csRenderInit({
        debug: {
            statsOverlay: true
        }
    });

    await csDICOMImageLoaderInit({
        maxWebWorkers: navigator.hardwareConcurrency || 1
    });

    const content = document.getElementById('cornerstone-element');

    const renderingEngineId = 'myRenderingEngine';
    const renderingEngine = new RenderingEngine(renderingEngineId);

    const viewportId = 'VIEWPORT';
    const viewportInput = {
        viewportId,
        type: Enums.ViewportType.STACK,
        element: content
    };

    renderingEngine.enableElement(viewportInput);   

    // pull from local orthanc
    let studyuid    = 'xxxxx';
    let seriesuid   = 'xxxxx';
    let instanceuid = 'xxxxx';
    const imageIds = ["wadors:http://localhost:8042/dicom-web/studies/"+studyuid+"/series/"+seriesuid+"/instances/"+instanceuid+"/frames/1"];

    const viewport = renderingEngine.getViewport(viewportId);

    await viewport.setStack(imageIds);

    viewport.render();
}

run();

The current behavior

Viewport is blank and there is an error in the console indicating metadata was not parsed from the DICOM file Cannot read properties of undefined (reading 'samplesPerPixel')

The expected behavior

DICOM image rendered into viewport.

System Information

  System:
    OS: Windows 11 10.0.26100
    CPU: (22) x64 Intel(R) Core(TM) Ultra 7 165H
    Memory: 5.49 GB / 31.64 GB
  Binaries:
    Node: 22.18.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.9.3 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 142.0.7444.59
    Edge: Chromium (141.0.3537.99)
    Internet Explorer: 11.0.26100.1882

kin3tik avatar Oct 31 '25 13:10 kin3tik