Skip to content

Commit

Permalink
Moving from tabs to a dropdown style widget (#25)
Browse files Browse the repository at this point in the history
* Fixed contents margins

* Added brainglobe-utils as dependency

* Added min dependency version for brainglobe-utils
  • Loading branch information
IgorTatarnikov authored Jan 18, 2024
1 parent 0f32e54 commit fdec546
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 24 deletions.
2 changes: 1 addition & 1 deletion brainglobe_registration/napari.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ contributions:
sample_data:
- key: example
display_name: Sample Brain Slice
uri: src/brainglobe_registration/resources/sample_hipp.tif
uri: brainglobe_registration/resources/sample_hipp.tif
widgets:
- command: brainglobe-registration.make_registration_widget
display_name: BrainGlobe Registration
38 changes: 15 additions & 23 deletions brainglobe_registration/registration_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,11 @@
import numpy as np
from bg_atlasapi import BrainGlobeAtlas
from bg_atlasapi.list_atlases import get_downloaded_atlases
from brainglobe_utils.qtpy.collapsible_widget import CollapsibleWidgetContainer
from napari.viewer import Viewer
from qtpy.QtCore import Qt
from qtpy.QtWidgets import (
QGroupBox,
QPushButton,
QTabWidget,
QVBoxLayout,
QWidget,
)
from skimage.segmentation import find_boundaries

Expand All @@ -44,9 +41,10 @@
)


class RegistrationWidget(QWidget):
class RegistrationWidget(CollapsibleWidgetContainer):
def __init__(self, napari_viewer: Viewer):
super().__init__()
self.setContentsMargins(10, 10, 10, 10)

self._viewer = napari_viewer
self._atlas: BrainGlobeAtlas = None
Expand Down Expand Up @@ -84,16 +82,6 @@ def __init__(self, napari_viewer: Viewer):
else:
self._moving_image = None

self.setLayout(QVBoxLayout())
self.layout().addWidget(header_widget())

self.main_tabs = QTabWidget(parent=self)
self.main_tabs.setTabPosition(QTabWidget.West)

self.settings_tab = QGroupBox()
self.settings_tab.setLayout(QVBoxLayout())
self.parameters_tab = QTabWidget()

self.get_atlas_widget = SelectImagesView(
available_atlases=self._available_atlases,
sample_image_names=self._sample_images,
Expand Down Expand Up @@ -133,13 +121,17 @@ def __init__(self, napari_viewer: Viewer):
self.run_button.clicked.connect(self._on_run_button_click)
self.run_button.setEnabled(False)

self.settings_tab.layout().addWidget(self.get_atlas_widget)
self.settings_tab.layout().addWidget(self.adjust_moving_image_widget)
self.settings_tab.layout().addWidget(self.transform_select_view)
self.settings_tab.layout().addWidget(self.run_button)
self.settings_tab.layout().setAlignment(Qt.AlignTop)
self.add_widget(header_widget(), collapsible=False)
self.add_widget(self.get_atlas_widget, widget_title="Select Images")
self.add_widget(
self.adjust_moving_image_widget, widget_title="Adjust Sample Image"
)
self.add_widget(
self.transform_select_view, widget_title="Select Transformations"
)

self.parameter_setting_tabs_lists = []
self.parameters_tab = QTabWidget()

for transform_type in self.transform_params:
new_tab = RegistrationParameterListView(
Expand All @@ -150,10 +142,10 @@ def __init__(self, napari_viewer: Viewer):
self.parameters_tab.addTab(new_tab, transform_type)
self.parameter_setting_tabs_lists.append(new_tab)

self.main_tabs.addTab(self.settings_tab, "Settings")
self.main_tabs.addTab(self.parameters_tab, "Parameters")
self.add_widget(self.parameters_tab, widget_title="Advanced Settings")
self.add_widget(self.run_button, collapsible=False)

self.layout().addWidget(self.main_tabs)
self.layout().itemAt(1).widget().collapse(animate=False)

def _on_atlas_dropdown_index_changed(self, index):
# Hacky way of having an empty first dropdown
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ classifiers = [
dependencies = [
"napari>=0.4.18",
"bg-atlasapi",
"brainglobe-utils>=0.3.4",
"numpy",
"qtpy",
"itk-elastix",
Expand Down

0 comments on commit fdec546

Please sign in to comment.