cornerstonejs / cornerstone-nifti-image-loader

Nifti image loader module for cornerstone/ohif viewer
MIT License
56 stars 27 forks source link

Cornerstone3D not work #49

Closed acegank closed 1 year ago

acegank commented 1 year ago

import * as cornerstone from "@cornerstonejs/core/dist/esm"; import * as cornerstoneNIFTIImageLoader from "@cornerstonejs/nifti-image-loader/dist/cornerstoneNIFTIImageLoader"; cornerstoneNIFTIImageLoader.external.cornerstone = cornerstone;

but will error:

Cannot read properties of undefined (reading 'dispatchEvent') Cornerstone3D has not events properties

how to solve this?

kousu commented 1 year ago

The maintainer explained yesterday that unfortunately they are not yet compatible. So you cannot use

npm install @cornerstonejs/core               # aka "Cornerstone3D"
npm install @cornerstonejs/nifti-image-loader

You have to instead use

npm install cornerstone-core                   # aka "legacy Cornerstone"
npm install @cornerstonejs/nifti-image-loader  # gets 1.0.7 of this project

or

npm install cornerstone-core
npm install cornerstonejs-nifti-image-loader  # which gets the older 1.0.0 of this project

Not even the OHIF viewer, which is the main consumer and funder of Cornerstone, uses Cornerstone3D yet -- it's still on cornerstone-core^2.6.1

kousu commented 1 year ago

@acegank, if it helps, I've rewritten the example, that uses the latest nifti loader with the latest cornerstone-core:

screenshot

Unlike the older examples, my rewrite uses the Cornerstone directly off npm, instead using an old vendored copy, but it doesn't go as far as upgrading all the way to Cornerstone3D because that's impossible at the moment.

You'll have to adapt the packaging to your project, whether you're using webpack or node or rollup, and you'll probably want to add cornerstone-tools to make it more useful, but it successfully displays a .nii.gz file and should get you going.

Would you consider closing this issue now? I think it's fair to say this is a duplicate of my post at #48.

acegank commented 1 year ago

@kousu ,Thank you for the clarification!

I have another question for you, there are two nifti files, one is origin files, one is mask files(segmentation), how to overlay them?

Thanks you again!

kousu commented 1 year ago

I have another question for you, there are two nifti files, one is origin files, one is mask files(segmentation), how to overlay them?

That's a good question. I hadn't thought of trying to do that, but knowing how to do layers would be good. I have no idea. I don't even know.

The reason I posted #48 is because I am also a newbie to Cornerstone and I got lost in the documentation's sprawl, and it's apparently currently worse because they're going through a major version upgrade.

I took a look through the docs and found this, but I can't really tell if that will do the right thing, or if it's even the right code because, again, that's from the Cornerstone3D docs. But maybe if you combine reading that with reading the source of cornerstone-tools you can get it to work.

Anyway that's about all I have time for right now, but good luck with your project!

acegank commented 1 year ago

thanks! you are right. if use Cornerstone3D will be easy. but use cornerstone-core i can't solve it.

i try many times,but..😔

anyway, thank you.

x6262 commented 1 year ago

Have you solved the problem of compatibility between cornerstone3D and nifti files yet?