Napari Q&A#

Below are short answers to some questions you may have about Napari.

1. What is Napari and what is it used for?

Napari is a multi-dimensional image viewer for Python. It is used to visualize scientific images and the data associated with them, such as segmentation masks, bounding boxes, and keypoints, for example.

With Napari, you can

  • visualize timeseries, 2D, 3D, and multi-channel images.

  • create interactive visualizations tailored to your needs.

  • set up visualizations in a Python script or a Jupyter notebook.

  • annotate data (draw masks, polygons, etc.).

  • use plugins from the community or develop and share your own plugin.

2. Where can I learn more about Napari?

Here are a few places where to learn more about Napari.

3. How is Napari related to Python?

Napari is a Python package. Its source code can be found in a GitHub repository.

Therefore, Napari integrates seamlessly into the scientific Python ecosystem. It can be easily coupled to machine learning and image analysis projects that use Python libraries, such as Scikit-image, OpenCV, or PyTorch.

4. How to install Napari?

Napari should be installed as a Python package using pip or conda. For more details, have a look at the official installation page as well as this repository’s installation and setup instructions.

5. Can Napari be started from the terminal?

Yes! In your terminal, with your Python environment activated and Napari installed in it, type

napari

The Napari viewer should open in a separate window.

_images/napari_terminal.gif
6. How can I open an image in Napari?

There are several ways to open images in Napari. The easiest is probably to Drag and drop the image file directly into the viewer window. You can also use File > Open File(s) from the menu.

_images/draganddrop.gif
Lastly, you can open images programmatically from a Python script or a Jupyter notebook.
import napari

# Create a new viewer with the image opened in it
viewer = napari.view_image(image)
7. What controls do I have in the Napari viewer?

The layer controls interface lets you change the contrast, opacity, colormap, and blending settings of individual layers, among other things, as well as the rendering mode in 3D view.

_images/layer_controls.png
You can toggle between **2D and 3D views**, and between **grid and overlay modes**, and change the **orientation** of the image by clicking on the corresponding icons at the bottom-left corner of the viewer. _images/viewer_icons.png
8. Where does the name Napari come from?

Napari is a settlement located at the north end of Tabuaeran atoll, Kiribati 🏝. You can learn more about it on Wikipedia.

9. Can I use Napari for annotating data?

Absolutely, Napari can be used as an annotation tool. You can manually annotate keypoints, polygons (e.g. bounding boxes) and draw segmentation masks.

_images/annotate.gif

To learn more about this topic, check out the Annotation page from the docs.

10. What kinds of images can be viewed in Napari?

With Napari, you can view images with an arbitrary number of dimensions (which is why it’s called an n-D image viewer). You can open 2D images in both grayscale and RGB (color) mode, 3D images, timeseries (2D+t, 3D+t), and multichannel images.

_images/mitosis.gif

Napari’s built-in image reader can open a number of common image file formats (TIF, PNG, JPEG…). In addition, many reader plugins (e.g. napari-aicsimageio, napari-medical-image-formats) can be installed to open specific file formats.

11. Besides images, what other kinds of data can be visualized in Napari?

You can add multiple layers of different types into the viewer and adjust their properties. Napari supports seven different layer types: Image, Labels, Points, Vectors, Shapes, Surface and Tracks. Each layer corresponds to a different data type and has its own set of visualizations and interactive controls.

To learn more about this topic, check out Using layers (Napari.org).

12. How is Napari related to Numpy?

Numpy is a fundamental package for scientific computing and image analysis in Python.

The images and the other types of image data that can be loaded into Napari (points, vectors, etc.) are all represented as Numpy arrays. Similarly, the data passed in argument to viewer.add_image(), viewer.add_points(), etc. should be Numpy arrays.

Note

You can access the Numpy arrays loaded into Napari through the data attribute of the layer. For example

# Access the data loaded in the first layer in the viewer
print(viewer.layers[0].data)
13. How is Napari related to Jupyter notebooks?

You can launch Napari from a Jupyter notebook, in which case you’ll be able to interactively load and save data from the viewer and control all of its features programmatically. You can take advantage of notebook functionalities, such as annotating your code using Markdown and running cells one by one to perform your analysis.

There are several examples of Image data visualization case studies in this repository that you can check out. These case studies take the form of Jupyter notebooks and give you examples of what you can do with Napari in different contexts.

14. What are Napari plugins? Where can I find them?

Plugins are a way of extending the viewer’s functionality by providing custom user interfaces and commands for realizing specific tasks. The Napari Hub offers a listing of over 300 plugins developed by the community.

You can install Napari plugins as Python packages using pip (e.g. pip install stardist-napari) or through the viewer’s menu: Plugins > Install/Uninstall Plugins....

15. Can I develop my own Napari plugin?

Once you have developed a working image analysis functionality, you can turn it into a plugin. If you think your plugin could be useful to others, you can publish it as a Python package and share it on the Napari Hub.

To develop your own Napari plugin, you will likely have to learn how to use the magicgui library as well as the basics of Qt for Python, which are the tools behind user interface creation in Napari.

16. Where can I find examples of Napari visualizations?

Check out the Napari Examples Gallery. You can also find several Image data visualization case studies in this repository.

17. What is the Napari bundled app?

In principle, Napari can be installed as a bundled app. However, the bundled app is still in active development, may not be very stable, and you cannot install plugins in it. Therefore, it is strongly recommended to install Napari as a Python package instead.

18. Where can I find help in image analysis in EPFL?

The Center for Imaging’s Image Analysis Hub provides EPFL-wide support in image analysis. Don’t hesitate to contact us by sending an email at imaging@epfl.ch to schedule a discussion about your specific challenges. We’re always happy to help!