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

loading/parsing of NRRD files very slow #401

Open
haehn opened this issue Dec 12, 2019 · 1 comment
Open

loading/parsing of NRRD files very slow #401

haehn opened this issue Dec 12, 2019 · 1 comment

Comments

@haehn
Copy link
Member

haehn commented Dec 12, 2019

Hi @NicolasRannou and @rudolphpienaar

It's final project time in my CS460.org Graphics course :) One student wants to implement volume rendering for OpenAnatomy.org. Now, we uses the brain atlas T1 nrrd file from there and the volume rendering example in AMI. The initial loading/parsing of the NRRD file takes super long and even stalls the browser (latest firefox) with a warning. If we drag the same NRRD file into slicedrop, loading is instant. Do you know why?

Thank you!

@NicolasRannou
Copy link
Member

Hi @haehn, sorry, I'm not much online those days!

Yes, there should be almost no difference with Slicedrop!

Do you know which kind of data (binary, uint, etc) and the approximate dimensions of the volume you are trying to load?

The way it currently works in AMI (as far as I can remember):
1- Load the data from the server
2- Parse data (https://github.com/FNNDSC/ami/blob/master/src/parsers/parsers.nrrd.js)
3- Store parsed data in typed array(s) - 1 per frame as far as I can remember (https://github.com/FNNDSC/ami/blob/master/src/parsers/parsers.nrrd.js)
4- Pack the typed arrays into 2d textures that are passed to the shaders

I'm not too sure how much time and how experienced the students are but I would:
1 (most important)- Profile the code to see where is the bottleneck (I'm assuming 3 and 4 are)
2- Consider using web-workers somehow
3- Consider WebGL2 Sampler2DArray (or 3d textures but it seems Sampler2DArray lets you upload single frames without re-uploading the whole stack to the shaders - not tested -)
4- Use the data loader from AMI (assuming bottleneck is not there) then write a custom ThreeJS "Shader Material" that doesn't require the image data to be packed!
5- Use XTK for non-webgl2 devices and implement a fast WebGL2 version (possibly leveraging the XTK NRRD parsers?)

Right now, AMI is very big and takes a lot of time to maintain so I'm considering splitting it into smaller "plugins for threejs", maybe under a mono-repo. One of the plugins could be "NRRD Loader", another "VolumeRendering2 Material", then the user does the "plumbing" to create the "NRRD Volume Rendering application".

I still use AMI every day but I seem to keep re-using and avoiding some components to allow me to get where we want it to be!

Let's chat soon it has been too long!

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

2 participants