This module provides a window to view a 3D scalar field.
It supports iso-surfaces, a cutting plane and the definition of a region of interest.
For sample code using ScalarFieldView, see viewer3DVolume.py
Bases: silx.gui.plot3d.Plot3DWindow.Plot3DWindow
Widget computing and displaying an iso-surface from a 3D scalar dataset.
Limitation: Currently, iso-surfaces are generated with higher values than the iso-level ‘inside’ the surface.
Parameters: | parent – See QMainWindow |
---|
Signal emitted when the scalar data field has changed.
Signal emitted when the selected region has changed.
This signal provides the new selected region.
Saves this view state. Only isosurfaces at the moment. Does not save the isosurface’s function.
Parameters: | ioDevice (qt.QIODevice) – A qt.QIODevice. |
---|
Loads this view state. See ScalarFieldView.saveView to know what is supported at the moment.
Parameters: | ioDevice (qt.QIODevice) – A qt.QIODevice. |
---|
Choose the current interaction.
Parameters: | mode (str) – Either plane or camera |
---|
Returns the current interaction mode, see setInteractiveMode()
Set the 3D scalar data set to use for building the iso-surface.
Dataset order is zyx (i.e., first dimension is z).
Parameters: |
|
---|
Get the 3D scalar data currently used to build the iso-surface.
Parameters: | copy (bool) – True (default) to get a copy, False to get the internal data (DO NOT modify!) |
---|---|
Returns: | The data set (or None if not set) |
Set the scale of the 3D scalar field (i.e., size of a voxel).
Parameters: |
|
---|
Returns the scales provided by setScale() as a numpy.ndarray.
Set the translation of the origin of the data array in data coordinates.
Parameters: |
|
---|
Returns the offset set by setTranslation() as a numpy.ndarray.
Set the text labels of the axes.
Parameters: |
|
---|
Returns the text labels of the axes
>>> widget = ScalarFieldView()
>>> widget.setAxesLabels(xlabel='X')
You can get the labels either as a 3-tuple:
>>> xlabel, ylabel, zlabel = widget.getAxesLabels()
Or as an object with methods getXLabel, getYLabel and getZLabel:
>>> labels = widget.getAxesLabels()
>>> labels.getXLabel()
... 'X'
Returns: | object describing the labels |
---|
Set the foreground color.
Parameters: | color (QColor, str or array-like of 3 or 4 float in [0., 1.] or uint8) – RGB color: name, #RRGGBB or RGB values |
---|
Set hightlighted item color.
Parameters: | color (QColor, str or array-like of 3 or 4 float in [0., 1.] or uint8) – RGB color: name, #RRGGBB or RGB values |
---|
Return an iterable of all cut planes of the view.
This includes hidden cut planes.
For now, there is always one cut plane.
Set the 3D selected region aligned with the axes.
Provided range are array indices range. The provided ranges are clipped to the data. If a range is None, the range of the array on this dimension is used.
Parameters: |
|
---|
Signal emitted when a new iso-surface is added to the view.
The newly added iso-surface is provided by this signal
Signal emitted when an iso-surface is removed from the view
The removed iso-surface is provided by this signal.
Add an iso-surface to the view.
Parameters: |
|
---|---|
Returns: | Isosurface object describing this isosurface |
Those classes are used by ScalarFieldView.
Bases: object
Description of a colormap
Parameters: |
|
---|
Bases: PyQt4.QtCore.QObject
Class representing a cutting plane
Parameters: | sfView (ScalarFieldView) – Widget in which the cut plane is applied. |
---|
Signal emitted when the cut visibility has changed.
This signal provides the new visibility status.
Signal emitted when the data this plane is cutting has changed.
Signal emitted when the cut plane has moved
Signal emitted when the colormap has changed
This signal provides the new colormap.
Signal emitted when the cut plane interpolation has changed
This signal provides the new interpolation mode.
Returns the normal of the plane (as a unit vector)
Returns: | Normal (nx, ny, nz), vector is 0 if no plane is defined |
---|---|
Return type: | numpy.ndarray |
Set the normal of the plane
Parameters: | normal – 3-tuple of float: nx, ny, nz |
---|
Returns the plane equation parameters: a*x + b*y + c*z + d = 0
Returns: | Plane equation parameters: (a, b, c, d) |
---|---|
Return type: | numpy.ndarray |
Set the visibility of the plane
Parameters: | visible (bool) – True to make plane visible |
---|
Set the color of the plane border.
Parameters: | color (QColor, str or array-like of 3 or 4 float in [0., 1.] or uint8) – RGB color: name, #RRGGBB or RGB values |
---|
Returns the data and information corresponding to the cut plane.
The returned data is not interpolated, it is a slice of the 3D scalar field.
Image data axes are so that plane normal is towards the point of view.
Returns: | An object containing the 2D data slice and information |
---|
Returns the interpolation used to display to cut plane.
Returns: | ‘nearest’ or ‘linear’ |
---|---|
Return type: | str |
Set the interpolation used to display to cut plane
The default interpolation is ‘linear’
Parameters: | interpolation (str) – ‘nearest’ or ‘linear’ |
---|
Returns the colormap set by getColormap().
Returns: | The colormap |
---|---|
Return type: | Colormap |
Set the colormap to use.
Parameters: |
|
---|
Bases: PyQt4.QtCore.QObject
Class representing an iso-surface
Parameters: | parent – The View widget this iso-surface belongs to |
---|
Signal emitted when the iso-surface level has changed.
This signal provides the new level value (might be nan).
Signal emitted when the iso-surface color has changed
Signal emitted when the iso-surface visibility has changed.
This signal provides the new visibility status.
Set the visibility of the iso-surface in the view.
Parameters: | visible (bool) – True to show the iso-surface, False to hide |
---|
Set the value at which to build the iso-surface.
Setting this value reset auto-level function
Parameters: | level (float) – The value at which to build the iso-surface |
---|
Set the function used to compute the iso-level.
WARNING: The function might get called in a thread.
Parameters: | autoLevel (callable) – A function taking a 3D numpy.ndarray of float32 and returning a float used as iso-level. Example: numpy.mean(data) + numpy.std(data) |
---|
Bases: object
Selection of a 3D region aligned with the axis.
Parameters: |
|
---|
Returns array ranges of the selection: 3x2 array of int
Returns: | A numpy array with ((zmin, zmax), (ymin, ymax), (xmin, xmax)) |
---|---|
Return type: | numpy.ndarray |
Slices corresponding to the selected range in the array
Returns: | A numpy array with (zslice, yslice, zslice) |
---|---|
Return type: | numpy.ndarray |
Range in the data coordinates of the selection: 3x2 array of float
Returns: | A numpy array with ((xmin, xmax), (ymin, ymax), (zmin, zmax)) |
---|---|
Return type: | numpy.ndarray |