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

Separate napari image parameter to prevent magicgui slowdown #401

Merged
merged 3 commits into from
Apr 16, 2024

Conversation

matham
Copy link
Contributor

@matham matham commented Apr 14, 2024

Description

What is this PR

  • Bug fix
  • Addition of a new feature
  • Other

Why is this PR needed?

The problem is that when large images are open in napari, every time I try to edit a parameter (and I imagine - when the progress bar is updated), the gui freezes for a bit. After some testing I realized that every time any parameter updates, magicgui is processing something for all the parameters in the root widget. But, this processing takes particularly long for image parameters, especially for large images (maybe magicgui gets some image data?).

You can see this effect in the video where I change the num threads without and with images being open.

main branch with no images open:

main_no_image.mp4

main branch with an image open. You can see the lag:

main_with_image.mp4

What does this PR do?

This PR breaks out the signal and background inputs to their own magicgui containers. This somehow prevents this processing, because they are in their own container within the root parameter container, rather than directly in the root container. No idea why as I'm not familiar with qt/magicgui.

You can see the fix with this branch:

branch_with_image.mp4

References

None.

How has this PR been tested?

Tested by running the gui and the pipeline.

Is this a breaking change?

No

Does this PR require an update to the documentation?

No.

Checklist:

  • The code has been tested locally
  • Tests have been added to cover all new functionality (unit & integration)
  • The documentation has been updated to reflect any changes
  • The code has been formatted with pre-commit

@adamltyson adamltyson requested a review from a team April 15, 2024 08:21
Copy link
Member

@IgorTatarnikov IgorTatarnikov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to replicate the slowdown on Windows after loading a ~2.3 GB 3D tiff into memory. The fix from this PR makes everything smooth.

Just a few nitpicky comments!

cellfinder/napari/detect/detect.py Outdated Show resolved Hide resolved
cellfinder/napari/detect/detect.py Outdated Show resolved Hide resolved
cellfinder/napari/detect/detect.py Outdated Show resolved Hide resolved
cellfinder/napari/detect/detect.py Outdated Show resolved Hide resolved
Co-authored-by: Igor Tatarnikov <61896994+IgorTatarnikov@users.noreply.github.com>
Copy link
Member

@IgorTatarnikov IgorTatarnikov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing the comments! Looks good to me I'll get this merged.

@IgorTatarnikov IgorTatarnikov merged commit 389e455 into brainglobe:main Apr 16, 2024
14 checks passed
@matham matham deleted the napari branch April 16, 2024 19:19
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 this pull request may close these issues.

None yet

2 participants