diff --git a/napari_skimage_regionprops/__init__.py b/napari_skimage_regionprops/__init__.py index cf8eb5e..b9ef90e 100644 --- a/napari_skimage_regionprops/__init__.py +++ b/napari_skimage_regionprops/__init__.py @@ -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 diff --git a/napari_skimage_regionprops/_parametric_images.py b/napari_skimage_regionprops/_parametric_images.py index db15999..1e915fd 100644 --- a/napari_skimage_regionprops/_parametric_images.py +++ b/napari_skimage_regionprops/_parametric_images.py @@ -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)