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

Info message when running BrainGlobe Registration plugin with no atlas installed #46

Merged
merged 19 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -180,6 +178,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
saarah815 marked this conversation as resolved.
Show resolved Hide resolved
from qtpy.QtWidgets import QWidget


def adjust_napari_image_layer(
Expand Down Expand Up @@ -154,3 +157,21 @@
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(

Check warning on line 169 in brainglobe_registration/utils/utils.py

View check run for this annotation

Codecov / codecov/patch

brainglobe_registration/utils/utils.py#L169

Added line #L169 was not covered by tests
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>",
)
Loading