brainglobe / brainglobe-registration

Registration to BrainGlobe atlases in napari using Elastix
BSD 3-Clause "New" or "Revised" License
13 stars 2 forks source link

Communicate napari layer deletions appropriately to the plugin #49

Closed saarah815 closed 2 months ago

saarah815 commented 2 months ago

Before submitting a pull request (PR), please read the contributing guide.

Please fill out as much of this template as you can, but if you have any problems or questions, just leave a comment and we will help out :)

Description

What is this PR

Why is this PR needed?

"Currently, if a user deletes the atlas or moving image layer the plugin goes into undefined behaviour and will probably throw index out of bounds errors.

Need to make sure that layer deletions are communicated appropriately and the plugin can handle restarting the entire workflow without having to restart the plugin."

[#44]

What does this PR do?

Bug Fixes:

Additional Features:

image

image

References

Issue #44 Issue #53

How has this PR been tested?

Essentially user is able to delete layers as required and restart entire workflow without restarting plugin.

Is this a breaking change?

No.

Does this PR require an update to the documentation?

N/A

Checklist:

saarah815 commented 2 months ago

This is great, thanks! I've added a few comments throughout the code.

Also, I get an error if I remove the last layer using the napari layer manager. That's being caused by _on_sample_dropdown_index_changed firing due to _update_dropdowns causing the moving_image_index_change signal to fire. This can be fixed by adding a check for an invalid layer index (-1) before running line 311-312.

I wonder if we can take advantage of this interaction with signals and reduce some code duplication.

Perhaps, _delete_atlas_layers can be called inside of the _on_atlas_dropdown_index_changed method. And the _handle_layer_deletion method just calls the reset_atlas_combobox method.

So a layer is deleted, if the layer is the atlas or annotation layer then the reset_atlas_combobox method is called. This causes the _on_atlas_dropdown_changed signal to fire with 0 calling _on_atlas_dropdown_index_changed, and there inside of the if index == 0: block we call _delete_atlas_layers.

Sounds good, will do - thank you!

saarah815 commented 2 months ago

Pushed all new changes. Just wanted to mention a few things:

Other than those two points, all other changes have been made :)

codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 88.23529% with 6 lines in your changes missing coverage. Please review.

Project coverage is 82.93%. Comparing base (f690dea) to head (c4e0cd5).

Files Patch % Lines
brainglobe_registration/registration_widget.py 86.95% 6 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## dev #49 +/- ## ========================================== + Coverage 80.96% 82.93% +1.96% ========================================== Files 8 8 Lines 541 580 +39 ========================================== + Hits 438 481 +43 + Misses 103 99 -4 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.