Show points based on featureΒΆ

show points based on feature
#!/usr/bin/env python3

import napari
import numpy as np
from magicgui import magicgui

# create points with a randomized "confidence" feature
points = np.random.rand(100, 3) * 100
colors = np.random.rand(100, 3)
confidence = np.random.rand(100)

viewer = napari.Viewer(ndisplay=3)
points = viewer.add_points(
        points, face_color=colors, features={'confidence': confidence}

# create a simple widget with magicgui which provides a slider that controls the visilibility
# of individual points based on their "confidence" value
    threshold={'widget_type': 'FloatSlider', 'min': 0, 'max': 1}
def confidence_slider(layer: napari.layers.Points, threshold=0.5):
    layer.shown = layer.features['confidence'] > threshold


if __name__ == '__main__':

Gallery generated by Sphinx-Gallery