Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Cannot destructure property 'imagePositionPatient' of 'getMetaData(...)' as it is undefined #1730

Open
ksdhyPro opened this issue Dec 26, 2024 · 11 comments

Comments

@ksdhyPro
Copy link

Describe the Bug

Why does the setVolumesForViewports method report an error message 'Cannot destruction property' imagePositionPatient 'of' getMetaData (...) 'as it is undefined? I used pydicom to check if the file contains' imagePositionPatient'
image

Steps to Reproduce

image

The current behavior

image
pydicom
image

The expected behavior

No error reported

OS

Windows10

Node version

v18.19.0

Browser

chrome 131.0.6778.205

@ksdhyPro
Copy link
Author

The previous version of Cornerstone was 2.8.0, and I thought the latest version would solve the problem. However, updating to the latest version still has this issue

@daker
Copy link
Contributor

daker commented Dec 26, 2024

Please post the full stacktrace

@woaihengniu
Copy link

Have you solved it? I have the same problem

@quasarj
Copy link

quasarj commented Jan 8, 2025

I am having the same problem, essentially. When loading a volume using wadouri, the metaData.get() method returns undefined sometimes, which obviously prevents the viewport from rendering. The actual error reported depends on some other factors, whether it's just an undefined error or an "unable to destructure" error (like above).

I have prepared the simplest possible example of the issue that I was able to reproduce. See here, a forked copy of the Cornerstone nextjs example app, that has been modified to load images using wadouri (from TCIA): https://github.com/quasarj/nextjs-cornerstone3d

Interestingly, it works... but only when set to SAGITTAL. See here, just changing to AXIAL (or anything, in my testing) causes it to fail with the above error: https://github.com/quasarj/nextjs-cornerstone3d/tree/broken

The stack trace in this example:
Uncaught (in promise) TypeError: _metaData__WEBPACK_IMPORTED_MODULE_3__.get(...) is undefined getClosestImageId webpack-internal:///(app-pages-browser)/./node_modules/@cornerstonejs/core/dist/esm/utilities/getClosestImageId.js:28 getViewReference webpack-internal:///(app-pages-browser)/./node_modules/@cornerstonejs/core/dist/esm/RenderingEngine/VolumeViewport.js:409 addActors webpack-internal:///(app-pages-browser)/./node_modules/@cornerstonejs/core/dist/esm/RenderingEngine/Viewport.js:261 setActors webpack-internal:///(app-pages-browser)/./node_modules/@cornerstonejs/core/dist/esm/RenderingEngine/Viewport.js:233 _setVolumeActors webpack-internal:///(app-pages-browser)/./node_modules/@cornerstonejs/core/dist/esm/RenderingEngine/BaseVolumeViewport.js:865 setVolumes webpack-internal:///(app-pages-browser)/./node_modules/@cornerstonejs/core/dist/esm/RenderingEngine/BaseVolumeViewport.js:710

@woaihengniu
Copy link

woaihengniu commented Jan 12, 2025

I suspect that there are some layers of the image that are not loaded, and then call the metaData data. Now I am opening a timer to get the metaData information of each layer, and each layer needs to obtain success. Only after success can we execute setVolumesForViewports. And then the rendering is done

@quasarj
Copy link

quasarj commented Jan 12, 2025

I've tried adding some various timers/wrappers to make sure all the slices are downloaded before I attempt to execute setVolumesForViewports, but that wasn't working either. I'll see if I can put together an example...

@woaihengniu
Copy link

await volume.load();
verifyImgLoadEndtimer = setInterval(() => {
let temObjArr = [];
for (let i = 0; i < imageIds.value.length; i++) {
let imagePlane = metaData.get('imagePlaneModule', imageIds.value[i]);
let imagePixel = metaData.get('imagePixelModule', imageIds.value[i]);
if (imagePlane && imagePixel) {
temObjArr.push(imagePixel);
} else {
break;
}
}
if (temObjArr.length === imageIds.value.length) {
clearInterval(verifyImgLoadEndtimer);
setVolumesForViewports(
renderingEngine,
[{ volumeId }],
viewportIds, true
)
renderingEngine.renderViewports(viewportIds);
}
}, 1000)

@alfiehao
Copy link

You can upgrade all cornerstonejs to version 2.14.2 , have a try.

Copy link
Member

sedghi commented Jan 16, 2025

Any update on this?

@woaihengniu
Copy link

I updated to the latest version (2.15.4), but I still have this problem. I still follow the method I used above. I suspect that the layer was not downloaded, and then I went to metaData to get the data

@sedghi
Copy link
Member

sedghi commented Jan 17, 2025

can you give us a working example that shows this issue (from start (import) to finish)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants