You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/tutorials/fundamentals/getting_started.md
+54-22Lines changed: 54 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -32,12 +32,11 @@ This command will launch an empty viewer:
32
32
33
33

34
34
35
-
Once you have the viewer open you can add images through the `File/Open` dropdown menu
35
+
Once you have the viewer open you can add images through the `File -> Open` dropdown menu
36
36
or by dragging and dropping images directly on the viewer.
37
37
We currently only support files that can be read with [`skimage.io.imread`](https://scikit-image.org/docs/dev/api/skimage.io.html#skimage.io.imread),
38
38
such as `tif`, `png`, and `jpg`.
39
39
We plan on adding support for more exotic file types shortly - see [issue #379](https://github.com/napari/napari/issues/379) for discussion.
40
-
You can also create new empty `points`, `shapes`, and `labels` layers using the new layer buttons in the bottom right of the viewer.
41
40
42
41
You can also directly load an image into the viewer from the command line by passing the path to the image as an argument as follows
43
42
@@ -56,31 +55,54 @@ but we'll be adding support for this functionality soon as discussed in [#379](h
56
55
57
56
### Python script usage
58
57
59
-
To launch napari from a python script, inside your script you should import `napari`,
60
-
and then create the `Viewer` by adding some data.
58
+
To launch napari from a python script, inside your script you can import `napari`,
59
+
then create a {class}`Viewer<napari.Viewer>` and {class}`Image<napari.layers.Image>`
60
+
layer by adding some image data, using {func}`imshow<napari.imshow>`.
61
+
The {class}`Viewer<napari.Viewer>` is representative of the napari viewer GUI
62
+
you launch and stores all the data you add to napari. The
63
+
{class}`Image<napari.layers.Image>` will store information about the image data
64
+
you added.
61
65
62
-
For example, to add an image and some points inside your script you should include:
66
+
For example, to add an image and print the shape of the image layer data,
67
+
you can use:
63
68
64
69
```python
70
+
# import sample data
71
+
from skimage.data import cells3d
72
+
65
73
import napari
66
74
67
-
# create a Viewer and add an image here
68
-
viewer= napari.view_image(my_image_data)
75
+
# create a `Viewer` and `Image` layer here
76
+
viewer, image_layer = napari.imshow(cells3d())
69
77
70
-
#custom code to add data here
71
-
viewer.add_points(my_points_data)
78
+
#print shape of image datas
79
+
print(image_layer.data.shape)
72
80
73
81
# start the event loop and show the viewer
74
82
napari.run()
75
83
```
76
84
77
-
then run your script from the command line to launch the viewer with your data:
85
+
Note that {func}`imshow<napari.imshow>` is a convenience function that is
86
+
equivalent to:
87
+
88
+
```python
89
+
# import sample data
90
+
from skimage.data import cells3d
91
+
92
+
import napari
93
+
94
+
viewer = napari.Viewer()
95
+
image_layer = viewer.add_image(cells3d())
96
+
```
97
+
98
+
You can now run your script from the command line to launch the viewer with your data:
78
99
79
100
```sh
80
101
python my_example_script.py
81
102
```
82
103
83
-
See the scripts inside the [`examples`](https://github.com/napari/napari/tree/main/examples) in the main repository for examples of using napari this way.
104
+
The [examples gallery](../../gallery) consists of code examples which can be
105
+
downloaded as `.py` (and `.ipynb` files) and run as above.
84
106
85
107

86
108
@@ -89,14 +111,17 @@ is that you can preprocess your images and add multiple layers before displaying
89
111
90
112
### IPython console usage
91
113
92
-
To launch napari from an IPython console import `napari` and create a `Viewer` object.
114
+
To launch napari from an IPython console import `napari` and create a
115
+
{class}`Viewer<napari.Viewer>` and {class}`Image<napari.layers.Image>` object.
93
116
94
117
```python
118
+
# import sample data
119
+
from skimage.data import cells3d
120
+
95
121
import napari
96
-
from skimage.data import astronaut
97
122
98
-
# create the viewer and display the image
99
-
viewer= napari.view_image(astronaut(), rgb=True)
123
+
# create a `Viewer` and `Image` layer here
124
+
viewer, image_layer = napari.imshow(cells3d())
100
125
```
101
126
102
127
Napari will automatically use the interactive [`%gui qt` event
@@ -112,18 +137,25 @@ and where data changed in the GUI will be accessible in the console.
112
137
113
138
### Jupyter notebook usage
114
139
115
-
You can also launch napari from a jupyter notebook,
116
-
such as [`examples/notebook.ipynb`](https://github.com/napari/napari/tree/main/examples/notebook.ipynb)
140
+
You can also launch napari from a Jupyter notebook. The
141
+
[examples gallery](../../gallery), as mentioned above, can also be downloaded as
142
+
`.ipynb` which can be run from a Jupyter notebook.
117
143
118
-

144
+
Below, we launch the [notebook example](https://github.com/napari/napari/tree/main/examples/notebook.ipynb) from a Jupyter notebook.
145
+
146
+

119
147
120
148
Similar to launching from the IPython console,
121
-
an advantage of launching napari from a jupyter notebook
122
-
is that you can continue to programmatically interact with the viewer from jupyter notebook,
149
+
an advantage of launching napari from a Jupyter notebook
150
+
is that you can continue to programmatically interact with the viewer from Jupyter notebook,
123
151
including bidirectional communication, where code run in the notebook will update the current viewer
124
152
and where data changed in the GUI will be accessible in the notebook.
125
153
126
154
## Next steps
127
155
128
-
To learn more about how to use the napari viewer with different types of napari layers
129
-
checkout the [viewer tutorial](./viewer) and more of our tutorials listed below.
156
+
To learn more about:
157
+
158
+
* how to use the napari viewer graphical user interface (GUI),
159
+
checkout the [viewer tutorial](./viewer)
160
+
* how to use the napari viewer with different types of napari layers, see
0 commit comments