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

Register/Fuse buttons grayed out if one layer is not Image #5

Closed
jo-mueller opened this issue Aug 6, 2024 · 2 comments · Fixed by #7
Closed

Register/Fuse buttons grayed out if one layer is not Image #5

jo-mueller opened this issue Aug 6, 2024 · 2 comments · Fixed by #7

Comments

@jo-mueller
Copy link
Contributor

Hi napari-stitcher devs,

first off: great plugin! We played around with it a bit today on some data to be stitched and found it really easy to use. One thing that seemed a bit odd to us: When selecting some layers and clicking on the Selection button in the merger widget, the Fuse/Register buttons remain grayed out if one of the selected layers is not of type Image (which obviously makes sense, because how would you merge, say, a points layer) - it's just that with many layers, it can be a bit hard to find which layer is the problematic one.

Maybe an easy solution for this would be to build a check into the function that adds the layers to the list and only adds them if the layer is of type Image. Here would probably be a good place.

cc @tsmejkal @zoccoler @maleehahassan

@m-albert
Copy link
Collaborator

m-albert commented Aug 6, 2024

Hey @jo-mueller, happy to hear you're liking the plugin and thanks a lot for the feedback!

Maybe an easy solution for this would be to build a check into the function that adds the layers to the list and only adds them if the layer is of type Image.

I think it's a good idea to keep only labels in the selection that are available for fusion. In addition to image layers I'd also include label layers into this as 1) this currently works as labels are simply treated as images and 2) multiview-stitcher will add support for meaningfully fusing labels in the future. Would your use case include labels layers that should be filtered out?

Other than that there'd also be the option to load layers programmatically as

import napari_stitcher
stitching_widget = napari_stitcher.StitcherQWidget(viewer)
viewer.window.add_dock_widget(stitching_widget)
stitching_widget.load_layers([l for l in viewer.layers if type(l) == napari.layers.image.image.Image])

Here would probably be a good place.

Yep agreed. Would you be willing to contribute a PR for this? Happy to otherwise do it on my side of course.

@jo-mueller
Copy link
Contributor Author

jo-mueller commented Aug 7, 2024

I could try myself at it :)

One thing that occurred to me from looking at the code: It seems like the list of layers is iterated through in multiple places, i.e. here, here and several other places. Filtering the list of layers at every place where this iteration is done would end up a bit clunky, I think.

Alternative solution: I could add a property self.layers to the widget, which would essentially be a view on the fitlered list of compatible layers. It would look something like this:

@property
def layers(self):
  return [layer for layer in self.viewer.layers if isinstance(layer, (Image, Labels)]

Edit: Just realized that I only need to change it in the loading functions ^^"

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

Successfully merging a pull request may close this issue.

2 participants