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

Add checkbox for load scene in memory or delayed #29

Open
evamaxfield opened this issue Sep 18, 2021 · 7 comments
Open

Add checkbox for load scene in memory or delayed #29

evamaxfield opened this issue Sep 18, 2021 · 7 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@evamaxfield
Copy link
Collaborator

Use Case

Please provide a use case to help us understand your request in context

Instead of having two plugin variants that the napari user has to switch between they could simply determine how they want to load it during the napari process and on a per image and per scene basis!

Solution

Please describe your ideal solution

Similar to current checkboxes implemented in #25 and #27, we would simply need to add another checkbox to store state and check before image load.

Note: like #28 this should happen after the next release and if reception is positive to making the scene selector the primary method for loading images into napari.

Alternatives

Please describe any alternatives you've considered, even if you've dismissed them

@evamaxfield evamaxfield added enhancement New feature or request help wanted Extra attention is needed labels Sep 18, 2021
@lambda-science
Copy link

Hey I wonder if there is any news on this ?
I'm facing an issue, I have a 350mbits .ndpi image, and when loading it in RAM it takes like 10 Gigabits of RAM.
Is there any way to force loading the image as "chunks" ? I did not find this option. By default it's loading in RAM because the filesize is under 4gbits and less than 30% of the computer RAM, but that's because it's well compressed.

Thanks !

@psobolewskiPhD
Copy link
Collaborator

@lambda-science
Excellent point. You can sort of work around this, because the thresholds are set here:

# Threshold above which to use out-of-memory loading
IN_MEM_THRESHOLD_PERCENT = 0.3
IN_MEM_THRESHOLD_SIZE_BYTES = 4e9 # 4GB
###############################################################################

So you can use the following trick to change. In ipython or the napari console add:

import napari_aicsimageio.core
napari_aicsimageio.core.IN_MEM_THRESHOLD_SIZE_BYTES = 1e8 # should be 100 MB

I think it should work added to a script too, but I just tested ipython and napari console.

@evamaxfield
Copy link
Collaborator Author

Thanks @psobolewskiPhD! There haven't been any updates on my side. I did think about this though.

It may be possible to create yet another widget that ships with napari-aicsimageio. "aicsimageio-configuration" widget or something that just handles these state management things. That widget can be loaded as a new pane in napari prior to loading a file, you can change all the settings you want there and then when you actually load a file, the "primary" widget checks the config (sort of like how we do with the scene management widget -- since we know the widget's namespace exactly -- we pull data from the widget with that namespace).

If that didn't make any sense at all, please ignore me. If someone looks at this issue and comment and it made sense to them, feel free to give it a try. Would be happy to accept a PR.

@psobolewskiPhD
Copy link
Collaborator

@evamaxfield totally makes sense to me.

I think it would be more elegant for napari preferences to include something for plugins to use for these things, but for now a widget can work.
I totally get your concept. A widget in the plugin menu call aicsimageio-configuration or something with some basic settings.
Could be used to address:
#3

I think the key is the settings would need to be set and then work with the widget closed when the reader actually fires. With the scene widget it's the reader that's calling the scene widget... So here we'd need global variables? or use the trick from above?
This would be the start, the bare minimum.

Also this would probably go in a new .py, not in core.py right?

Then, having the settings persist between sessions, which could be nice, could be done using https://napari.org/magicgui/api/magicgui.html persist as mentioned in the other issue by @tlambert03

@evamaxfield
Copy link
Collaborator Author

Yea storing info in a single global would be better imo. Just one big container for all of these config options so we only need to namespace one item instead of however many config selections we want to add. I think either would work. The globals or the "namespaced widget data sharing" trick.

To be honest, I have no idea where this code would live in this lib. Probably outside or core.py but if that is the easiest place to put it then fine by me too. "Whatever works"

Yea the persist between sessions would be the best too.

@psobolewskiPhD
Copy link
Collaborator

OK, we've got a holiday coming up so I'll try and make some proof-of-concept.
Hopefully I can figure out how to add a widget, get it into the contributions, etc. 🤣

@evamaxfield
Copy link
Collaborator Author

Cool! Excited to see whatever comes out of it! (Also have a nice holiday!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants