Skip to content

Commit

Permalink
Merge 9ecd712 into 2174c87
Browse files Browse the repository at this point in the history
  • Loading branch information
horsto committed Sep 1, 2020
2 parents 2174c87 + 9ecd712 commit b17f7a0
Show file tree
Hide file tree
Showing 14 changed files with 624 additions and 321 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ target/
# pyenv
.python-version

# vscode
.vscode

# celery beat schedule file
celerybeat-schedule

Expand Down
Empty file.
22 changes: 22 additions & 0 deletions brainreg_segment/layout/gui_constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Constants used throughout
WINDOW_HEIGHT = 750
WINDOW_WIDTH = 1500
COLUMN_WIDTH = 150


POINT_SIZE = 5
SPLINE_SIZE = 4
NUM_COLORS = 10
BRUSH_SIZE = 10
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"
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# GUI ELEMENTS
from qtpy.QtWidgets import (
QDoubleSpinBox,
QPushButton,
Expand All @@ -9,7 +10,14 @@


def add_combobox(
layout, label, items, row, column=0, label_stack=False, callback=None
layout,
label,
items,
row,
column=0,
label_stack=False,
callback=None,
width=150,
):
if label_stack:
combobox_row = row + 1
Expand All @@ -21,8 +29,15 @@ def add_combobox(
combobox.addItems(items)
if callback:
combobox.currentIndexChanged.connect(callback)
combobox_label = QLabel(label)
layout.addWidget(combobox_label, row, column)
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

Expand All @@ -35,8 +50,16 @@ def add_button(
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)
Expand Down
35 changes: 35 additions & 0 deletions brainreg_segment/layout/utils.py
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")
4 changes: 2 additions & 2 deletions brainreg_segment/regions/IO.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import tifffile
import imio
import numpy as np

from pathlib import Path
Expand Down Expand Up @@ -120,7 +120,7 @@ def save_regions_to_file(
name = label_layer.name

filename = destination_directory / (name + image_extension)
tifffile.imsave(filename, data.astype(np.int16))
imio.to_tiff(data.astype(np.int16), filename)


def export_regions_to_file(image, filename, voxel_size, ignore_empty=True):
Expand Down
1 change: 1 addition & 0 deletions brainreg_segment/regions/analysis.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy as np
import pandas as pd


from napari.qt.threading import thread_worker
from skimage.measure import regionprops_table

Expand Down
2 changes: 1 addition & 1 deletion brainreg_segment/regions/layers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import tifffile

import numpy as np

from glob import glob
Expand Down Expand Up @@ -28,6 +27,7 @@ def add_new_label_layer(
"""
labels = np.empty_like(base_image)
label_layer = viewer.add_labels(labels, num_colors=num_colors, name=name)
label_layer.n_dimensional = True
label_layer.selected_label = selected_label
label_layer.brush_size = brush_size
return label_layer
Expand Down

0 comments on commit b17f7a0

Please sign in to comment.