Skip to content

Commit

Permalink
added relabel to public API
Browse files Browse the repository at this point in the history
  • Loading branch information
haesleinhuepf committed May 28, 2022
1 parent ee6e089 commit 563e9d4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion napari_skimage_regionprops/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from ._table import add_table, get_table, TableWidget
from ._regionprops import regionprops, regionprops_table, regionprops_table_all_frames
from ._parametric_images import visualize_measurement_on_labels
from ._parametric_images import visualize_measurement_on_labels, relabel
from napari_plugin_engine import napari_hook_implementation
from ._load_csv import load_csv

Expand Down
11 changes: 8 additions & 3 deletions napari_skimage_regionprops/_parametric_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,22 @@ def visualize_measurement_on_labels(labels_layer:"napari.layers.Labels", column:
table = table[table['frame'] == current_timepoint]

measurements = np.asarray(table[column]).tolist()

relabel(labels, measurements)

def relabel(image, measurements):
import importlib
loader = importlib.find_loader("pyclesperanto_prototype")
found = loader is not None

if found:
import pyclesperanto_prototype as cle
return cle.pull(cle.replace_intensities(labels, numpy.asarray([0] + measurements)))
return relabel_cle(image, measurements)
else:
return relabel_numpy(labels, measurements)
return relabel_numpy(image, measurements)

def relabel_cle(image, measurements):
import pyclesperanto_prototype as cle
return cle.pull(cle.replace_intensities(image, numpy.asarray([0] + measurements)))

def relabel_numpy(image, measurements):
return numpy.take(numpy.array([0] + measurements), image)

0 comments on commit 563e9d4

Please sign in to comment.