QWidget displaying a 3D volume as a stack of 2D images.
The StackView class implements this widget.
Basic usage of StackView is through the following methods:
The StackView uses PlotWindow and also exposes a subset of the silx.gui.plot.Plot API for further control (plot title, axes labels, ...).
The StackViewMainWindow class implements a widget that adds a status bar displaying the 3D index and the value under the mouse cursor.
Example:
import numpy
import sys
from silx.gui import qt
from silx.gui.plot.StackView import StackViewMainWindow
app = qt.QApplication(sys.argv[1:])
# synthetic data, stack of 100 images of size 200x300
mystack = numpy.fromfunction(
lambda i, j, k: numpy.sin(i/15.) + numpy.cos(j/4.) + 2 * numpy.sin(k/6.),
(100, 200, 300)
)
sv = StackViewMainWindow()
sv.setColormap("jet", autoscale=True)
sv.setStack(mystack)
sv.setLabels(["1st dim (0-99)", "2nd dim (0-199)",
"3rd dim (0-299)"])
sv.show()
app.exec_()
Stack view widget, to display and browse through stack of images.
The profile tool can be switched to “3D” mode, to compute the profile on each image of the stack (not only the active image currently displayed) and display the result as a slice.
Parameters: |
|
---|
Signals that the data value under the cursor has changed.
It provides: row, column, data value.
Signal emitted when there is a change is perspective/displayed axes.
It provides the perspective as an integer, with the following meaning:
- 0: axis Y is the 2nd dimension, axis X is the 3rd dimension
- 1: axis Y is the 1st dimension, axis X is the 3rd dimension
- 2: axis Y is the 1st dimension, axis X is the 2nd dimension
Signal emitted when the stack is changed. This happens when a new volume is loaded, or when the current volume is transposed (change in perspective).
The signal provides the size (number of pixels) of the stack. This will be 0 if the stack is cleared, else it will be a positive integer.
Set the visibility of the browsing options.
Parameters: | isVisible (bool) – True to have the options visible, else False |
---|
Set the frame selection to a specific value :param int number: Number of the frame
Set the 3D stack.
The perspective parameter is used to define which dimension of the 3D array is to be used as frame index. The lowest remaining dimension number is the row index of the displayed image (Y axis), and the highest remaining dimension is the column index (X axis).
Parameters: |
|
---|
Get the original stack, as a 3D array or dataset.
The output has the form: [data, params] where params is a dictionary containing display parameters.
Parameters: |
|
---|---|
Returns: | 3D stack and parameters. |
Return type: | (numpy.ndarray, dict) |
Get the stack, as it is currently displayed.
The first index of the returned stack is always the frame index. If the perspective has been changed in the widget since the data was first loaded, this will be reflected in the order of the dimensions of the returned object.
The output has the form: [data, params] where params is a dictionary containing display parameters.
Parameters: |
|
---|---|
Returns: | 3D stack and parameters. |
Return type: | (numpy.ndarray, dict) |
Returns the currently active image object.
It returns None in case of not having an active image.
Parameters: | just_legend (bool) – True to get the legend of the image, False (the default) to get the image data and info. Note: StackView uses the same legend for all frames. |
---|---|
Returns: | legend or image object |
Return type: | str or list or None |
Set the plot main title.
Parameters: | title (str) – Main title of the plot (default: ‘’) |
---|
Set the labels to be displayed on the plot axes.
You must provide a sequence of 3 strings, corresponding to the 3 dimensions of the original data volume. The proper label will automatically be selected for each plot axis when the volume is rotated (when different axes are selected as the X and Y axes).
Parameters: | labels (list(str)) – 3 labels corresponding to the 3 dimensions of the data volumes. |
---|
Set the plot horizontal axis label.
Parameters: | label (str) – The horizontal axis label |
---|
Return the current vertical axis label as a str.
Parameters: | axis (str) – The Y axis for which to get the label (left or right) |
---|
Set the vertical axis label on the plot.
Parameters: |
|
---|
Set the Y axis orientation.
Parameters: | flag (bool) – True for Y axis going from top to bottom, False for Y axis going from bottom to top |
---|
Get the supported colormap names as a tuple of str.
The list should at least contain and start by: (‘gray’, ‘reversed gray’, ‘temperature’, ‘red’, ‘green’, ‘blue’)
Get the current colormap description.
Returns: | A description of the current colormap. See setColormap() for details. |
---|---|
Return type: | dict |
Set the colormap and update active image.
Parameters that are not provided are taken from the current colormap.
The colormap parameter can also be a dict with the following keys:
name: string. The colormap to use: ‘gray’, ‘reversed gray’, ‘temperature’, ‘red’, ‘green’, ‘blue’.
normalization: string. The mapping to use for the colormap: either ‘linear’ or ‘log’.
autoscale: bool. Whether to use autoscale (True) or range provided by keys ‘vmin’ and ‘vmax’ (False).
vmin: float. The minimum value of the range to use if ‘autoscale’ is False.
vmax: float. The maximum value of the range to use if ‘autoscale’ is False.
List of RGB or RGBA colors to use (only if name is None)
Parameters: |
|
---|
Set whether the plot keeps data aspect ratio or not.
Parameters: | flag (bool) – True to respect data aspect ratio |
---|
When viewing the last 3 dimensions of an n-D array (n>3), you can use this method to change the text in the combobox.
For instance, for a 7-D array, first stack dim is 4, so the default “Dim1-Dim2” text should be replaced with “Dim5-Dim6” (dimensions numbers are 0-based).
Parameters: | first_stack_dim (int) – First stack dimension (n-3) when viewing the last 3 dimensions of an n-D array. |
---|
Bases: silx.gui.plot.StackView.StackView
This class is a StackView with a menu, an additional toolbar to set the plot limits, and a status bar to display the value and 3D index of the data samples hovered by the mouse cursor.
Parameters: | parent (QWidget) – Parent widget, or None |
---|
Set the displayed stack.
See StackView.setStack() for details.