From ef870e3539ef2a430d99b2aa67c4c6c7aa8cd7ac Mon Sep 17 00:00:00 2001 From: saarah815 Date: Mon, 5 Aug 2024 16:37:16 +0100 Subject: [PATCH 01/18] added error when no atlas found --- .../registration_widget.py | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/brainglobe_registration/registration_widget.py b/brainglobe_registration/registration_widget.py index 82e47e8..ae3012c 100644 --- a/brainglobe_registration/registration_widget.py +++ b/brainglobe_registration/registration_widget.py @@ -21,13 +21,10 @@ from brainglobe_utils.qtpy.logo import header_widget from dask_image.ndinterp import affine_transform as dask_affine_transform from napari.qt.threading import thread_worker -from napari.utils.notifications import show_error +from napari.utils.notifications import show_error, show_info from napari.viewer import Viewer from pytransform3d.rotations import active_matrix_from_angle -from qtpy.QtWidgets import ( - QPushButton, - QTabWidget, -) +from qtpy.QtWidgets import QMessageBox, QPushButton, QTabWidget from skimage.segmentation import find_boundaries from skimage.transform import rescale @@ -180,6 +177,26 @@ def __init__(self, napari_viewer: Viewer): self.layout().itemAt(1).widget().collapse(animate=False) + if len(self._available_atlases) == 1: + show_info( + "No atlas installed. Please download atlas(es) from https://github.com/brainglobe/brainglobe-atlasapi" + ) + return + + def check_atlas_installed(self): + if len(self._available_atlases) == 1: + msg = QMessageBox() + msg.setIcon(QMessageBox.Information) + msg.setText( + "No atlas installed. Please download atlas(es) from https://github.com/brainglobe/brainglobe-atlasapi" + ) + msg.setWindowTitle("Information") + msg.setStandardButtons(QMessageBox.Ok) + msg.exec_() + return + + check_atlas_installed(self) + def _on_atlas_dropdown_index_changed(self, index): # Hacky way of having an empty first dropdown if index == 0: From 9e09b01cdc3c38d438ed28c7625934601aa3c50c Mon Sep 17 00:00:00 2001 From: saarah815 Date: Mon, 5 Aug 2024 16:59:17 +0100 Subject: [PATCH 02/18] added error when no atlas found --- brainglobe_registration/registration_widget.py | 1 - 1 file changed, 1 deletion(-) diff --git a/brainglobe_registration/registration_widget.py b/brainglobe_registration/registration_widget.py index ae3012c..f58b882 100644 --- a/brainglobe_registration/registration_widget.py +++ b/brainglobe_registration/registration_widget.py @@ -181,7 +181,6 @@ def __init__(self, napari_viewer: Viewer): show_info( "No atlas installed. Please download atlas(es) from https://github.com/brainglobe/brainglobe-atlasapi" ) - return def check_atlas_installed(self): if len(self._available_atlases) == 1: From d65ecf8ceae18845bd50a0e082b148ea9434dd5d Mon Sep 17 00:00:00 2001 From: saarah815 <63860766+saarah815@users.noreply.github.com> Date: Tue, 6 Aug 2024 11:35:32 +0100 Subject: [PATCH 03/18] Update brainglobe_registration/registration_widget.py Co-authored-by: Igor Tatarnikov <61896994+IgorTatarnikov@users.noreply.github.com> --- brainglobe_registration/registration_widget.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/brainglobe_registration/registration_widget.py b/brainglobe_registration/registration_widget.py index f58b882..250726d 100644 --- a/brainglobe_registration/registration_widget.py +++ b/brainglobe_registration/registration_widget.py @@ -186,8 +186,9 @@ def check_atlas_installed(self): if len(self._available_atlases) == 1: msg = QMessageBox() msg.setIcon(QMessageBox.Information) + msg.setTextFormat(Qt.RichText) msg.setText( - "No atlas installed. Please download atlas(es) from https://github.com/brainglobe/brainglobe-atlasapi" + "No atlases available. Please download atlas(es) using brainglobe-atlasapi or brainrender-napari" ) msg.setWindowTitle("Information") msg.setStandardButtons(QMessageBox.Ok) From 2b29d3a256796a95f059172628f80284fbcd4c16 Mon Sep 17 00:00:00 2001 From: saarah815 <63860766+saarah815@users.noreply.github.com> Date: Tue, 6 Aug 2024 11:36:27 +0100 Subject: [PATCH 04/18] Update brainglobe_registration/registration_widget.py Co-authored-by: Igor Tatarnikov <61896994+IgorTatarnikov@users.noreply.github.com> --- brainglobe_registration/registration_widget.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brainglobe_registration/registration_widget.py b/brainglobe_registration/registration_widget.py index 250726d..d6484db 100644 --- a/brainglobe_registration/registration_widget.py +++ b/brainglobe_registration/registration_widget.py @@ -179,7 +179,7 @@ def __init__(self, napari_viewer: Viewer): if len(self._available_atlases) == 1: show_info( - "No atlas installed. Please download atlas(es) from https://github.com/brainglobe/brainglobe-atlasapi" + "No atlases available. Please download atlas(es) with brainglobe-atlasapi (https://github.com/brainglobe/brainglobe-atlasapi) or brainrender-napari (https://brainglobe.info/tutorials/manage-atlases-in-GUI.html)" ) def check_atlas_installed(self): From c668924b17a772f01f4acad8565741d266d1451f Mon Sep 17 00:00:00 2001 From: saarah815 Date: Tue, 6 Aug 2024 14:42:35 +0100 Subject: [PATCH 05/18] changes to info message --- .../registration_widget.py | 25 +++---------------- brainglobe_registration/utils/utils.py | 24 ++++++++++++++++++ 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/brainglobe_registration/registration_widget.py b/brainglobe_registration/registration_widget.py index d6484db..47c0a51 100644 --- a/brainglobe_registration/registration_widget.py +++ b/brainglobe_registration/registration_widget.py @@ -21,10 +21,10 @@ from brainglobe_utils.qtpy.logo import header_widget from dask_image.ndinterp import affine_transform as dask_affine_transform from napari.qt.threading import thread_worker -from napari.utils.notifications import show_error, show_info +from napari.utils.notifications import show_error from napari.viewer import Viewer from pytransform3d.rotations import active_matrix_from_angle -from qtpy.QtWidgets import QMessageBox, QPushButton, QTabWidget +from qtpy.QtWidgets import QPushButton, QTabWidget from skimage.segmentation import find_boundaries from skimage.transform import rescale @@ -32,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, @@ -177,25 +178,7 @@ def __init__(self, napari_viewer: Viewer): self.layout().itemAt(1).widget().collapse(animate=False) - if len(self._available_atlases) == 1: - show_info( - "No atlases available. Please download atlas(es) with brainglobe-atlasapi (https://github.com/brainglobe/brainglobe-atlasapi) or brainrender-napari (https://brainglobe.info/tutorials/manage-atlases-in-GUI.html)" - ) - - def check_atlas_installed(self): - if len(self._available_atlases) == 1: - msg = QMessageBox() - msg.setIcon(QMessageBox.Information) - msg.setTextFormat(Qt.RichText) - msg.setText( - "No atlases available. Please download atlas(es) using brainglobe-atlasapi or brainrender-napari" - ) - msg.setWindowTitle("Information") - msg.setStandardButtons(QMessageBox.Ok) - msg.exec_() - return - - check_atlas_installed(self) + check_atlas_installed() def _on_atlas_dropdown_index_changed(self, index): # Hacky way of having an empty first dropdown diff --git a/brainglobe_registration/utils/utils.py b/brainglobe_registration/utils/utils.py index 2bb9891..88d1a03 100644 --- a/brainglobe_registration/utils/utils.py +++ b/brainglobe_registration/utils/utils.py @@ -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( @@ -154,3 +158,23 @@ 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(): + available_atlases = ["------"] + get_downloaded_atlases() + if len(available_atlases) == 1: + show_info( + "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)" + ) + display_info( + widget=QWidget(), + title="Information", + message="No atlases available. Please download atlas(es) " + "using brainglobe-atlasapi or brainrend" + "er-napari", + ) From b21b3823620f52bc3f06fb580cadb6b4f4567ca7 Mon Sep 17 00:00:00 2001 From: saarah815 <63860766+saarah815@users.noreply.github.com> Date: Tue, 6 Aug 2024 18:09:57 +0100 Subject: [PATCH 06/18] Update brainglobe_registration/utils/utils.py Co-authored-by: Igor Tatarnikov <61896994+IgorTatarnikov@users.noreply.github.com> --- brainglobe_registration/utils/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brainglobe_registration/utils/utils.py b/brainglobe_registration/utils/utils.py index 88d1a03..4aebab7 100644 --- a/brainglobe_registration/utils/utils.py +++ b/brainglobe_registration/utils/utils.py @@ -161,7 +161,7 @@ def calculate_rotated_bounding_box( def check_atlas_installed(): - available_atlases = ["------"] + get_downloaded_atlases() + available_atlases = get_downloaded_atlases() if len(available_atlases) == 1: show_info( "No atlases available. Please download atlas(es) with " From 4275ad9e291d33b19e873e3fc4c50726f06b4dd3 Mon Sep 17 00:00:00 2001 From: saarah815 <63860766+saarah815@users.noreply.github.com> Date: Tue, 6 Aug 2024 18:10:20 +0100 Subject: [PATCH 07/18] Update brainglobe_registration/utils/utils.py Co-authored-by: Igor Tatarnikov <61896994+IgorTatarnikov@users.noreply.github.com> --- brainglobe_registration/utils/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brainglobe_registration/utils/utils.py b/brainglobe_registration/utils/utils.py index 4aebab7..edf7f2b 100644 --- a/brainglobe_registration/utils/utils.py +++ b/brainglobe_registration/utils/utils.py @@ -162,7 +162,7 @@ def calculate_rotated_bounding_box( def check_atlas_installed(): available_atlases = get_downloaded_atlases() - if len(available_atlases) == 1: + if len(available_atlases) == 0: show_info( "No atlases available. Please download atlas(es) with " "brainglobe-atlasapi (https://github.com/brainglobe/brain" From 9d7b215dc78e1a207c1c58e609e74ed6ba602012 Mon Sep 17 00:00:00 2001 From: saarah815 <63860766+saarah815@users.noreply.github.com> Date: Tue, 6 Aug 2024 18:10:46 +0100 Subject: [PATCH 08/18] Update brainglobe_registration/utils/utils.py Co-authored-by: Igor Tatarnikov <61896994+IgorTatarnikov@users.noreply.github.com> --- brainglobe_registration/utils/utils.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/brainglobe_registration/utils/utils.py b/brainglobe_registration/utils/utils.py index edf7f2b..15f0860 100644 --- a/brainglobe_registration/utils/utils.py +++ b/brainglobe_registration/utils/utils.py @@ -163,12 +163,6 @@ def calculate_rotated_bounding_box( def check_atlas_installed(): available_atlases = get_downloaded_atlases() if len(available_atlases) == 0: - show_info( - "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)" - ) display_info( widget=QWidget(), title="Information", From ce5b7a4fe78167883c7a8ca8f2f3adad99bf87e2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 6 Aug 2024 17:10:55 +0000 Subject: [PATCH 09/18] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- brainglobe_registration/utils/utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/brainglobe_registration/utils/utils.py b/brainglobe_registration/utils/utils.py index 15f0860..597ee13 100644 --- a/brainglobe_registration/utils/utils.py +++ b/brainglobe_registration/utils/utils.py @@ -6,7 +6,6 @@ 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 From 6d3d30b146c9e755ef20e92611be8532c6a450af Mon Sep 17 00:00:00 2001 From: saarah815 <63860766+saarah815@users.noreply.github.com> Date: Tue, 6 Aug 2024 18:11:34 +0100 Subject: [PATCH 10/18] Update brainglobe_registration/utils/utils.py Co-authored-by: Igor Tatarnikov <61896994+IgorTatarnikov@users.noreply.github.com> --- brainglobe_registration/utils/utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/brainglobe_registration/utils/utils.py b/brainglobe_registration/utils/utils.py index 597ee13..23f8dfc 100644 --- a/brainglobe_registration/utils/utils.py +++ b/brainglobe_registration/utils/utils.py @@ -166,8 +166,8 @@ def check_atlas_installed(): widget=QWidget(), title="Information", message="No atlases available. Please download atlas(es) " - "using brainglobe-atlasapi or brainrend" - "er-napari", + "using " + "brainglobe-atlasapi or brainrender-napari", ) From a3344e1b1148c8c01bf02d5db98c14e3c0594d0e Mon Sep 17 00:00:00 2001 From: saarah815 <63860766+saarah815@users.noreply.github.com> Date: Tue, 6 Aug 2024 18:11:48 +0100 Subject: [PATCH 11/18] Update brainglobe_registration/utils/utils.py Co-authored-by: Igor Tatarnikov <61896994+IgorTatarnikov@users.noreply.github.com> --- brainglobe_registration/utils/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brainglobe_registration/utils/utils.py b/brainglobe_registration/utils/utils.py index 23f8dfc..45265ee 100644 --- a/brainglobe_registration/utils/utils.py +++ b/brainglobe_registration/utils/utils.py @@ -163,7 +163,7 @@ def check_atlas_installed(): available_atlases = get_downloaded_atlases() if len(available_atlases) == 0: display_info( - widget=QWidget(), + widget=parent_widget, title="Information", message="No atlases available. Please download atlas(es) " "using Date: Tue, 6 Aug 2024 20:45:44 +0100 Subject: [PATCH 18/18] parent_widget --- brainglobe_registration/utils/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brainglobe_registration/utils/utils.py b/brainglobe_registration/utils/utils.py index 222649d..e94faa7 100644 --- a/brainglobe_registration/utils/utils.py +++ b/brainglobe_registration/utils/utils.py @@ -167,7 +167,7 @@ def check_atlas_installed(parent_widget: QWidget): available_atlases = get_downloaded_atlases() if len(available_atlases) == 0: display_info( - widget=QWidget(), + widget=parent_widget, title="Information", message="No atlases available. Please download atlas(es) " "using