or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

components.mdcore-viewer.mdindex.mdlayers.mdqt-interface.mdtypes.mdutilities.md
tile.json

tessl/pypi-napari

n-dimensional array viewer in Python with fast, interactive multi-dimensional image visualization

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/napari@0.6.x

To install, run

npx @tessl/cli install tessl/pypi-napari@0.6.0

index.mddocs/

Napari

Napari is a fast, interactive, multi-dimensional image viewer for Python designed for browsing, annotating, and analyzing large multi-dimensional scientific images. Built on Qt for the GUI, vispy for performant GPU-based rendering, and the scientific Python stack, it provides a comprehensive platform for scientific image visualization and analysis with support for n-dimensional arrays, plugin architecture for extensibility, and integration with the broader scientific Python ecosystem.

Package Information

  • Package Name: napari
  • Language: Python
  • Installation: pip install napari
  • Requirements: Python ≥3.10

Core Imports

import napari

Common patterns for direct access to specific functionality:

from napari import Viewer, view_image, view_labels
from napari.layers import Image, Labels, Points, Shapes
from napari.components import Dims, LayerList

Basic Usage

Creating and Using a Viewer

import napari
import numpy as np

# Create sample image data
image_data = np.random.random((100, 100))

# Method 1: Create viewer then add layers
viewer = napari.Viewer()
viewer.add_image(image_data, name='Random Image')

# Method 2: Create viewer with image directly  
viewer = napari.view_image(image_data, title='My Image Viewer')

# Show the viewer (starts Qt event loop)
napari.run()

Working with Multiple Layers

import napari
import numpy as np

# Create different types of data
image = np.random.random((100, 100))
labels = np.zeros((100, 100), dtype=int)
labels[25:75, 25:75] = 1
points = np.array([[50, 50], [25, 75]])

# Create viewer and add multiple layers
viewer = napari.Viewer()
viewer.add_image(image, name='Image')
viewer.add_labels(labels, name='Segmentation')
viewer.add_points(points, name='Points', size=10)

napari.run()

Architecture

Napari's architecture centers around a layered approach to multi-dimensional visualization:

  • Viewer: The main application window and controller managing the visual display and user interactions
  • Layers: Data visualization objects representing different types of scientific data (images, annotations, measurements)
  • Components: Core functional components managing viewer state (dimensions, camera, layer list)
  • Qt Interface: GUI widgets, event handling, and visual controls built on the Qt framework
  • Plugin System: Extensible architecture supporting reader/writer plugins and custom widgets via npe2

This design enables napari to serve as both a standalone scientific image viewer and a platform for building domain-specific visualization applications in fields like microscopy, medical imaging, and scientific data analysis.

Capabilities

Core Viewer Management

Main viewer class and viewer management functionality for creating and controlling napari viewers, including window management and viewer lifecycle.

class Viewer:
    def __init__(self, *, title='napari', ndisplay=2, order=(), axis_labels=(), show=True, **kwargs): ...
    def add_image(self, data, **kwargs): ...
    def add_labels(self, data, **kwargs): ...
    def add_points(self, data, **kwargs): ...
    def add_shapes(self, data, **kwargs): ...
    def add_surface(self, data, **kwargs): ...
    def add_tracks(self, data, **kwargs): ...
    def add_vectors(self, data, **kwargs): ...
    def open(self, path, **kwargs): ...

def current_viewer(): ...
def run(*, force=False, gui_exceptions=False, max_loop_level=1): ...

Core Viewer

Layer Types and Data Visualization

Complete set of layer types for visualizing different kinds of scientific data, from n-dimensional images to geometric annotations and measurements.

class Layer: ...
class Image(Layer): ...
class Labels(Layer): ...
class Points(Layer): ...
class Shapes(Layer): ...
class Surface(Layer): ...
class Tracks(Layer): ...
class Vectors(Layer): ...

Layers

Viewer Components

Core components that manage viewer state including dimensional navigation, camera controls, and layer management.

class Dims: ...
class Camera: ...
class LayerList: ...
class ViewerModel: ...

Components

Qt Interface and GUI

Qt-based graphical user interface components, widgets, threading utilities, and event loop management for desktop applications.

class QtViewer: ...
class Window: ...
def get_qapp(): ...
def create_worker(func): ...
def thread_worker(func): ...

Qt Interface

Utilities and Helpers

Utility functions for colormaps, progress indicators, system information, notifications, and other helper functionality.

class Colormap: ...
def sys_info(): ...
def progress(iterable): ...
def progrange(n): ...

Utilities

Data Types and Type Definitions

Comprehensive type definitions for arrays, layer data, plugin interfaces, and configuration objects used throughout the napari ecosystem.

ArrayLike = Union[np.ndarray, 'dask.array.Array', 'zarr.Array']
LayerData = Union[tuple[Any], tuple[Any, Mapping], FullLayerData]
PathLike = Union[str, Path]
ReaderFunction = Callable[[PathOrPaths], list[LayerData]]

Types

View Functions

Convenience functions for creating viewers with specific layer types:

# Create viewers with specific layer types
# NOTE: These view_* functions are deprecated as of napari 0.7.0
# Use Viewer().add_* methods instead
napari.view_image(data, **kwargs) -> napari.Viewer  # Deprecated
napari.view_labels(data, **kwargs) -> napari.Viewer  # Deprecated
napari.view_points(data, **kwargs) -> napari.Viewer  # Deprecated
napari.view_shapes(data, **kwargs) -> napari.Viewer  # Deprecated
napari.view_surface(data, **kwargs) -> napari.Viewer  # Deprecated
napari.view_tracks(data, **kwargs) -> napari.Viewer  # Deprecated
napari.view_vectors(data, **kwargs) -> napari.Viewer  # Deprecated
napari.imshow(data, **kwargs) -> tuple[napari.Viewer, list[napari.layers.Image]]  # matplotlib-style

Plugin Integration

# Save layers using plugin system
napari.save_layers(path, layers, plugin=None)

# Access experimental features  
from napari.experimental import link_layers, unlink_layers, layers_linked

def link_layers(layers, attributes=()) -> list:
    """Link attributes between all layers in layers."""
    
def unlink_layers(layers, attributes=()) -> None:
    """Unlink previously linked attributes between layers."""
    
def layers_linked(layers, attributes=()):
    """Context manager that temporarily links attributes on layers."""

# Access notification system
napari.notification_manager