impy.viewer package¶
Submodules¶
impy.viewer.utils module¶
- impy.viewer.utils.add_dask(viewer: napari.viewer.Viewer, img: impy.arrays.lazy.LazyImgArray, **kwargs)[source]¶
- impy.viewer.utils.add_labeledarray(viewer: napari.viewer.Viewer, img: impy.arrays.labeledarray.LabeledArray, **kwargs)[source]¶
- impy.viewer.utils.add_labels(viewer: napari.Viewer, labels: Label, opacity: float = 0.3, name: str | list[str] | None = None, **kwargs)[source]¶
- impy.viewer.utils.front_image(viewer: napari.viewer.Viewer)[source]¶
From list of image layers return the most front visible image.
- impy.viewer.utils.iter_layer(viewer: napari.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.layer_to_impy_object(viewer: napari.viewer.Viewer, layer)[source]¶
Convert layer to real data.
- Parameters
layer (napari.layers.Layer) – Input layer.
- Returns
- 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: Optional[ImpyObject] = None, **kwargs)[source]¶
Add images, points, labels, tracks etc to viewer.
- Parameters
obj (ImpyObject) – Object to add.
- add_surface(image3d: impy.arrays.labeledarray.LabeledArray, level: Optional[float] = None, step_size: int = 1, mask=None, **kwargs)[source]¶
Add a surface layer from a 3D image.
- Parameters
image3d (LabeledArray) – 3D image from which surface will be generated
level – Passed to
skimage.measure.marching_cubes
step_size – Passed to
skimage.measure.marching_cubes
mask – Passed to
skimage.measure.marching_cubes
- property axes: str¶
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: numpy.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[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: napari.components.layerlist.LayerList¶
Napari layer list. Identical to
ip.gui.viewer.layers
.
- property scale: dict[str, float]¶
Scale information of current viewer. Defined to make compatible with
ImgArray
.
- property selection: list[typing.NewType.<locals>.new_type]¶
Return selected layers’ data as a list of impy objects.
- stepof(symbol: str) int [source]¶
Get the current step of certain axis.
- Parameters
symbol (str) – Axis symbol
- property viewer: napari.viewer.Viewer¶
The most front viewer you’re using