Closed IgorTatarnikov closed 2 months ago
See here for example implementation (https://github.com/brainglobe/brainglobe-utils/blob/6044656fd76d1a8a1b2ba5419e3e0ceaf1ef2e13/brainglobe_utils/brainmapper/transform_widget.py#L61-L136)
The overall plan should be to listen for layer deletions (using the @self._viewer.layers.connect
decorator) and inside the function update the dropdowns in the SelectImagesView
, but also check if the moving image data layer, the atlas_reference or the atlas_annotations layer has been deleted.
Deleting the layer currently selected as the moving image should set self._moving_image and self._moving_image_data_backup to None.
When deleting either one of the atlas layers (Reference or Annotations), I think the expected behaviour should be to delete the other layer, and clear any class attributes related to the atlas, set self._atlas back to None, and set the index for the atlas selection combobox to 0.
Some of this code already exists in the _on_atlas_dropdown_index_changed
method inside of the index == 0
. Perhaps this can be generalised and extracted into it's own method, say clear_atlas
, which uses the find_layer_index
function to get the index of both the reference
and annotation
layers in the napari
layer list (check if any return -1 which is a stand in for layer not found), pop any layers that exist off of self._viewer.layers
and reset all atlas related class attributes to None
Closed by #49
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.