Skip to content

Commit c2a0586

Browse files
committed
add examples
1 parent 5891f7f commit c2a0586

6 files changed

+63
-0
lines changed

examples/features_line_widget.gif

270 KB
Loading
294 KB
Loading

examples/line_features.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import napari
2+
import matplotlib.pyplot as plt
3+
import numpy as np
4+
import pandas as pd
5+
from napari_matplotlib.line import FeaturesLineWidget
6+
7+
labels = np.array([[0, 0, 1, 0],
8+
[0, 2, 1, 0],
9+
[2, 2, 2, 0],
10+
[3, 3, 2, 0],
11+
[0, 3, 0, 0]])
12+
table = pd.DataFrame(data=np.array([np.array([1, 2, 3]), np.array([2, 5, 3]), np.array([0, 1, 0.5])]).T,
13+
columns=['label', 'measurement1', 'measurement2'])
14+
15+
viewer = napari.Viewer()
16+
viewer.add_labels(labels, features=table, name='labels')
17+
18+
plotter_widget = FeaturesLineWidget(viewer)
19+
viewer.window.add_dock_widget(plotter_widget)
20+
21+
napari.run()

examples/line_features_over_time.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import napari
2+
import numpy as np
3+
import pandas as pd
4+
from napari_matplotlib.line import FeaturesLineWidget
5+
6+
labels = np.array([[0, 0, 1, 0],
7+
[0, 2, 1, 0],
8+
[2, 2, 2, 0],
9+
[3, 3, 2, 0],
10+
[0, 3, 0, 0]])
11+
12+
table = pd.DataFrame(data=np.array([
13+
np.array([1, 2, 3, 1, 2, 3, 1, 2, 3]),
14+
np.array([2, 5, 3, 3, 6, 4, 4, 7, 3]),
15+
np.array([1, 1, 1, 2, 2, 2, 3, 3, 3]),]).T,
16+
columns=['label',
17+
'mean_intensity',
18+
'frame'])
19+
20+
viewer = napari.Viewer()
21+
viewer.add_labels(labels, features=table, name='labels')
22+
23+
plotter_widget = FeaturesLineWidget(viewer)
24+
viewer.window.add_dock_widget(plotter_widget)
25+
26+
napari.run()

examples/line_profile.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import napari
2+
import numpy as np
3+
from napari_matplotlib.line import LineWidget
4+
5+
viewer = napari.Viewer()
6+
image = np.random.random((10, 10))
7+
image2 = np.arange(100).reshape((10, 10))
8+
9+
line = np.array([[1, 1], [7, 4]])
10+
viewer.add_image(image, colormap='green')
11+
viewer.add_image(image2, colormap='magenta', blending='additive')
12+
shapes_layer = viewer.add_shapes([line], shape_type='line', edge_width=1, edge_color='coral')
13+
14+
viewer.window.add_dock_widget(LineWidget(viewer), area='right')
15+
16+
napari.run()

examples/line_widget.gif

620 KB
Loading

0 commit comments

Comments
 (0)