-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3a3d212
commit 610d1d9
Showing
1,333 changed files
with
609,136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Sphinx build info version 1 | ||
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. | ||
config: 8e851b6de6e482421765994aeda5d8bb | ||
tags: 645f666f9bcd5a90fca523b33c5a78b7 |
28 changes: 28 additions & 0 deletions
28
dev/html/_downloads/0151608a12a917be578012c602f3d75b/nD_multiscale_image.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
""" | ||
nD multiscale image | ||
=================== | ||
Displays an nD multiscale image | ||
.. tags:: visualization-advanced | ||
""" | ||
|
||
import numpy as np | ||
from skimage.transform import pyramid_gaussian | ||
|
||
import napari | ||
|
||
# create multiscale from random data | ||
base = np.random.random((1536, 1536)) | ||
base = np.array([base * (8 - i) / 8 for i in range(8)]) | ||
print('base shape', base.shape) | ||
multiscale = list( | ||
pyramid_gaussian(base, downscale=2, max_layer=2, channel_axis=-1) | ||
) | ||
print('multiscale level shapes: ', [p.shape for p in multiscale]) | ||
|
||
# add image multiscale | ||
viewer = napari.view_image(multiscale, contrast_limits=[0, 1], multiscale=True) | ||
|
||
if __name__ == '__main__': | ||
napari.run() |
54 changes: 54 additions & 0 deletions
54
dev/html/_downloads/02abd904ab6dfedb781bffb4eb5c091d/mouse_drag_callback.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
""" | ||
Mouse drag callback | ||
=================== | ||
Example updating the status bar with line profile info while dragging | ||
lines around in a shapes layer. | ||
.. tags:: gui | ||
""" | ||
|
||
import numpy as np | ||
from skimage import data, measure | ||
|
||
import napari | ||
|
||
|
||
def profile_lines(image, shape_layer): | ||
profile_data = [ | ||
measure.profile_line(image, line[0], line[1], mode='reflect').mean() | ||
for line in shape_layer.data | ||
] | ||
print(f"profile means: [{', '.join(f'{d:.2f}' for d in profile_data)}]") | ||
|
||
|
||
np.random.seed(1) | ||
viewer = napari.Viewer() | ||
blobs = data.binary_blobs(length=512, volume_fraction=0.1, n_dim=2) | ||
viewer.add_image(blobs, name='blobs') | ||
line1 = np.array([[11, 13], [111, 113]]) | ||
line2 = np.array([[200, 200], [400, 300]]) | ||
lines = [line1, line2] | ||
shapes_layer = viewer.add_shapes( | ||
lines, | ||
shape_type='line', | ||
edge_width=5, | ||
edge_color='coral', | ||
face_color='royalblue', | ||
) | ||
shapes_layer.mode = 'select' | ||
|
||
|
||
@shapes_layer.mouse_drag_callbacks.append | ||
def profile_lines_drag(layer, event): | ||
profile_lines(blobs, layer) | ||
yield | ||
while event.type == 'mouse_move': | ||
profile_lines(blobs, layer) | ||
# the yield statement allows the mouse UI to keep working while | ||
# this loop is executed repeatedly | ||
yield | ||
|
||
|
||
if __name__ == '__main__': | ||
napari.run() |
43 changes: 43 additions & 0 deletions
43
dev/html/_downloads/03b8aca5ce2cf0ea3dcfe976abd763e0/cursor_position.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"\n# Cursor position\n\nAdd small data to examine cursor positions\n\n.. tags:: interactivity\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import numpy as np\n\nimport napari\n\nviewer = napari.Viewer()\nimage = np.array([[1, 0, 0, 1],\n [0, 0, 1, 1],\n [1, 0, 3, 0],\n [0, 2, 0, 0]], dtype=int)\n\nviewer.add_labels(image)\n\npoints = np.array([[0, 0], [2, 0], [1, 3]])\nviewer.add_points(points, size=0.25)\n\nrect = np.array([[0, 0], [3, 1]])\nviewer.add_shapes(rect, shape_type='rectangle', edge_width=0.1)\n\nvect = np.array([[[3, 2], [-1, 1]]])\nviewer.add_vectors(vect, edge_width=0.1)\n\nif __name__ == '__main__':\n napari.run()" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.14" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 0 | ||
} |
55 changes: 55 additions & 0 deletions
55
dev/html/_downloads/05c99088daf94818055a38d86842b92a/add_points_with_multicolor_text.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
""" | ||
Add points with multicolor text | ||
=============================== | ||
Display a points layer on top of an image layer with text using | ||
multiple face colors mapped from features for the points and text. | ||
.. tags:: visualization-basic | ||
""" | ||
|
||
import numpy as np | ||
|
||
import napari | ||
|
||
# add the image with three points | ||
viewer = napari.view_image(np.zeros((400, 400))) | ||
points = np.array([[100, 100], [200, 300], [333, 111]]) | ||
|
||
# create features for each point | ||
features = { | ||
'confidence': np.array([1, 0.5, 0]), | ||
'good_point': np.array([True, False, False]), | ||
} | ||
|
||
# define the color cycle for the points face and text colors | ||
color_cycle = ['blue', 'green'] | ||
|
||
text = { | ||
'string': 'Confidence is {confidence:.2f}', | ||
'size': 20, | ||
'color': {'feature': 'good_point', 'colormap': color_cycle}, | ||
'translation': np.array([-30, 0]), | ||
} | ||
|
||
# create a points layer where the face_color is set by the good_point feature | ||
# and the border_color is set via a color map (grayscale) on the confidence | ||
# feature | ||
points_layer = viewer.add_points( | ||
points, | ||
features=features, | ||
text=text, | ||
size=20, | ||
border_width=7, | ||
border_width_is_relative=False, | ||
border_color='confidence', | ||
border_colormap='gray', | ||
face_color='good_point', | ||
face_color_cycle=color_cycle, | ||
) | ||
|
||
# set the border_color mode to colormap | ||
points_layer.border_color_mode = 'colormap' | ||
|
||
if __name__ == '__main__': | ||
napari.run() |
Oops, something went wrong.