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

BigDataViewer #52

Open
tischi opened this issue Feb 10, 2021 · 17 comments
Open

BigDataViewer #52

tischi opened this issue Feb 10, 2021 · 17 comments

Comments

@tischi
Copy link

tischi commented Feb 10, 2021

Amazing stuff @oeway!!

I was wondering about the limitations of this approach...
Concretely, is it conceivable to have BigDataViewer running in the web?
https://github.com/bigdataviewer/bigdataviewer-core

cc @joshmoore

@oeway
Copy link
Contributor

oeway commented Feb 10, 2021

Hi @tischi Thank you! In fact I am also very much interested in bring in BigDataViewer to ImageJ.JS. In general, since N5/Zarr are designed for scalability and to live with remote dataset, also as I understand, BigDataViewer don't need much resources to run for visualising the data.

For the feasibility, I don't see any obvious obstacle that prevent us from not making it work, we can compile the plugin and patch the transport layer, then it should just work. On that end, we have tried to compile ImageJ2, and still need some work on it to reduce the loading time. The best way forward is to try that with ImageJ2

For now, because we only support ImageJ-1 plugins for now, I am not sure whether it's possible to hack a custom BigDataViewer version that works with ImageJ-1. I saw the dependency list of BDV, and it's looks ok. Maybe @tpietzsch can explain a bit here?

Otherwise, maybe we can also think about running BDV independent of ImageJ2, say build a web version of BDV, take away the imagej-1, only keep the SciJava framework and necessary components. @ctrueden What do you think about this? We haven't discuss this but potentially we can also produce separate web apps for these "big" plugins.

With that said, I have very limited bandwidth to work on this right now, but this could be definitely something we can aim for, for example we are thinking about doing a "ImageJ in the browser" hackathon with @fjug and @ctrueden .

@tischi
Copy link
Author

tischi commented Feb 10, 2021

That sounds amazing!

In fact, your N5/Zarr comment is spot on.
For example, I have code that implements this: Plugins › BigDataViewer › OME ZARR › Open OME ZARR From S3... and there are equivalent implementations for reading N5 from S3 into BDV.

I think it would be very nice to re-use all that code in a browser. Thus, also your idea of a stand-alone www-BDV is very interesting, imho.

For example, there is this website: https://blog.openmicroscopy.org/file-formats/community/2020/11/04/zarr-data/
If you click on "View" for any of those data sets it already opens the data in a very nice viewer, e.g.: https://hms-dbmi.github.io/vizarr/?source=https://s3.embassy.ebi.ac.uk/idr/zarr/v0.1/9836835.zarr
However, I think, this viewer still needs a bit of development to do all the things that BDV can do; although @joshmoore could judge this much better.

Finding resources (and time) to do the implementation is certainly an issue, however maybe we could use this thread to figure out who would, in principle, think that a www-BDV is a useful aim and then see how to make it happen in terms of resources.

I also cc @axtimwalde as I am very curious about his opinion.

@axtimwalde
Copy link

BigDataViewer relies on multi-threading on the CPU for rendering in reasonable time. It also relies on reasonable size memory to cache remote data. Both, multithreading and memory are non-existent or severly limited in the browser, so I am expecting a mildly depressing user experience.

On the other hand, the browser has access to standardized GL via WebGL and a great reslicing viewer using WebGL already exists with Neuroglancer which already supports N5 sources. So, all things equal, I am not seeing what BDV in the webbrowser brings to the table (other than that it is cool to get it to work). May be I am too negative about these things, so sorry for lowering the temperature. I may be very wrong.

@tischi
Copy link
Author

tischi commented Feb 10, 2021

May be I am too negative about these things, so sorry for lowering the temperature. I may be very wrong.

No need to be sorry! It's good to evaluate properly whether it would be worth the effort! Personally, I have no clue about the limitations of things running in the browser, so your opinion is very valuable, to me at least!

@oeway
Copy link
Contributor

oeway commented Feb 10, 2021

@axtimwalde Good to have your thoughts here! This is definitely the time to evaluate this from both sides.

BigDataViewer relies on multi-threading on the CPU for rendering in reasonable time. It also relies on reasonable size memory to cache remote data. Both, multithreading and memory are non-existent or severly limited in the browser, so I am expecting a mildly depressing user experience.

Yes, in general I agree with you that the browser is rather limited in terms of compute resources, the 4 GB memory per tab limit for example is rather limiting. And indeed this would mean the loss of user experience.
However, in terms of the memory limitation applies also to Neuroglancer maybe we don't really need that much of memory for caching for many cases?
Regarding the multi-threading aspects, we can work around it with WebWorkers, and cheerpj supports that: https://github.com/leaningtech/cheerpj-meta/wiki/WebWorker-API . The other semi-future options is to use WebAssembly which has multi-threading support (also via webworkers), but we will need to switch to another WebAssemly-based java compiler.

On the other hand, the browser has access to standardized GL via WebGL and a great reslicing viewer using WebGL already exists with Neuroglancer which already supports N5 sources. So, all things equal, I am not seeing what BDV in the webbrowser brings to the table (other than that it is cool to get it to work). May be I am too negative about these things, so sorry for lowering the temperature. I may be very wrong.

That is true if we only aim for yet another viewer for zarr and N5. However, we can perhaps think about taking advantage of the plugins in the Fiji world. This is to say, the web BDV is not just a viewer, it can allow further customisation by combining BDV with other SciJava/ImageJ plugins. As mentioned, right now, the work we did in compiling ImageJ-2 suffers the issue of long loading time due its package size, however, if we only ship necessary components for BDV + additional plugin and serve as independent web apps. This might be still interesting for many applications, especially for plugins already or will be built on top of BDV.

Another potential direction to pursue (but not sure if possible) is taking out the rendering part of BDV, and delegate the rendering part to Neuroglancer or potentially ITK/VTK viewer, then we can use the API layer of BDV to bridge with other SciJava/ImageJ plugin.

In all cases, we won't do any heavy computation in the browser, but rather simple ones, e.g. custom the UI, facilitate the exploration, etc.

Finally, if we really want the performance, we can also think about running BDV purely on the server side, and bridge it with the viewers + ImageJ.JS with plugins in the browser. I was discussing this with @thewtex (and he recently supported zarr in the ITK/VTK viewer).

I am just throwing some thoughts here, wondering what others think about these.

@thewtex
Copy link

thewtex commented Feb 10, 2021

Refactoring is still underway in ITK/VTK viewer, but the idea is to eventually support server side rendering with BDV et. al..

@tischi
Copy link
Author

tischi commented Feb 11, 2021

the idea is to eventually support server side rendering with BDV et. al..

@thewtex @oeway I am sorry for not having a clue, but would it be possible to explain in a few sentences what "on the server side" means in this context (as compared to "in the browser")?

@oeway
Copy link
Contributor

oeway commented Feb 11, 2021

@thewtex @oeway I am sorry for not having a clue, but would it be possible to explain in a few sentences what "on the server side" means in this context (as compared to "in the browser")?

@tischi No worries, "on the server side" means we can run ImageJ/Fiji on a server (typically close to the data), then similar to ImageJ server, we can make a plugin to communicate with ImageJ.JS running in the browser via HTTP or websocket. Like that, the data will be rendered by BDV in the server, and the rendered view will be sent to the ITK/VTK viewer in the ImageJ.JS in the browser. When user do pan or zoom in ITK/VTK, the request will be sent to BDV to render. Is this clear?

@tischi
Copy link
Author

tischi commented Feb 11, 2021

When user do pan or zoom in ITK/VTK, the request will be sent to BDV to render. Is this clear?

Cristal clear! Thanks a lot! I guess scaling the server might be a bit of an issue, but I also guess living in the days of kybernetes that could probably be done automagically?!

@axtimwalde
Copy link

Hi again, is there any significant development that I missed that makes server side rendering a promising concept? I only remember past efforts that were depressingly non-interactive (e.g. http://www.emouseatlas.org/eAtlasViewer_ema/application/ema/wlz/EMA80.php published in https://bmcbioinformatics.biomedcentral.com/articles/10.1186/1471-2105-13-122). Putting aside the scalability issues with serving expensive customized output to many independent users (instead of unprocessed cacheble compressed data), there was always the limiting issue of how many interactive frames per second you can actually get across the wire. Tiled JPEGs certainly don't do it. The only acceptable solution that I know of is to live-encode video streams. With that, I find this to be pretty close to what NX, AnyDesk, or TeamViewer are doing to achieve reasonable remote desktop experience. So, if this works for remote desktop, why would I not use a remote desktop application to bind to my fat server and run stuff there? What is the benefit of a dedicated BDV rendering server (close to the data) over a dedicated all purpose server (close to the data)?

@thewtex
Copy link

thewtex commented Feb 11, 2021

@axtimwalde yes, scalability would still be an issue. Effective frame encoding is certainly part of the story of a workable solution. A remote desktop is a good solution if that is what is wanted and available. With ImageJ.js / ImJoy, it is also possible to integrate into custom web applications.

Cristal clear! Thanks a lot! I guess scaling the server might be a bit of an issue, but I also guess living in the days of kybernetes that could probably be done automagically?!

The cloud could still be more magical 🧙 🐰, but it is getting easier with services like Coiled. Is BDV scriptable from Python?

@axtimwalde
Copy link

If you start the JVM from Python, yes.

https://www.youtube.com/watch?v=Ddo5z5qGMb8

https://pypi.org/project/imglyb/

https://forum.image.sc/t/imglyb-bigdataviewer/28390/21

@oeway
Copy link
Contributor

oeway commented Mar 31, 2021

@axtimwalde Regarding the question about why we need a dedicated viewer rather than using a generic screen sharing tool or X11 forwarding, I think that is mainly because screen sharing are often laggy for simple tasks such as using markup tools to draw polygons. The issues is that every UI interaction will require a round-trip to the server.

If we instead make a dedicated viewer to interface with the remote viewer, we can be smart about what to be done directly in the browser and what to be scheduled remotely. I.e.: most interactions such as drawing ROI can be handled directly by the browser, the remote BDV instance can serve the current volume as a virtual multi-resolution pyramid in zarr format to the browser (such that we can use vizarr or ITK/VTK viewer to visualize it).

Since all the view change will be handled directly in the browser by requesting chunks (combined with local caching) just like vizarr did, the user experience should be rather good. When we need to perform transformations, alignment, non-orthogonal reslicing to the whole volume, we let BDV do it and the result will be served as virtual zarr arrays.

I did a rough comparison with napari + VNC screenshare and the Kaibu(ITK/VTK viewer) on the same binder machine: https://www.youtube.com/watch?v=0La0iCaDlME And you can see the experience is rather bad when using markup tools because of the latency. In addition, with a web implementation of viewers, we can easily adapt to different screen size while on mobile it's much harder to use screenshare tools.

What do you think about this?

@oeway
Copy link
Contributor

oeway commented May 18, 2021

@tischi We added basic NGFF/zarr support with #58 It's implemented as a virtual stack in ImageJ. We can load remote chunks in a lazy fashion. However, the current limitation is on the XY plane, i.e., if we have large tissue image for example, we will have to load the entire image as a whole due to the design of ImageJ virtual stack. I am wondering whether you have any suggestion on a minimal implementation with pure ImageJ-1 to allow browsing multi-resolution pyramid.

@tischi
Copy link
Author

tischi commented May 19, 2021

@oeway
Sorry, no ideas for chunked loading in XY for pure ImageJ.
I would be afraid if we write too much new code in "pure ImageJ" we may re-implement BDV..

@oeway
Copy link
Contributor

oeway commented May 19, 2021

@oeway
Sorry, no ideas for chunked loading in XY for pure ImageJ.
I would be afraid if we write too much new code in "pure ImageJ" we may re-implement BDV..

@tischi That's what I felt too, so we will need to move to ImageJ2 then, the pending issue for now is the significant size of the ImageJ2/SciJava stack, it makes it super long to load the app, unless we find a way to cut the depedencies.

I would like to try another approach as we discussed here, use ImageJ.JS or ITK/VTK viewer as the frontend, and connect to a remote Fiji + bigdataviewer. But there are a few technical details I need to figure out, would you have time in the coming days/weeks so we can discuss over a call? Maybe at the GatherTown?

@tischi
Copy link
Author

tischi commented May 19, 2021

Yes, let's organize something. Could you send me a mail not to clutter this issue?

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

4 participants