Skip to content

Commit

Permalink
draw parametric images on column double-click
Browse files Browse the repository at this point in the history
  • Loading branch information
haesleinhuepf committed Apr 23, 2022
1 parent cbadd9c commit cc9fc3c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ activate the `show selected` checkbox.
If you closed a table and want to reopen it, you can use the menu `Tools > Measurements > Show table (nsr)` to reopen it.
You just need to select the labels layer the properties are associated with.

For visualizing measurements with different grey values, as parametric images, you can use the menu `Tools > Visualization > Measurements on labels (nsr)`.
After performing measurements, use this dialog to select the layer where measurements were performed on and layer properties were stored.
Also enter which column should be visualized.
For visualizing measurements with different grey values, as parametric images, you can double-click table headers.

![img.png](https://github.com/haesleinhuepf/napari-skimage-regionprops/raw/master/images/parametric_images.png)
![img.png](https://github.com/haesleinhuepf/napari-skimage-regionprops/raw/master/images/label_value_visualization.gif)


## Usage, programmatically
Expand Down
Binary file added images/label_value_visualization.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions napari_skimage_regionprops/_table.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import time

import napari
from pandas import DataFrame
from qtpy.QtCore import QTimer
Expand All @@ -21,9 +23,11 @@ def __init__(self, layer: napari.layers.Layer, viewer:napari.Viewer = None):
self._viewer = viewer

self._view = QTableWidget()
self._view.setEditTriggers(QTableWidget.EditTrigger.NoEditTriggers)
self.set_content(layer.properties)

self._view.clicked.connect(self._clicked_table)
self._view.horizontalHeader().sectionDoubleClicked.connect(self._double_clicked_table)
layer.mouse_drag_callbacks.append(self._clicked_labels)

copy_button = QPushButton("Copy to clipboard")
Expand Down Expand Up @@ -58,6 +62,17 @@ def _clicked_table(self):
current_step[-4] = frame
self._viewer.dims.current_step = current_step

def _double_clicked_table(self):
if "label" in self._table.keys():
selected_column = list(self._table.keys())[self._view.currentColumn()]
print("Selected column", selected_column)
if selected_column is not None:
from ._parametric_images import visualize_measurement_on_labels
new_layer = self._viewer.add_image(visualize_measurement_on_labels(self._layer, selected_column),
name=selected_column + " in " + self._layer.name)
new_layer.contrast_limits = [np.min(self._table[selected_column]), np.max(self._table[selected_column])]
new_layer.colormap = "jet"

def _after_labels_clicked(self):
if "label" in self._table.keys() and hasattr(self._layer, "selected_label"):
row = self._view.currentRow()
Expand Down

0 comments on commit cc9fc3c

Please sign in to comment.