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 5 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()
saarah815 marked this conversation as resolved.
Show resolved Hide resolved

def _on_atlas_dropdown_index_changed(self, index):
# Hacky way of having an empty first dropdown
if index == 0:
Expand Down
24 changes: 24 additions & 0 deletions brainglobe_registration/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
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 napari.utils.notifications import show_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 +158,23 @@
int(np.round(max_corner[1] - min_corner[1])),
int(np.round(max_corner[2] - min_corner[2])),
)


def check_atlas_installed():
saarah815 marked this conversation as resolved.
Show resolved Hide resolved
available_atlases = ["------"] + get_downloaded_atlases()
saarah815 marked this conversation as resolved.
Show resolved Hide resolved
if len(available_atlases) == 1:
saarah815 marked this conversation as resolved.
Show resolved Hide resolved
show_info(

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

View check run for this annotation

Codecov / codecov/patch

brainglobe_registration/utils/utils.py#L166

Added line #L166 was not covered by tests
"No atlases available. Please download atlas(es) with "
"brainglobe-atlasapi (https://github.com/brainglobe/brain"
"globe-atlasapi) or brainrender-napari (https://brainglobe.info"
"/tutorials/manage-atlases-in-GUI.html)"
)
saarah815 marked this conversation as resolved.
Show resolved Hide resolved
display_info(

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

View check run for this annotation

Codecov / codecov/patch

brainglobe_registration/utils/utils.py#L172

Added line #L172 was not covered by tests
widget=QWidget(),
saarah815 marked this conversation as resolved.
Show resolved Hide resolved
title="Information",
message="No atlases available. Please download atlas(es) "
"using <a href='https://github.com/brainglobe/brainglobe-at"
"lasapi'>brainglobe-atlasapi</a> or <a href='https://brain"
"globe.info/tutorials/manage-atlases-in-GUI.html'>brainrend"
"er-napari</a>",
)
saarah815 marked this conversation as resolved.
Show resolved Hide resolved
Loading