@@ -15,8 +15,8 @@ kernelspec:
15
15
16
16
``` {Admonition} DEPRECATED ATTRIBUTES
17
17
:class: warning
18
- As of napari 0.5.0, `edge_*` attributes are being renamed to
19
- `border_*` attributes. We have yet to update the images and/or videos in
18
+ As of napari 0.5.0, `edge_*` attributes are being renamed to
19
+ `border_*` attributes. We have yet to update the images and/or videos in
20
20
this tutorial. Please use `border` in place of `edge` for all `Points` attributes moving forward.
21
21
22
22
The code in this tutorial uses the latest API. Only images and videos may be out of date.
@@ -37,11 +37,11 @@ points independently. You can also adjust `opacity` and `symbol` representing
37
37
all the points simultaneously.
38
38
39
39
Each data point can have annotations associated with it using the
40
- ` Points.properties ` dictionary . These properties can be used to set the face and
40
+ ` Points.features ` table . These features can be used to set the face and
41
41
border colors of the points. For example, when displaying points of different
42
42
classes/types, one could automatically set color the individual points by their
43
- respective class/type. For more details on point properties , see
44
- [ ] ( #setting-point-border-and-face-color-with-properties ) or
43
+ respective class/type. For more details on point features , see
44
+ [ ] ( #setting-point-border-and-face-color-with-features ) or
45
45
[ point annotation tutorial] ( ../../tutorials/annotation/annotate_points ) .
46
46
47
47
## Creating and editing the ` points ` layer using the GUI
@@ -116,7 +116,7 @@ layer:
116
116
to move around the ` points ` layer as you create your selection.
117
117
118
118
* ** Pan/zoom**
119
- ![ image: Pan/zoom tool] ( ../../images/pan-zoom-tool.png )
119
+ ![ image: Pan/zoom tool] ( ../../images/pan-zoom-tool.png )
120
120
121
121
The default mode of the points layer supports panning and zooming, as in the
122
122
image layer. This mode is represented by the magnifying glass in the layers
@@ -194,7 +194,7 @@ layer:
194
194
Note that when entering 3D rendering mode the GUI ` Add point ` ,
195
195
` Delete selected points ` , and ` Select points ` tools are all disabled. Those
196
196
options are supported only when viewing a layer using 2D rendering.
197
-
197
+
198
198
* ` ctrl-c ` and ` ctrl-v ` (copying and pasting points)
199
199
200
200
Copy and paste any selected points using ` ctrl-c ` and ` ctrl-v ` , respectively.
@@ -214,12 +214,12 @@ the same. In these examples we'll mainly use `add_points` to overlay points onto
214
214
on an existing image.
215
215
216
216
Each data point can have annotations associated with it using the
217
- ` Points.properties ` dictionary . These properties can be used to set the face and
217
+ ` Points.features ` table . These features can be used to set the face and
218
218
border colors of the points. For example, when displaying points of different
219
219
classes/types, one could automatically set the color of the individual points by
220
- their respective class/type. For more details on point properties , see
221
- [ ] ( #setting-point-border-and-face-color-with-properties ) below or the
222
- [ Point annotation tutorial] ( ../../tutorials/annotation/annotate_points ) .
220
+ their respective class/type. For more details on point features , see
221
+ [ ] ( #setting-point-border-and-face-color-with-features ) below or the
222
+ [ Point annotation tutorial] ( annotating-points ) .
223
223
224
224
In this example, we will overlay some points on the image of an astronaut:
225
225
@@ -267,14 +267,40 @@ the same as the ordering of the dimensions for image layers. This array is
267
267
always accessible through the ` layer.data ` property and will grow or shrink as
268
268
new points are either added or deleted.
269
269
270
- ### Using the points properties dictionary
270
+ (points-features-table)=
271
+
272
+ ### Using the points features table
273
+
274
+ The ` Points ` layer can contain features that annotate each point.
275
+ ` Points.features ` stores the features in a table or data frame where each column
276
+ represents a feature and each row represents a point.
277
+ Therefore, the table has N rows for the N points in ` Points.data ` .
278
+ This table can be provided as a dictionary that maps from feature names to
279
+ the columns of feature values.
280
+ For example, the following dictionary can be used as the value for the ` features `
281
+ parameter in {meth}` Viewer.add_points<napari.Viewer.add_points> `
282
+
283
+ ``` python
284
+ features = {
285
+ ' good_point' : [True , True , False ],
286
+ ' confidence' : [0.99 , 0.8 , 0.2 ],
287
+ }
288
+ ```
289
+
290
+ and corresponds to the following features table
291
+
292
+ | point index | good_point | confidence |
293
+ | ----------- | ---------- | ---------- |
294
+ | 0 | True | 0.99 |
295
+ | 1 | True | 0.8 |
296
+ | 2 | False | 0.2 |
297
+
298
+ where the point index is the index for a point in both ` data ` and its corresponding
299
+ row in the ` features ` table.
271
300
272
- The ` points ` layer can contain properties that annotate each point.
273
- ` Points.properties ` stores the properties in a dictionary where each key is the
274
- name of the property and the values are NumPy arrays with a value for each point
275
- (i.e., length N for N points in ` Points.data ` ). As we will see below, we can use
276
- the values in a property to set the display properties of the points (e.g., face
277
- color or border color). To see the points properties in action, please see the
301
+ As we will see below, we can use feature values to determine the display properties
302
+ of the points (e.g., face color or border color).
303
+ To see the points features in action, please see the
278
304
[ Point annotation tutorial] ( annotating-points ) .
279
305
280
306
@@ -338,17 +364,17 @@ properties are different from the `layer.current_border_color` and
338
364
` layer.current_face_color ` properties that will determine the color of the next
339
365
point to be added or any currently selected points.
340
366
341
- ### Setting point border and face color with properties
367
+ ### Setting point border and face color with features
342
368
343
- Point border and face colors can be set as a function of a property in
344
- ` Points.properties ` . There are two ways the values in ` Points.properties ` can be
369
+ Point border and face colors can be set as a function of a feature in
370
+ ` Points.features ` . There are two ways that these feature values can be
345
371
mapped to colors: (1) color cycles and (2) colormaps.
346
372
347
- Color cycles are sets of colors that are mapped to categorical properties. The
348
- colors are repeated if the number of unique property values is greater than the
349
- number of colors in the color cycle.
373
+ Color cycles are sets of colors that are mapped to categorical features.
374
+ The colors are repeated if the number of unique feature values is greater
375
+ than the number of colors in the color cycle.
350
376
351
- Colormaps are a continuum of colors that are mapped to a continuous property
377
+ Colormaps are a continuum of colors that are mapped to a continuous feature
352
378
value. The available colormaps are listed below (colormaps are from
353
379
[ vispy] ( https://vispy.org/api/vispy.color.colormap.html#vispy.color.colormap.Colormap ) ).
354
380
For guidance on choosing colormaps, see the
@@ -360,21 +386,21 @@ list(napari.utils.colormaps.AVAILABLE_COLORMAPS)
360
386
361
387
### Setting border or face color with a color cycle
362
388
363
- Here we will set the border color of the markers with a color cycle on a property .
389
+ Here we will set the border color of the markers with a color cycle on a feature .
364
390
To do the same for a face color, substitute ` face_color ` for ` border_color ` in the
365
391
example snippet below.
366
392
367
393
``` {code-cell} python
368
394
viewer = napari.view_image(data.astronaut(), rgb=True)
369
395
points = np.array([[100, 100], [200, 200], [300, 100]])
370
- point_properties = {
371
- 'good_point': np.array( [True, True, False]) ,
372
- 'confidence': np.array( [0.99, 0.8, 0.2]) ,
396
+ point_features = {
397
+ 'good_point': [True, True, False],
398
+ 'confidence': [0.99, 0.8, 0.2],
373
399
}
374
400
375
401
points_layer = viewer.add_points(
376
402
points,
377
- properties=point_properties ,
403
+ features=point_features ,
378
404
border_color='good_point',
379
405
border_color_cycle=['magenta', 'green'],
380
406
border_width=0.5,
@@ -392,33 +418,34 @@ nbscreenshot(viewer, alt_text="3 points overlaid on an astronaut image, where th
392
418
viewer.close()
393
419
```
394
420
395
- In the example above, the ` point_properties ` were provided as a dictionary with
396
- two properties: ` good_point ` and ` confidence ` . The values of each property are
397
- stored in a NumPy ndarray with length 3 since there were 3 coordinates provided
398
- in ` points ` . We set the border color as a function of the ` good_point ` property by
399
- providing the keyword argument ` border_color='good_point' ` to the
400
- ` viewer.add_points() ` method. The color cycle is set via the ` border_color_cycle `
401
- keyword argument, ` border_color_cycle=['magenta', 'green'] ` . The color cycle can
402
- be provided as a list of colors (as a list of strings or a (M x 4) array of M
403
- RGBA colors).
421
+ In the example above, the ` point_features ` table was provided as a
422
+ dictionary with two keys or features: ` good_point ` and ` confidence `
423
+ as described in [ ] ( points-features-table ) .
424
+ The values of each feature are stored in a list of length 3 since there were three
425
+ coordinates provided in ` points ` . We set the border color as a function of the
426
+ ` good_point ` feature by providing the keyword argument
427
+ ` border_color='good_point' ` to the ` viewer.add_points() ` method.
428
+ The color cycle is set via the ` border_color_cycle ` keyword argument,
429
+ ` border_color_cycle=['magenta', 'green'] ` . The color cycle can be provided as a
430
+ list of colors (a list of strings or a (M x 4) array of M RGBA colors).
404
431
405
432
### Setting border or face color with a colormap
406
433
407
434
In the example snippet below, we set the face color of the markers with a
408
- colormap on a property . To do the same for a border color, substitute ` face ` for
435
+ colormap on a feature . To do the same for a border color, substitute ` face ` for
409
436
` border ` .
410
437
411
438
``` {code-cell} python
412
439
viewer = napari.view_image(data.astronaut(), rgb=True)
413
440
points = np.array([[100, 100], [200, 200], [300, 100]])
414
- point_properties = {
415
- 'good_point': np.array( [True, True, False]) ,
416
- 'confidence': np.array( [0.99, 0.8, 0.2]) ,
441
+ point_features = {
442
+ 'good_point': [True, True, False],
443
+ 'confidence': [0.99, 0.8, 0.2],
417
444
}
418
445
419
446
points_layer = viewer.add_points(
420
447
points,
421
- properties=point_properties ,
448
+ features=point_features ,
422
449
face_color='confidence',
423
450
face_colormap='viridis',
424
451
)
@@ -435,13 +462,15 @@ nbscreenshot(viewer, alt_text="3 points overlaid on an astronaut image, where th
435
462
viewer.close()
436
463
```
437
464
438
- In the example above, the ` point_properties ` were provided as a dictionary with
439
- two properties: ` good_point ` and ` confidence ` . The values of each property are
440
- stored in a NumPy ndarray with length 3 since there were 3 coordinates provided
441
- in ` points ` . We set the face color as a function of the ` confidence ` property by
442
- providing the keyword argument ` face_color='confidence' ` to the
443
- ` viewer.add_points() ` method. We set the colormap to viridis using the
444
- ` face_colormap ` keyword argument as ` face_colormap='viridis' ` .
465
+ In the example above, the ` point_features ` table was provided as a
466
+ dictionary with two keys or features: ` good_point ` and ` confidence `
467
+ as described in [ ] ( points-features-table ) .
468
+ The values of each feature are stored in a list of length 3 since there were three
469
+ coordinates provided in ` points ` .
470
+ We set the face color as a function of the ` confidence ` feature by providing the
471
+ keyword argument ` face_color='confidence' ` to the ` viewer.add_points() ` method.
472
+ We set the colormap to viridis using the ` face_colormap ` keyword argument
473
+ as ` face_colormap='viridis' ` .
445
474
446
475
### Changing the points symbol
447
476
@@ -452,7 +481,7 @@ layer using the `symbol` keyword argument.
452
481
## Putting it all together
453
482
454
483
Here you can see an example of adding, selecting, deleting points, and changing
455
- their properties :
484
+ their features :
456
485
457
486
``` {raw} html
458
487
<figure>
0 commit comments