Data layers¶
See Data layers for an introduction to data layers.
Layer
¶
Layer(
name: str = "",
data: Any = None,
meta: Optional[Dict] = None,
position: Optional[Tuple] = None,
tile_meta: Optional[TileMeta] = None,
description: str = "",
merger: str = "default",
**meta_kwargs,
)
Base class of data layers.
A data layer holds a single piece of data (an image, a mask, a numeric value, etc.) together with metadata. Layers represent both the inputs and the outputs of algorithms.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the layer. |
""
|
data
|
object
|
Data held by the layer. Its type depends on the subclass. |
None
|
meta
|
dict
|
Metadata dictionary. It is merged with |
None
|
position
|
tuple
|
Position of the layer in global pixel coordinates. |
None
|
tile_meta
|
TileMeta
|
Metadata about the layer's position and role in a set of tiles. |
None
|
description
|
str
|
Description of the layer, displayed on the algorithm documentation page. |
""
|
merger
|
str
|
Strategy used to merge the layer when it is assembled from tiles. Only |
"default"
|
**meta_kwargs
|
Extra metadata, added to |
{}
|
Attributes:
| Name | Type | Description |
|---|---|---|
data |
Any
|
Data held by the layer. |
name |
str
|
Name of the layer. |
meta |
dict
|
Metadata about the layer. |
kind |
str
|
A short string identifying the layer type, e.g. |
position |
tuple
|
Position of the layer in global pixel coordinates. |
extent |
Domain
|
Region covered by the data in global pixel coordinates. For objects such as points, it is the bounding box of the objects. |
size |
tuple
|
Size of the extent. |
coords_min |
tuple
|
Lower corner of the extent. |
coords_max |
tuple
|
Upper corner of the extent. |
ndim |
int
|
Number of spatial dimensions. |
shape |
tuple
|
Shape of the data, if it is array-like. |
tile_meta |
TileMeta
|
Metadata about the layer's position and role in a set of tiles. |
select
¶
Image
¶
Image(
data: Optional[ndarray] = None,
name="Image",
description="Input image",
dimensionality: Optional[List[int]] = None,
rgb: bool = False,
channel_axis: Optional[int] = None,
**kwargs,
)
Bases: Layer
Data layer for images: 2D or 3D arrays, optionally multichannel or RGB.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
The image array. |
None
|
name
|
str
|
Name of the layer. |
"Image"
|
description
|
str
|
Description of the layer, displayed on the algorithm documentation page. |
"Input image"
|
dimensionality
|
list of int
|
Accepted numbers of dimensions, for example |
None
|
rgb
|
bool
|
Set to |
False
|
channel_axis
|
int
|
Index of the channel axis, for multichannel images. The channel axis is not
counted as a spatial dimension (it doesn't affect |
None
|
**kwargs
|
Passed to |
{}
|
Examples:
Mask
¶
Mask(
data: Optional[ndarray] = None,
name: str = "Mask",
description: str = "Segmentation mask",
dimensionality: Optional[List[int]] = None,
channel_axis: Optional[int] = None,
**kwargs,
)
Bases: Layer
Data layer for segmentation masks.
Masks are label images, where integer values encode either object classes (e.g. for pixel classification) or object instances.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
The label image. Boolean arrays are accepted for binary masks. |
None
|
name
|
str
|
Name of the layer. |
"Mask"
|
description
|
str
|
Description of the layer, displayed on the algorithm documentation page. |
"Segmentation mask"
|
dimensionality
|
list of int
|
Accepted numbers of dimensions, for example |
None
|
channel_axis
|
int
|
Index of the channel axis, if any. The channel axis is not counted as a spatial dimension, and it is never split into tiles. |
None
|
**kwargs
|
Passed to |
{}
|
Examples:
Points
¶
Points(
data: Optional[ndarray] = None,
name="Points",
description="Input points (2D, 3D)",
dimensionality: Optional[List[int]] = None,
**kwargs,
)
Bases: Layer
Data layer for sets of points (2D, 3D).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
Point coordinates, as an array of shape |
None
|
name
|
str
|
Name of the layer. |
"Points"
|
description
|
str
|
Description of the layer, displayed on the algorithm documentation page. |
"Input points (2D, 3D)"
|
dimensionality
|
list of int
|
Accepted numbers of dimensions, for example |
None
|
**kwargs
|
Passed to |
{}
|
Vectors
¶
Vectors(
data: Optional[ndarray] = None,
name="Vectors",
description="Input vectors (2D, 3D)",
dimensionality: Optional[List[int]] = None,
**kwargs,
)
Bases: Layer
Data layer for sets of vectors (2D, 3D).
Each vector is defined by an origin point and a displacement.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
An array of shape |
None
|
name
|
str
|
Name of the layer. |
"Vectors"
|
description
|
str
|
Description of the layer, displayed on the algorithm documentation page. |
"Input vectors (2D, 3D)"
|
dimensionality
|
list of int
|
Accepted numbers of dimensions, for example |
None
|
**kwargs
|
Passed to |
{}
|
Boxes
¶
Boxes(
data: Optional[ndarray] = None,
name="Boxes",
description="Bounding boxes",
dimensionality: Optional[List[int]] = None,
**kwargs,
)
Bases: Layer
Data layer for bounding boxes (2D, 3D).
Boxes can be oriented (OBB).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
The coordinates of the four corners of each box, as an array of shape
|
None
|
name
|
str
|
Name of the layer. |
"Boxes"
|
description
|
str
|
Description of the layer, displayed on the algorithm documentation page. |
"Bounding boxes"
|
dimensionality
|
list of int
|
Accepted numbers of dimensions, for example |
None
|
**kwargs
|
Passed to |
{}
|
Paths
¶
Paths(
data: Optional[List] = None,
name="Paths",
description="Input paths (2D, 3D)",
dimensionality: Optional[List[int]] = None,
serializer: str = "default",
**kwargs,
)
Bases: Layer
Data layer for paths (2D, 3D), for example spline curves.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
list of numpy.ndarray
|
One array per path, each of shape |
None
|
name
|
str
|
Name of the layer. |
"Paths"
|
description
|
str
|
Description of the layer, displayed on the algorithm documentation page. |
"Input paths (2D, 3D)"
|
dimensionality
|
list of int
|
Accepted numbers of dimensions, for example |
None
|
**kwargs
|
Passed to |
{}
|
Tracks
¶
Tracks(
data: Optional[ndarray] = None,
name="Tracks",
description="Input tracks (2D, 3D)",
dimensionality: Optional[List[int]] = None,
**kwargs,
)
Bases: Layer
Data layer for object tracks: point detections linked over time by a track ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
An array of shape |
None
|
name
|
str
|
Name of the layer. |
"Tracks"
|
description
|
str
|
Description of the layer, displayed on the algorithm documentation page. |
"Input tracks (2D, 3D)"
|
dimensionality
|
list of int
|
Accepted numbers of dimensions, for example |
None
|
**kwargs
|
Passed to |
{}
|
Float
¶
Float(
data: Optional[float] = None,
name="Float",
min: float = float(min),
max: float = float(max),
step: float = 0.1,
default: float = 0.0,
required: bool = True,
auto_call: bool = False,
**kwargs,
)
Bases: Layer
Data layer for floating-point values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
float
|
The value. |
None
|
name
|
str
|
Name of the layer. |
"Float"
|
min
|
float
|
Minimum accepted value. |
float(min)
|
max
|
float
|
Maximum accepted value. |
float(max)
|
step
|
float
|
Step size of the spin box in user interfaces. |
0.1
|
default
|
float
|
Default value, used when |
0.0
|
auto_call
|
bool
|
Re-run the algorithm when the value changes in user interfaces. |
False
|
**kwargs
|
Passed to |
{}
|
Examples:
Integer
¶
Integer(
data: Optional[int] = None,
name="Int",
default: int = 0,
required: bool = True,
auto_call: bool = False,
min: int = int(min),
max: int = int(max),
step: int = 1,
**kwargs,
)
Bases: Layer
Data layer for integer values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
int
|
The value. |
None
|
name
|
str
|
Name of the layer. |
"Int"
|
min
|
int
|
Minimum accepted value. |
int(min)
|
max
|
int
|
Maximum accepted value. |
int(max)
|
step
|
int
|
Step size of the spin box in user interfaces. |
1
|
default
|
int
|
Default value, used when |
0
|
auto_call
|
bool
|
Re-run the algorithm when the value changes in user interfaces. |
False
|
**kwargs
|
Passed to |
{}
|
Examples:
Bool
¶
Bool(
data: Optional[bool] = None,
name="Bool",
default: bool = False,
required: bool = True,
auto_call: bool = False,
**kwargs,
)
Bases: Layer
Data layer for boolean values, shown as a checkbox in user interfaces.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
bool
|
The value. |
None
|
name
|
str
|
Name of the layer. |
"Bool"
|
default
|
bool
|
Default value, used when |
False
|
auto_call
|
bool
|
Re-run the algorithm when the value changes in user interfaces. |
False
|
**kwargs
|
Passed to |
{}
|
String
¶
String(
data: Optional[str] = None,
name="String",
default: str = "",
required: bool = True,
**kwargs,
)
Bases: Layer
Data layer for strings of text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
str
|
The text. |
None
|
name
|
str
|
Name of the layer. |
"String"
|
default
|
str
|
Default value, used when |
""
|
**kwargs
|
Passed to |
{}
|
Choice
¶
Choice(
data: Optional[str] = None,
name="Choice",
items: Optional[List] = None,
required: bool = True,
default: str = "",
auto_call: bool = False,
**kwargs,
)
Bases: Layer
Data layer for a choice among items, shown as a dropdown in user interfaces.
Can be used to represent labels for classification.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
str
|
The selected item. |
None
|
name
|
str
|
Name of the layer. |
"Choice"
|
items
|
list of str
|
The available items. |
None
|
default
|
str
|
Default item, used when |
""
|
auto_call
|
bool
|
Re-run the algorithm when the selection changes in user interfaces. |
False
|
**kwargs
|
Passed to |
{}
|
Examples:
Notification
¶
Notification(
data: Optional[str] = None,
level: Optional[str] = "info",
name="Notification",
required: bool = True,
default: str = "",
**kwargs,
)
Bases: Layer
Data layer for text notifications.
Notifications are printed to the terminal, or shown in user interfaces (as Napari notifications, for example).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
str
|
The notification text. |
None
|
level
|
str
|
Notification level: |
"info"
|
name
|
str
|
Name of the layer. |
"Notification"
|
**kwargs
|
Passed to |
{}
|
Examples:
Progress
¶
Bases: Layer
Data layer for progress bars.
Progress is shown in the terminal, or as a progress bar in user interfaces.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
int
|
Number of completed steps. |
None
|
max_val
|
int
|
Total number of steps. |
1
|
name
|
str
|
Name of the layer. |
"Progress"
|
**kwargs
|
Passed to |
{}
|
Examples:
Null
¶
Null(
data: Optional[Any] = None,
name="None",
default=None,
serializer: str = "default",
**kwargs,
)
Bases: Layer
Data layer for None, or the absence of data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
None
|
Always |
None
|
name
|
str
|
Name of the layer. |
"None"
|
**kwargs
|
Passed to |
{}
|
Any
¶
Bases: Layer
Data layer for any other kind of data, such as custom Python objects.
Parameters with types that cannot be resolved, and outputs of unrecognized types, are represented by this layer. They are not shown in user interfaces.
Since this layer can hold arbitrary objects, it is generally not serializable,
and only works locally (not with servers). Exceptions are simple JSON-compatible
types (int, float, bool, str, numpy.ndarray), and lists, tuples, or
dictionaries of these types.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
object
|
Any kind of data. |
None
|
name
|
str
|
Name of the layer. |
"Any"
|
**kwargs
|
Passed to |
{}
|