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

fflate.decompressSync is not a function when using nifti-reader-js (React) #39

Closed
pcanas opened this issue Dec 7, 2023 · 4 comments
Closed

Comments

@pcanas
Copy link

pcanas commented Dec 7, 2023

How to reproduce

  1. Clone this repo: https://github.com/Chesneynl/nifti-loader-with-error
  2. yarn install
  3. yarn dev

package.json dependencies are

    "fflate": "^0.8.1",
    "nifti-reader-js": "^0.6.8",

The problem

We get an error because the fflate functions are not found

Captura de pantalla 2023-12-07 a las 19 23 13 Captura de pantalla 2023-12-07 a las 19 24 11

These are found when I am navigating my project, so it might have to do with the bundling...

@pcanas
Copy link
Author

pcanas commented Dec 18, 2023

Could I have an update on this item? Thanks!

@neurolabusc
Copy link
Collaborator

@pcanas you are installing the up stream cornerstonejs/nifti-volume-loader, so I would look at the issue with that package, with issue 55 looking relevant.

I notice that when your run

git clone https://github.com/Chesneynl/nifti-loader-with-error.git
cd nifti-loader-with-error 
yarn install

a yarn-error.log is created that notes Trace: Error: https://registry.yarnpkg.com/nifti-image-loader: Not found

@pcanas
Copy link
Author

pcanas commented Dec 19, 2023

Hi @neurolabusc
The issue you refer to is talking about cornerstone's nifti-image-loader not the volume one. I do not see the relation.

Also notice that the yarn-error.log is already part of the cloned repo (error on our side), if you would run

git clone https://github.com/Chesneynl/nifti-loader-with-error.git
cd nifti-loader-with-error 
rm yarn-error.log
yarn install

you would not see such error.

Could you provide any more updates on this? Thank you!

@neurolabusc
Copy link
Collaborator

@pcanas here is a minimal demo which uses yarn to install and run nifti-reader-js. The example reads a compressed NIfTI file (which uses fflate for new versions, and pako for older versions of nifti-reader-js:

git clone [email protected]:neurolabusc/NIFTI-Reader-Demo.git
cd NIFTI-Reader-Demo
yarn install
yarn start

I am not familiar with yarn or cornerstone. While cornerstone is legendary for DICOM-support, you may want to consider NiiVue if your interest in NIfTI images (as well as meshes, connectomes and tractography). You can see a lot of live demos here, it is also embedded into a lot of React frameworks, including those shown here as well as OpenNeuro.

A minimal HTML page would be:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>NiiVue</title>
  </head>
  <body>
    <canvas id="gl" width="640" height="640"></canvas>
  </body>
  <script type="module" async>
    import * as niivue from "https://niivue.github.io/niivue/dist/index.js";
    var volumeList = [
      { url: "https://niivue.github.io/niivue-demo-images/mni152.nii.gz" },
    ];
    var nv = new niivue.Niivue({ isResizeCanvas: false });
    nv.attachTo("gl");
    nv.loadVolumes(volumeList);
  </script>
</html>

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

No branches or pull requests

3 participants