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

Moving from tabs to a dropdown style widget #25

Merged
merged 3 commits into from
Jan 18, 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
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