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

Map active layer to current ij window #205

Closed
wants to merge 1 commit into from

Conversation

gselzer
Copy link
Collaborator

@gselzer gselzer commented Apr 27, 2023

When we are running in interactive mode, it would be nice to have better support for original ImageJ plugins when the ImageJ UI is not shown. To that end, if ImageJ is enabled but the ImageJ UI is not visible, we can set the active ImagePlus to the active napari layer, to mimic the GUI components needed.

The current improvements allow you to call an inplace PlugIn taking one input, and synchronize the output back into the active napari layer.

There are, at time of writing, some open questions/bugs, that make this a draft PR:

  1. The Gaussian Blur... command can cause napari-imagej to hang on shutdown. A stacktrace dump shows a non-daemon thread pool is still active, so it may be coming from here
  2. We need to figure out how to close all of the relevant Java-side images when we perform something like this. How do we ensure that all created ImageDisplays/ImagePluses created through this code path are deleted after we're done? Otherwise, the created images can affect the execution of other ImageJ functionality?
  3. How do we replicate this functionality for multiple input ImagePluses? @ctrueden mentioned something about proxies, but I'm naive about this.

This would close #203

@gselzer gselzer added the enhancement New feature or request label Apr 27, 2023
@gselzer gselzer added this to the 0.2.0 milestone Apr 27, 2023
@gselzer gselzer requested review from ctrueden and hinerm April 27, 2023 16:46
@gselzer gselzer self-assigned this Apr 27, 2023
@gselzer gselzer marked this pull request as draft April 27, 2023 16:46
@gselzer gselzer force-pushed the active-layer-to-active-ij-window branch from 65e885e to b3723a2 Compare April 27, 2023 16:51
@ctrueden
Copy link
Member

ctrueden commented Apr 27, 2023

@ctrueden mentioned something about proxies, but I'm naive about this.

Unfortunately, you can only make a Proxy of an interface, and ImagePlus is not an interface.

My current thinking is that, maybe, we could always wrap all napari image layers into Java (to Dataset and then via the legacy map to ImagePlus as well), whenever any Java-side functionality is invoked from the napari-imagej widget. However, these wrapped images should not be shown, but merely exist hidden, even while in interactive mode, until they are explicitly shown via some code path. (e.g. the user clicks the "transfer to ImageJ" button, or a script calls ui.show(dataset) or imp.show()). I am skeptical that this idea would actually work in practice—I have some concerns, e.g. "what about when the user runs a plugin via the ImageJ GUI? should that also proactively sync napari layers before execution? it could..."—but maybe it's worth a shot?

@gselzer gselzer force-pushed the active-layer-to-active-ij-window branch from b3723a2 to d5eabbe Compare May 1, 2023 14:12
@codecov-commenter
Copy link

Codecov Report

Patch coverage: 61.72% and project coverage change: -0.77 ⚠️

Comparison is base (6e48793) 89.81% compared to head (d5eabbe) 89.05%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #205      +/-   ##
==========================================
- Coverage   89.81%   89.05%   -0.77%     
==========================================
  Files          45       47       +2     
  Lines        4242     4421     +179     
==========================================
+ Hits         3810     3937     +127     
- Misses        432      484      +52     
Impacted Files Coverage Δ
src/napari_imagej/utilities/_module_utils.py 77.08% <58.20%> (-6.32%) ⬇️
src/napari_imagej/java.py 81.85% <78.57%> (-0.22%) ⬇️

... and 7 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@gselzer
Copy link
Collaborator Author

gselzer commented May 3, 2023

So, while this works great in limited scenarios, there are too many issues with original ImageJ plugins running in the napari UI that I'm doing to dismiss this effort, in favor of #207.

@gselzer gselzer closed this May 3, 2023
@gselzer gselzer deleted the active-layer-to-active-ij-window branch May 19, 2023 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

No Image Open error when running ImageJ commands
3 participants