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

Sync changes from ImageWindow back to Python more robustly #283

Open
ctrueden opened this issue Jul 26, 2023 · 0 comments
Open

Sync changes from ImageWindow back to Python more robustly #283

ctrueden opened this issue Jul 26, 2023 · 0 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@ctrueden
Copy link
Member

  • Open a single-plane image (e.g. Brick) in napari.
  • Send it to ImageJ.
  • Draw on the ImageJ window with the paintbrush tool.
  • Return to napari and toggle the image layer to invisible then back to visible using the eyeball.
  • Witness the lack of updates.

We know why this happens: it's due to how ImgLib2 images are synced with ImagePlus objects by the imglib2-ij library. It's hard to deal with because the ImagePlus active plane works only by on-heap primitive arrays. The imglib2-ij library works around this by syncing back to the ImgLib2 image whenever the active image plane is changed on the ImagePlus. This is nice, but when you have a 2D image like the example here, it falls down because there is no way to change the active plane. Furthermore, even with >2D images, users will be confused because they will not see the changes happen when jumping back and forth—there is no way for them to know that moving the slider will refresh things. Heck, I didn't remember this during my recent demo, so what are the chances of most users figuring this out? We'll get bug reports.

So, how can we mitigate this issue? I don't have an iron clad answer, but here are some ideas:

  • Add a refresh button to the napari-imagej toolbar. I think this would be nice and people might stumble on it intuitively, but it is kind of off to the side of the image layer, so it's a bit weird.
  • Add a listener to ImageWindows that perform a sync whenever the ImageWindow loses focus. This is kind of evil maybe, but it would be effective. And could consider adding this to imglib2-ij rather than only to napari-imagej.
  • Even more aggressive, we could add some syncing thread that marks the ImagePlus as dirty every time updateAndDraw() is called on it, but only keeps syncing while the image is currently dirty, to avoid accumulating a flood of resyncs. This is the most disruptive option though, as it might result in needless resyncing in some circumstances and impact performance.
  • Other ideas?
@gselzer gselzer self-assigned this Jul 26, 2023
@gselzer gselzer added the bug Something isn't working label Jul 26, 2023
@gselzer gselzer added this to the 0.3.0 milestone Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants