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] PolySegWasmContourToStackLabelmap ERROR #1837

Open
zhoualibaba opened this issue Feb 20, 2025 · 4 comments
Open

[Bug] PolySegWasmContourToStackLabelmap ERROR #1837

zhoualibaba opened this issue Feb 20, 2025 · 4 comments

Comments

@zhoualibaba
Copy link

zhoualibaba commented Feb 20, 2025

Describe the Bug

Vite + vue3
When I attempted to convert the contour segmentation to labelmap segmentation using the example Convert contour segmentation to stack labelmap as a reference, an error occurred. The error message is: Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.
Image

I made efforts to troubleshoot this issue. I suspect that the problem might lie in the file
/node_modules/@cornerstonejs/tools/dist/esm/stateManagement/segmentation/polySeg/registerPolySegWorker.js
Image

I made an attempt to modify the path, as shown in the following image:
Image

After changing the path, the error changed. Here's an image of the new error state:

Image

Furthermore, after experimenting with vite-plugin-wasm, the error changed again, as shown in the image below:

Image

I've configured my project according to the guidelines in vue-angular-react-etc

Steps to Reproduce

1.load stack image use wadouri
2.use LinearSplineROI draw segmentation
3.change segmentation from contour to labelmap
await segmentation.addSegmentationRepresentations(viewportId, [ { segmentationId: segmentationId, type: csToolsEnums.SegmentationRepresentations.Labelmap } ])
4.use brush tool

The current behavior

d

The expected behavior

d

OS

d

Node version

d

Browser

d

@sedghi
Copy link
Member

sedghi commented Feb 20, 2025

this is a vite issue i'm pretty sure, but i will look into it. Since our nextjs recipe (webpack) works fine.

@sedghi
Copy link
Member

sedghi commented Feb 20, 2025

This works, can you confirm too?

export default defineConfig({
  assetsInclude: ["**/*.wasm"],
  plugins: [react(), viteCommonjs()],

  // seems like only required in dev mode, there is an issue with vite import.meta.url
  // in dev mode see https://github.com/vitejs/vite/issues/8427
  optimizeDeps: {
    exclude: ["@cornerstonejs/dicom-image-loader", "@cornerstonejs/tools"],
    include: ["dicom-parser", "xmlbuilder2"],
  },
  worker: {
    format: "es",
  },
})

@zhoualibaba
Copy link
Author

@sedghi Thank you for your reply. It's really helpful. This configuration has solved the package reference issue.

However, there are still some problems with the type conversion of segmentation in my project. There is no error reported, but the corresponding labelmap data does not appear in the converted viewport. I will try again.

I would like to know if you will develop a method to directly convert a certain segmentation from Contour to Labelmap in one viewport in your future development plan.

@sedghi
Copy link
Member

sedghi commented Feb 21, 2025

Yeah there are already convertors for it https://www.cornerstonejs.org/live-examples/polysegwasmcontourtostacklabelmap

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

2 participants