diff --git a/brainglobe_registration/registration_widget.py b/brainglobe_registration/registration_widget.py index 62b2437..edaffc9 100644 --- a/brainglobe_registration/registration_widget.py +++ b/brainglobe_registration/registration_widget.py @@ -24,10 +24,7 @@ from napari.utils.notifications import show_error from napari.viewer import Viewer from pytransform3d.rotations import active_matrix_from_angle -from qtpy.QtWidgets import ( - QPushButton, - QTabWidget, -) +from qtpy.QtWidgets import QPushButton, QTabWidget from skimage.segmentation import find_boundaries from skimage.transform import rescale @@ -35,6 +32,7 @@ from brainglobe_registration.utils.utils import ( adjust_napari_image_layer, calculate_rotated_bounding_box, + check_atlas_installed, find_layer_index, get_image_layer_names, open_parameter_file, @@ -182,6 +180,8 @@ def __init__(self, napari_viewer: Viewer): self.layout().itemAt(1).widget().collapse(animate=False) + check_atlas_installed(self) + def _on_atlas_dropdown_index_changed(self, index): # Hacky way of having an empty first dropdown if index == 0: diff --git a/brainglobe_registration/utils/utils.py b/brainglobe_registration/utils/utils.py index 2bb9891..e94faa7 100644 --- a/brainglobe_registration/utils/utils.py +++ b/brainglobe_registration/utils/utils.py @@ -4,7 +4,10 @@ import napari import numpy as np import numpy.typing as npt +from brainglobe_atlasapi.list_atlases import get_downloaded_atlases +from brainglobe_utils.qtpy.dialog import display_info from pytransform3d.rotations import active_matrix_from_angle +from qtpy.QtWidgets import QWidget def adjust_napari_image_layer( @@ -154,3 +157,21 @@ def calculate_rotated_bounding_box( int(np.round(max_corner[1] - min_corner[1])), int(np.round(max_corner[2] - min_corner[2])), ) + + +def check_atlas_installed(parent_widget: QWidget): + """ + Function checks if user has any atlases installed. If not, message box + appears in napari, directing user to download atlases via attached links. + """ + available_atlases = get_downloaded_atlases() + if len(available_atlases) == 0: + display_info( + widget=parent_widget, + title="Information", + message="No atlases available. Please download atlas(es) " + "using " + "brainglobe-atlasapi or brainrender-napari", + )