Skip to content

Commit

Permalink
Info message when running BrainGlobe Registration plugin with no atla…
Browse files Browse the repository at this point in the history
…s installed (#46)

* added error when no atlas found

* added error when no atlas found

* Update brainglobe_registration/registration_widget.py

Co-authored-by: Igor Tatarnikov <61896994+IgorTatarnikov@users.noreply.github.com>

* Update brainglobe_registration/registration_widget.py

Co-authored-by: Igor Tatarnikov <61896994+IgorTatarnikov@users.noreply.github.com>

* changes to info message

* Update brainglobe_registration/utils/utils.py

Co-authored-by: Igor Tatarnikov <61896994+IgorTatarnikov@users.noreply.github.com>

* Update brainglobe_registration/utils/utils.py

Co-authored-by: Igor Tatarnikov <61896994+IgorTatarnikov@users.noreply.github.com>

* Update brainglobe_registration/utils/utils.py

Co-authored-by: Igor Tatarnikov <61896994+IgorTatarnikov@users.noreply.github.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update brainglobe_registration/utils/utils.py

Co-authored-by: Igor Tatarnikov <61896994+IgorTatarnikov@users.noreply.github.com>

* Update brainglobe_registration/utils/utils.py

Co-authored-by: Igor Tatarnikov <61896994+IgorTatarnikov@users.noreply.github.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update brainglobe_registration/utils/utils.py

Co-authored-by: Igor Tatarnikov <61896994+IgorTatarnikov@users.noreply.github.com>

* Update brainglobe_registration/utils/utils.py

Co-authored-by: Igor Tatarnikov <61896994+IgorTatarnikov@users.noreply.github.com>

* Update brainglobe_registration/registration_widget.py

Co-authored-by: Igor Tatarnikov <61896994+IgorTatarnikov@users.noreply.github.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* parent_widget

* parent_widget

---------

Co-authored-by: Igor Tatarnikov <61896994+IgorTatarnikov@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 7, 2024
1 parent 56a6f74 commit ce8bdc5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
8 changes: 4 additions & 4 deletions brainglobe_registration/registration_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,15 @@
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

from brainglobe_registration.elastix.register import run_registration
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,
Expand Down Expand Up @@ -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:
Expand Down
21 changes: 21 additions & 0 deletions brainglobe_registration/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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 <a href='https://brainglobe.info/documentation/"
"brainglobe-atlasapi/usage/command-line-interface.html'>"
"brainglobe-atlasapi</a> or <a href='https://brainglobe.info/"
"tutorials/manage-atlases-in-GUI.html'>brainrender-napari</a>",
)

0 comments on commit ce8bdc5

Please sign in to comment.