magicclass.ext.vispy package

Subpackages

Submodules

magicclass.ext.vispy.camera module

class magicclass.ext.vispy.camera.Camera(viewbox: vispy.scene.widgets.viewbox.ViewBox)[source]

Bases: magicclass.fields._group.HasFields

The camera interface for vispy canvas.

fov

The field of view of the camera in degree.

Type

float

scale

The scale factor of the camera.

Type

float

center

The rotation center of the camera, in x, y, z order.

Type

tuple of float

angles

The Euler angles of the camera in degree, in x, y, z order.

Type

tuple of float

angles

Field class for magicgui construction. Unlike MagicField, object of this class always returns value itself.

center

Field class for magicgui construction. Unlike MagicField, object of this class always returns value itself.

fov

Field class for magicgui construction. Unlike MagicField, object of this class always returns value itself.

scale

Field class for magicgui construction. Unlike MagicField, object of this class always returns value itself.

class magicclass.ext.vispy.camera.EulerAngleEdit(value: tuple[float, float, float] = (0.0, 0.0, 0.0), layout: str = 'horizontal', nullable: bool = False, **kwargs)[source]

Bases: magicgui.widgets.Container

The TupleEdit for Euler angles.

property value: tuple[float, float, float]
class magicclass.ext.vispy.camera.VispyCamera(fov=45.0, distance=None, translate_speed=1.0, **kwargs)[source]

Bases: vispy.scene.cameras.arcball.ArcballCamera

The camera for the 3D view.

changed

Declares a signal emitter on a class.

This is class implements the [descriptor protocol](https://docs.python.org/3/howto/descriptor.html#descriptorhowto) and is designed to be used as a class attribute, with the supported signature types provided in the contructor:

```python from psygnal import Signal

class MyEmitter:

changed = Signal(int)

def receiver(arg: int):

print("new value:", arg)

emitter = MyEmitter() emitter.changed.connect(receiver) emitter.changed.emit(1) # prints 'new value: 1' ```

!!! note

in the example above, MyEmitter.changed is an instance of Signal, and emitter.changed is an instance of SignalInstance. See the documentation on [SignalInstance][psygnal.SignalInstance] for details on how to connect to and/or emit a signal on an instance of an object that has a Signal.

Parameters
  • *types (Union[Type[Any], Signature]) -- A sequence of individual types, or a single [inspect.Signature][] object.

  • description (str) -- Optional descriptive text for the signal. (not used internally).

  • name (Optional[str]) -- Optional name of the signal. If it is not specified then the name of the class attribute that is bound to the signal will be used. default None

  • check_nargs_on_connect (bool) -- Whether to check the number of positional args against signature when connecting a new callback. This can also be provided at connection time using .connect(..., check_nargs=True). By default, True.

  • check_types_on_connect (bool) -- Whether to check the callback parameter types against signature when connecting a new callback. This can also be provided at connection time using .connect(..., check_types=True). By default, False.

view_changed()[source]

Called when this camera is changes its view. Also called when its associated with a viewbox.

viewbox_key_event(event)[source]

The ViewBox key event handler

Parameters

event (instance of Event) -- The event.

magicclass.ext.vispy.camera.quaternion2euler(quaternion, degrees=False) tuple[float, float, float][source]

Converts VisPy quaternion into euler angle representation.

Euler angles have degeneracies, so the output might different from the Euler angles that might have been used to generate the input quaternion.

Euler angles representation also has a singularity near pitch = Pi/2 ; to avoid this, we set to Pi/2 pitch angles that are closer than the chosen epsilon from it.

Parameters
  • quaternion (vispy.util.Quaternion) -- Quaternion for conversion.

  • degrees (bool) -- If output is returned in degrees or radians.

Returns

angles -- Euler angles in (rx, ry, rz) order.

Return type

3-tuple

magicclass.ext.vispy.layer2d module

class magicclass.ext.vispy.layer2d.Curve(viewbox: ViewBox, x: ArrayLike, y: ArrayLike = None, face_color=None, edge_color=None, size: float = 7, name: str | None = None, lw: float = 1, ls: str = '-', symbol=None)[source]

Bases: magicclass.ext.vispy.layer2d.PlotDataLayer

class magicclass.ext.vispy.layer2d.Histogram(viewbox: ViewBox, data: np.ndarray, bins: int = 10, face_color=None, edge_color=None, name: str | None = None)[source]

Bases: magicclass.ext.vispy._base.LayerItem

property name
class magicclass.ext.vispy.layer2d.PlotDataLayer[source]

Bases: magicclass.ext.vispy._base.LayerItem

add(points: np.ndarray | Sequence)[source]

Add new points to the plot data item.

property color
property edge_color: numpy.ndarray

Edge color of the data.

property face_color: numpy.ndarray

Face color of the data.

property name: str
property ndata: int
remove(i: int | Sequence[int])[source]

Remove the i-th data.

property xdata: numpy.ndarray
property ydata: numpy.ndarray
class magicclass.ext.vispy.layer2d.Scatter(viewbox: ViewBox, x: ArrayLike, y: ArrayLike = None, face_color=None, edge_color=None, size: float = 7, name: str | None = None, symbol='o')[source]

Bases: magicclass.ext.vispy.layer2d.PlotDataLayer

magicclass.ext.vispy.layer3d module

class magicclass.ext.vispy.layer3d.Curve3D(data, viewbox: ViewBox, color=None, width=1.0, name: str | None = None)[source]

Bases: magicclass.ext.vispy._base.LayerItem, magicclass.fields._group.HasFields

color

Field class for magicgui construction. Unlike MagicField, object of this class always returns value itself.

property data: numpy.ndarray
property name: str
width

Field class for magicgui construction. Unlike MagicField, object of this class always returns value itself.

class magicclass.ext.vispy.layer3d.Image(data, viewbox: ViewBox, contrast_limits: tuple[float, float] | None = None, rendering: str = 'mip', iso_threshold: float | None = None, name: str = '', attenuation: float = 1.0, cmap: str = 'grays', gamma: str = 1.0, interpolation: str = 'linear')[source]

Bases: magicclass.ext.vispy._base.LayerItem, magicclass.fields._group.HasFields

INTERPOLATIONS = ['nearest', 'linear']
RENDERINGS = ['translucent', 'mip', 'minip', 'attenuated_mip', 'additive', 'iso', 'average']
attenuation

Field class for magicgui construction. Unlike MagicField, object of this class always returns value itself.

contrast_limits

Field class for magicgui construction. Unlike MagicField, object of this class always returns value itself.

property data: numpy.ndarray
gamma

Field class for magicgui construction. Unlike MagicField, object of this class always returns value itself.

interpolation

Field class for magicgui construction. Unlike MagicField, object of this class always returns value itself.

iso_threshold

Field class for magicgui construction. Unlike MagicField, object of this class always returns value itself.

property name: str
rendering

Field class for magicgui construction. Unlike MagicField, object of this class always returns value itself.

class magicclass.ext.vispy.layer3d.IsoSurface(data, viewbox: ViewBox, contrast_limits=None, iso_threshold=None, face_color=None, edge_color=None, shading='smooth', name: str | None = None)[source]

Bases: magicclass.ext.vispy.layer3d._SurfaceBase, magicclass.fields._group.HasFields

contrast_limits

Field class for magicgui construction. Unlike MagicField, object of this class always returns value itself.

property data: numpy.ndarray
edge_color

Field class for magicgui construction. Unlike MagicField, object of this class always returns value itself.

edge_width

Field class for magicgui construction. Unlike MagicField, object of this class always returns value itself.

face_color

Field class for magicgui construction. Unlike MagicField, object of this class always returns value itself.

iso_threshold

Field class for magicgui construction. Unlike MagicField, object of this class always returns value itself.

shading

Field class for magicgui construction. Unlike MagicField, object of this class always returns value itself.

class magicclass.ext.vispy.layer3d.Surface(data, viewbox: ViewBox, face_color=None, edge_color=None, shading='none', name: str | None = None)[source]

Bases: magicclass.ext.vispy.layer3d._SurfaceBase, magicclass.fields._group.HasFields

property data
edge_color

Field class for magicgui construction. Unlike MagicField, object of this class always returns value itself.

edge_width

Field class for magicgui construction. Unlike MagicField, object of this class always returns value itself.

face_color

Field class for magicgui construction. Unlike MagicField, object of this class always returns value itself.

shading

Field class for magicgui construction. Unlike MagicField, object of this class always returns value itself.

class magicclass.ext.vispy.layer3d.SurfaceData(verts: np.ndarray, faces: np.ndarray, values: np.ndarray)[source]

Bases: NamedTuple

Dataset that defines a surface data.

faces: numpy.ndarray

Alias for field number 1

values: numpy.ndarray

Alias for field number 2

verts: numpy.ndarray

Alias for field number 0

magicclass.ext.vispy.layerlist module

class magicclass.ext.vispy.layerlist.LayerList(data=())[source]

Bases: psygnal.containers._evented_list.EventedList[magicclass.ext.vispy._base.LayerItem]

events: ListEvents

magicclass.ext.vispy.plot_api module

magicclass.ext.vispy.plot_api.figure()[source]
magicclass.ext.vispy.plot_api.gca()[source]
magicclass.ext.vispy.plot_api.gcf()[source]
magicclass.ext.vispy.plot_api.imshow(image, cmap=None, vmin=None, vmax=None)[source]
magicclass.ext.vispy.plot_api.plot(x=None, y=None, face_color=None, edge_color=None, color=None, size: float = 7, name: str | None = None, lw: float = 1, ls: str = '-', symbol=None) VispyPlotCanvas[source]
magicclass.ext.vispy.plot_api.scatter(x=None, y=None, face_color=None, edge_color=None, color=None, size: float = 7, name: str | None = None, symbol=None) VispyPlotCanvas[source]
magicclass.ext.vispy.plot_api.show()[source]
magicclass.ext.vispy.plot_api.subplot(pos: int)[source]
magicclass.ext.vispy.plot_api.subplot(row: int, col: int, idx: int)

magicclass.ext.vispy.widgets2d module

class magicclass.ext.vispy.widgets2d.Has2DViewBox(viewbox: vispy.scene.widgets.viewbox.ViewBox)[source]

Bases: magicclass.ext.vispy._base.HasViewBox

add_curve(x=None, y=None, face_color=None, edge_color=None, color=None, size: float = 7, name: str | None = None, lw: float = 1, ls: str = '-', symbol=None)[source]

Add a line plot like plt.plot(x, y).

Parameters
  • x (array-like) --

    X data.

    y : array-like

    Y data.

    face_color: str or array-like, optional

    Face color of plot. Graphic object will be filled with this color.

    edge_color: str or array-like, optional

    Edge color of plot.

    color: str or array-like, optional

    Set face color and edge color at the same time.

  • size (float, default is 7) -- Symbol size.

  • name (str, optional) --

    Object name of the plot item.

    lw: float, default is 1.0

    Line width of edge.

    ls: str, default is "-"

    Line style of edge. One of "-", "--", ":" or "-.".

    symbol: str, optional

    Symbol style. Currently supports circle ("o"), cross ("+", "x"), star ("*"), square ("s", "D") triangle ("^", "<", "v", ">") and others that pyqtgraph supports.

Returns

A plot item of a curve.

Return type

Curve

add_hist(data, bins: int = 10, face_color=None, edge_color=None, color=None, name: str | None = None) Histogram[source]
add_scatter(x=None, y=None, face_color=None, edge_color=None, color=None, size: float = 7, name: str | None = None, symbol=None)[source]

Add a line plot like plt.plot(x, y).

Parameters
  • x (array-like) --

    X data.

    y : array-like

    Y data.

    face_color: str or array-like, optional

    Face color of plot. Graphic object will be filled with this color.

    edge_color: str or array-like, optional

    Edge color of plot.

    color: str or array-like, optional

    Set face color and edge color at the same time.

  • size (float, default is 7) -- Symbol size.

  • name (str, optional) --

    Object name of the plot item.

    symbol: str, optional

    Symbol style. Currently supports circle ("o"), cross ("+", "x"), star ("*"), square ("s", "D") triangle ("^", "<", "v", ">") and others that pyqtgraph supports.

Returns

A plot item of a curve.

Return type

Curve

property xrange: tuple[float, float]

Range of X dimension.

property yrange: tuple[float, float]

Range of Y dimension.

class magicclass.ext.vispy.widgets2d.ImageItem(viewbox: ViewBox | None = None, lock_contrast_limits: bool = False)[source]

Bases: magicclass.ext.vispy.widgets2d.Has2DViewBox

property cmap
property contrast_limits: tuple[float, float]

Contrast limits of the image.

property image
property title: str

The title string.

property xlabel: str

The x-label string.

property ylabel: str

The x-label string.

class magicclass.ext.vispy.widgets2d.PlotItem(viewbox: vispy.scene.widgets.viewbox.ViewBox)[source]

Bases: magicclass.ext.vispy.widgets2d.Has2DViewBox

property title: str

The title string.

property xlabel: str

The x-label string.

property ylabel: str

The x-label string.

class magicclass.ext.vispy.widgets2d.VispyImageCanvas(**kwargs)[source]

Bases: magicclass.widgets.utils.FreeWidget, magicclass.ext.vispy.widgets2d.ImageItem

A Vispy based 2-D plot canvas for images.

class magicclass.ext.vispy.widgets2d.VispyMultiImageCanvas(nrows: int = 1, ncols: int = 1)[source]

Bases: magicclass.ext.vispy._base.MultiPlot

A multiple Vispy based 2-D plot canvas for images.

class magicclass.ext.vispy.widgets2d.VispyMultiPlotCanvas(nrows: int = 1, ncols: int = 1)[source]

Bases: magicclass.ext.vispy._base.MultiPlot

A multiple Vispy based 2-D plot canvas.

class magicclass.ext.vispy.widgets2d.VispyPlotCanvas(**kwargs)[source]

Bases: magicclass.widgets.utils.FreeWidget, magicclass.ext.vispy.widgets2d.PlotItem

A Vispy based 2-D plot canvas for curve, histogram, bar plot etc.

magicclass.ext.vispy.widgets3d module

class magicclass.ext.vispy.widgets3d.Has3DViewBox(viewbox: vispy.scene.widgets.viewbox.ViewBox)[source]

Bases: magicclass.ext.vispy._base.HasViewBox

A Vispy canvas for 3-D object visualization.

Very similar to napari. This widget can be used independent of napari, or as a mini-viewer of napari.

add_curve(data: Union[numpy._typing._array_like._SupportsArray[numpy.dtype], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype]], bool, int, float, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]], color='white', width=1)[source]
add_image(data: ArrayLike, *, contrast_limits: tuple[float, float] = None, rendering: str = 'mip', iso_threshold: float | None = None, attenuation: float = 1.0, cmap: str = 'grays', gamma: float = 1.0, interpolation: str = 'linear')[source]
add_isosurface(data: ArrayLike, *, contrast_limits: tuple[float, float] | None = None, iso_threshold: float | None = None, face_color: Color | None = None, edge_color: Color | None = None, shading: str = 'smooth')[source]
add_layer(layer: magicclass.ext.vispy._base.LayerItem)[source]

Add a layer item to the canvas.

add_surface(data: tuple[ArrayLike, ArrayLike] | tuple[ArrayLike, ArrayLike, ArrayLike], *, face_color: Color | None = None, edge_color: Color | None = None, shading: str = 'smooth')[source]
property camera: magicclass.ext.vispy.camera.Camera

Return the native camera.

property layers

Return the layer list.

class magicclass.ext.vispy.widgets3d.Vispy3DCanvas[source]

Bases: magicclass.widgets.utils.FreeWidget, magicclass.ext.vispy.widgets3d.Has3DViewBox

A Vispy based 3-D canvas.

class magicclass.ext.vispy.widgets3d.VispyMulti3DCanvas(nrows: int = 1, ncols: int = 1)[source]

Bases: magicclass.ext.vispy._base.MultiPlot

A multiple Vispy based 3-D canvas.

Module contents

class magicclass.ext.vispy.Vispy3DCanvas[source]

Bases: magicclass.widgets.utils.FreeWidget, magicclass.ext.vispy.widgets3d.Has3DViewBox

A Vispy based 3-D canvas.

class magicclass.ext.vispy.VispyImageCanvas(**kwargs)[source]

Bases: magicclass.widgets.utils.FreeWidget, magicclass.ext.vispy.widgets2d.ImageItem

A Vispy based 2-D plot canvas for images.

class magicclass.ext.vispy.VispyMulti3DCanvas(nrows: int = 1, ncols: int = 1)[source]

Bases: magicclass.ext.vispy._base.MultiPlot

A multiple Vispy based 3-D canvas.

class magicclass.ext.vispy.VispyMultiImageCanvas(nrows: int = 1, ncols: int = 1)[source]

Bases: magicclass.ext.vispy._base.MultiPlot

A multiple Vispy based 2-D plot canvas for images.

class magicclass.ext.vispy.VispyMultiPlotCanvas(nrows: int = 1, ncols: int = 1)[source]

Bases: magicclass.ext.vispy._base.MultiPlot

A multiple Vispy based 2-D plot canvas.

class magicclass.ext.vispy.VispyPlotCanvas(**kwargs)[source]

Bases: magicclass.widgets.utils.FreeWidget, magicclass.ext.vispy.widgets2d.PlotItem

A Vispy based 2-D plot canvas for curve, histogram, bar plot etc.