-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Layout changes and refactoring (#10)
* Update .gitignore * Grouped layout helpers * Delete gui_elements.py * Code refactoring * Moved segment.py for now * Revert to segment.py * Implement segmentation methods as separate classes * Add layout folder * Update segment.py * Enable button label alignment * Region label paint is ndim by default * Rename segmentation method folder and bugfixes * Take over Adam's fixes and further bugfixes * get rid of wildcard import * Update segment.py * Adding comments to trigger commit hooks * Update analysis.py * Reformatted code * Reset constants (defaults) Back to original values * Re-integrated loading function for atlas layers and brainreg Otherwise CI breaks. * bugfix constant naming * updated GUI tests. Left out add_surface_points() for now add_surface_points() seems to work when workflow is followed in GUI but fails in CI. Need to investigate a bit. * Make imio requirement * Bugfixes, test changes * Separate methods chooser panel from loader and add button styling
- Loading branch information
Showing
21 changed files
with
1,894 additions
and
1,449 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Constants used throughout | ||
WINDOW_HEIGHT = 750 | ||
WINDOW_WIDTH = 1500 | ||
COLUMN_WIDTH = 150 | ||
|
||
LOADING_PANEL_ALIGN = ( | ||
"left" # Alignment of text in pushbuttons in loading panel | ||
) | ||
SEGM_METHODS_PANEL_ALIGN = ( | ||
"left" # Alignment of text in pushbuttons in methods chooser panel | ||
) | ||
|
||
POINT_SIZE = 100 | ||
SPLINE_SIZE = 50 | ||
NUM_COLORS = 10 | ||
BRUSH_SIZE = 250 | ||
SPLINE_POINTS_DEFAULT = 1000 | ||
SPLINE_SMOOTHING_DEFAULT = 0.1 | ||
FIT_DEGREE_DEFAULT = 3 | ||
|
||
SUMMARISE_TRACK_DEFAULT = True | ||
ADD_SURFACE_POINT_DEFAULT = False | ||
CALCULATE_VOLUMES_DEFAULT = True | ||
SUMMARIZE_VOLUMES_DEFAULT = True | ||
|
||
TRACK_FILE_EXT = ".points" | ||
IMAGE_FILE_EXT = ".tiff" | ||
BOUNDARIES_STRING = "Boundaries" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
# GUI ELEMENTS | ||
# from napari.resources import build_icons # Contains .SVGPATH to all icons for napari | ||
|
||
from qtpy.QtWidgets import ( | ||
QDoubleSpinBox, | ||
QPushButton, | ||
QCheckBox, | ||
QLabel, | ||
QSpinBox, | ||
QComboBox, | ||
) | ||
|
||
|
||
def add_combobox( | ||
layout, | ||
label, | ||
items, | ||
row, | ||
column=0, | ||
label_stack=False, | ||
callback=None, | ||
width=150, | ||
): | ||
if label_stack: | ||
combobox_row = row + 1 | ||
combobox_column = column | ||
else: | ||
combobox_row = row | ||
combobox_column = column + 1 | ||
combobox = QComboBox() | ||
combobox.addItems(items) | ||
if callback: | ||
combobox.currentIndexChanged.connect(callback) | ||
combobox.setMaximumWidth = width | ||
|
||
if label is not None: | ||
combobox_label = QLabel(label) | ||
combobox_label.setMaximumWidth = width | ||
layout.addWidget(combobox_label, row, column) | ||
else: | ||
combobox_label = None | ||
|
||
layout.addWidget(combobox, combobox_row, combobox_column) | ||
return combobox, combobox_label | ||
|
||
|
||
def add_button( | ||
label, | ||
layout, | ||
connected_function, | ||
row, | ||
column, | ||
visibility=True, | ||
minimum_width=0, | ||
alignment="center", | ||
): | ||
button = QPushButton(label) | ||
if alignment == "center": | ||
pass | ||
elif alignment == "left": | ||
button.setStyleSheet("QPushButton { text-align: left; }") | ||
elif alignment == "right": | ||
button.setStyleSheet("QPushButton { text-align: right; }") | ||
|
||
button.setVisible(visibility) | ||
button.setMinimumWidth(minimum_width) | ||
layout.addWidget(button, row, column) | ||
button.clicked.connect(connected_function) | ||
return button | ||
|
||
|
||
# def add_radiobutton( | ||
# label, | ||
# layout, | ||
# connected_function, | ||
# row, | ||
# column, | ||
# visibility=True, | ||
# minimum_width=0, | ||
# alignment="center", | ||
# ): | ||
# button = QRadioButton(label) | ||
# if alignment == "center": | ||
# pass | ||
# elif alignment == "left": | ||
# button.setStyleSheet( | ||
# "QRadioButton { text-align: left; padding: 0; spacing: 30px;}" | ||
# ) | ||
# elif alignment == "right": | ||
# button.setStyleSheet( | ||
# "QRadioButton { text-align: right; padding: 0; spacing: 30px;}" | ||
# ) | ||
|
||
# # Too change indicator button ... needs to dynamically retrieve icon from Napari. | ||
# # Icons are saved as .svg files under napari.resources SVGPATH | ||
# # "QRadioButton::indicator" | ||
# # "{" | ||
# # "width:16px;" | ||
# # "height:16px;" | ||
# # "}" | ||
# # "QRadioButton::indicator::unchecked" | ||
# # "{" | ||
# # "image: url(build_icons.SVGPATH/visibility_off.svg);" | ||
# # "}" | ||
# # "QRadioButton::indicator::checked" | ||
# # "{" | ||
# # "image: url(/opt/miniconda3/envs/analysis/lib/python3.6/site-packages/napari/resources/icons/visibility.svg);" | ||
# # "}" | ||
# # ) | ||
|
||
# button.setVisible(visibility) | ||
# button.setMinimumWidth(minimum_width) | ||
# layout.addWidget(button, row, column) | ||
# button.clicked.connect(connected_function) | ||
# return button | ||
|
||
|
||
def add_checkbox(layout, default, label, row, column=0): | ||
box = QCheckBox() | ||
box.setChecked(default) | ||
layout.addWidget(QLabel(label), row, column) | ||
layout.addWidget(box, row, column + 1) | ||
return box | ||
|
||
|
||
def add_float_box( | ||
layout, default, minimum, maximum, label, step, row, column=0 | ||
): | ||
box = QDoubleSpinBox() | ||
box.setMinimum(minimum) | ||
box.setMaximum(maximum) | ||
box.setValue(default) | ||
box.setSingleStep(step) | ||
layout.addWidget(QLabel(label), row, column) | ||
layout.addWidget(box, row, column + 1) | ||
return box | ||
|
||
|
||
def add_int_box(layout, default, minimum, maximum, label, row, column=0): | ||
box = QSpinBox() | ||
box.setMinimum(minimum) | ||
box.setMaximum(maximum) | ||
# Not always set if not after min & max | ||
box.setValue(default) | ||
layout.addWidget(QLabel(label), row, column) | ||
layout.addWidget(box, row, column + 1) | ||
return box |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Small layout utils | ||
from napari.viewer import Viewer | ||
|
||
|
||
def disable_napari_btns(viewer): | ||
""" | ||
Disable some Napari functions to hide them from user interation | ||
- Transpose TODO: Understand how to add this properly with space conventions | ||
- Grid view | ||
- Console | ||
- New labels layer | ||
- New points layer | ||
- New shapes layer | ||
""" | ||
viewer.window.qt_viewer.viewerButtons.transposeDimsButton.setVisible(False) | ||
viewer.window.qt_viewer.viewerButtons.gridViewButton.setVisible(False) | ||
viewer.window.qt_viewer.viewerButtons.consoleButton.setVisible(False) | ||
viewer.window.qt_viewer.layerButtons.newLabelsButton.setVisible(False) | ||
viewer.window.qt_viewer.layerButtons.newPointsButton.setVisible(False) | ||
viewer.window.qt_viewer.layerButtons.newShapesButton.setVisible(False) | ||
|
||
|
||
def disable_napari_key_bindings(): | ||
""" | ||
Disable some default key bingings that are unused | ||
""" | ||
|
||
@Viewer.bind_key("Control-G", overwrite=True) | ||
def no_grid_mode_warning(self): | ||
print("Grid mode is not supported") | ||
|
||
@Viewer.bind_key("Control-T", overwrite=True) | ||
def no_tranpose_warning(self): | ||
print("Transposing is not supported") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.