question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No image return when i use cornerstone.loadAndCacheImage(imageId)

See original GitHub issue
const imageId = cornerstoneWADOImageLoader.wadouri.fileManager.add(file);
        var element = document.getElementById('dicomImage');
        cornerstone.enable(element);
        cornerstone.loadAndCacheImage(imageId).then((image) => {
          console.log(image)
          //const viewport = cornerstone.getDefaultViewportForImage(element, image);
          cornerstone.displayImage(element, image);
});

Nothing print out in the callback and the promise is pending Browser print out an error cornerstoneWADOImageLoaderWebWorker.js:1 Uncaught SyntaxError: Unexpected token <

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
MasonBergstromcommented, Sep 7, 2018

Alright took awhile but I finally got it working with all of my files. For the Explicit VR Little Endian it wasn’t pako I was missing, I never initialized the WebWorker.

When I didn’t provide any config to initialize with, it was using the default config. I assumed the default was using the codec provided by the NPM package since some of my images were still working just fine.

Turns out those scripts aren’t hooked up to work through the package so, I put them into my public folder in a folder called “ImageLoaderScripts” and used this:

try {
    wado.webWorkerManager.initialize({
        maxWebWorkers: 8,
        startWebWorkersOnDemand: true,
        webWorkerPath: '/ImageLoaderScripts/cornerstoneWADOImageLoaderWebWorker.min.js',
        webWorkerTaskPaths: [],
        taskConfiguration: {
            decodeTask: {
                loadCodecsOnStartup: true,
                initializeCodecsOnStartup: false,
                codecsPath: '/ImageLoaderScripts/cornerstoneWADOImageLoaderCodecs.min.js',
                usePDFJS: false,
                strict: true
            }
        }
    });
} catch (error) {
    throw new Error('cornerstoneWADOImageLoader is not loaded');
}

When adding this line to the code all of my images load perfectly. If I remove it I get the error message: Uncaught SyntaxError: Unexpected token <

Stepping through the NPM bundled code I believe the spot that throws the error is createImage.js#L77 I’m guessing when it can’t decode the image, because it’s missing a codec, the promise just rejects without explaining why. Is there an earlier spot we could throw an error that lets us know we’re missing something like codecs?

1reaction
dannyrbcommented, Mar 27, 2019

@MasonBergstrom, is this an accurate summary of what you would like to see addressed? https://github.com/cornerstonejs/cornerstoneWADOImageLoader/issues/252

Read more comments on GitHub >

github_iconTop Results From Across the Web

unable to load a dicom image using cornerstone
I am trying to load a dicom image using cornerstone library. I get an error - uncaught exception: loadImage: no image loader for...
Read more >
How to use the cornerstone-core.loadAndCacheImage ... - Snyk
Use Snyk Code to scan source code in minutes - no build needed - and fix issues ... loadAndCacheImage(imageId).then( function(image) { console.log(image); ...
Read more >
Image Loaders - cornerstone
The ImageLoader will return an Image Load Object containing a Promise which it will resolve with the corresponding Image Object once it has...
Read more >
Dynamic multiple images. - Google Groups
updates the image display. function updateTheImage(imageIndex) {. return cornerstone.loadAndCacheImage(imageIds[imageIndex]).then(function(image) {.
Read more >
cornerstonejs Demo 示例_Allen-沐风的博客
loadImage(imageId).then(function(image) { cornerstone. ... stylesheet - included to make things pretty, not needed or used by cornerstone ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found