impy.viewer package¶
Submodules¶
impy.viewer.utils module¶
- class impy.viewer.utils.ComplexArrayView(data: _A)[source]¶
Bases:
object
View a complex array in napari.
- property data_raw: _A¶
Return the raw data.
- property dtype: dtype¶
Data type of array.
- property nbytes: int¶
Bytes of array.
- property ndim: int¶
Number of dimensions of array.
- property shape: tuple¶
Shape of array.
- impy.viewer.utils.add_dask(viewer: Viewer, img: LazyImgArray, **kwargs)[source]¶
- impy.viewer.utils.add_labeledarray(viewer: Viewer, img: LabeledArray, **kwargs)[source]¶
Add a LabeledArray to the viewer.
- impy.viewer.utils.add_labels(viewer: Viewer, labels: Label, opacity: float = 0.3, name: str | list[str] | None = None, **kwargs)[source]¶
- impy.viewer.utils.add_tracks(viewer: napari.Viewer, track: TrackFrame, **kwargs)[source]¶
- impy.viewer.utils.front_image(viewer: Viewer)[source]¶
From list of image layers return the most front visible image.
- impy.viewer.utils.iter_layer(viewer: Viewer, layer_type: str)[source]¶
Iterate over layers and yield only certain type of layers.
- Parameters:
layer_type (str, {"shape", "image", "point"}) – Type of layer.
- Yields:
napari.layers – Layers specified by layer_type
- impy.viewer.utils.iter_selected_layer(viewer: Viewer, layer_type: str | list[str])[source]¶
Iterate over selected layers and yield only certain type of layers.
- impy.viewer.utils.layer_to_impy_object(viewer: Viewer, layer)[source]¶
Convert layer to real data.
- Parameters:
layer (napari.layers.Layer) – Input layer.
- Return type:
ImgArray, Label, MarkerFrame or TrackFrame, or Shape features.
impy.viewer.viewer module¶
- class impy.viewer.viewer.napariViewers[source]¶
Bases:
object
The controller of
napari.Viewer``s from ``impy
. Always access byip.gui
.- add(obj: ImpyObject, **kwargs)[source]¶
Add images, points, labels, tracks etc to viewer.
- Parameters:
obj (ImpyObject) – Object to add.
- property axes: Axes¶
Axes information of current viewer.
Defined to make compatible with
ImgArray
.
- property current_slice: tuple[slice | int, ...]¶
Return a tuple of slicer that corresponds to current field of view.
For instance, when the viewer is displaying yx-plane at t=1, then this property returns
(1, slice(None), slice(None))
.
- property cursor_pos: ndarray¶
Return cursor position. Scale is considered.
- cursor_to_pixel(ref: 'napari.layers.Image' | int | str | LabeledArray | LazyImgArray, ndim: int = None) np.ndarray [source]¶
With cursor position and a layer as inputs, this function returns the cursor “pixel” coordinates on the given layer. This function is useful when you want to get such as pixel value at the cursor position.
- Parameters:
ref (napari.layers.Image, int, str, LabeledArray or LazyImgArray) –
Reference layer or its identifier. To determine the reference layer, this parameter is interpreted in different ways depending on its type:
napari.layers.Image … layer itself
int … the index of layer list
str … the name of layer list
LabeledArray or LazyImgArray … layer that has same object as data
ndim (int, optional) – If specified, the last ndim coordinates will be returned.
- Returns:
1-D, int64 array of cursor position along each dimension.
- Return type:
np.ndarray
- get(kind: str = 'image', layer_state: str = 'visible', returns: str = 'last') ImpyObject | list[impy.viewer.viewer.ImpyObject] [source]¶
Simple way to get impy object from viewer.
- Parameters:
kind (str, optional) –
Kind of layers/shapes to return.
”image”: Image layer.
”labels”: Labels layer
”points”: Points layer.
”shapes”: Shapes layer.
”tracks”: Tracks layer.
”vectors”: Vectors layer.
”surface”: Surface layer.
”line”: Line shapes in Shapes layer.
”rectangle”: Rectangle shapes in Shapes layer.
”path”: Path shapes in Shapes layer.
”polygon”: Polygon shapes in Shapes layer.
”ellipse”: Ellipse shapes in Shapes layer.
layer_state ({"selected", "visible", "any"}, default is "any") –
How to filter layer list.
”selected”: Only selected layers will be searched.
”visible”: Only visible layers will be searched.
”any”: All the layers will be searched.
returns ({"first", "last", "all"}) –
What will be returned in case that there are multiple layers/shapes.
”first”: Only the first object will be returned.
”last”: Only the last object will be returned.
”all”: All the objects will be returned as a list.
- Returns:
impy object(s) that satisfies the options.
- Return type:
ImgArray, Label, MarkerFrame or TrackFrame, np.ndarray, or list of one of them.
Examples
Get the front image.
>>> ip.gui.get("image")
Get all the selected images as a list.
>>> ip.gui.get("image", layer_state="selected", returns="all")
Get all the lines from the front visible shapes layer.
>>> ip.gui.get("line", layer_state="visible")
- goto(**kwargs) tuple[int, ...] [source]¶
Change the current step of the viewer.
Examples
Go to t=3.
>>> ip.gui.goto(t=3)
Go to t=3 and last z.
>>> ip.gui.goto(t=3, z=-1)
- property layers: LayerList¶
Napari layer list. Identical to
ip.gui.viewer.layers
.
- property scale: ScaleView¶
Scale information of current viewer.
Defined to make compatible with
ImgArray
.
- property selection: list[impy.viewer.viewer.ImpyObject]¶
Return selected layers’ data as a list of impy objects.
- stepof(symbol: str | Axis) int [source]¶
Get the current step of certain axis.
- Parameters:
symbol (AxisLike) – Axis symbol
- property viewer: Viewer¶
The most front viewer you’re using