erlab.interactive.imagetool¶
Interactive visualization tool for multidimensional image-like data.
Modules¶
Provides core functionality of ImageTool. |
|
Helper functions for fast slicing |
|
Numba-compiled functions for fast slicing of 2D, 3D, and 4D arrays. |
|
Fast parallelized averaging for multidimensional arrays. |
|
Widgets for controlling |
|
Dialogs for data manipulation found in the menu bar. |
|
Manager for multiple ImageTool windows. |
Functions
|
Create and display ImageTool windows. |
Classes
|
Base class for an ImageTool window. |
|
The ImageTool window class. |
- class erlab.interactive.imagetool.BaseImageTool(data=None, parent=None, **kwargs)[source]¶
Bases:
QMainWindowBase class for an ImageTool window.
This class combines the
ImageSlicerAreaand the controls into a single window.Use this class only if you want to extend ImageTool without the menubar or keyboard shortcuts. Otherwise, use
ImageTool.- Parameters:
data (default:
None) – The data to be displayed.**kwargs – Additional keyword arguments to the underlying
ImageSlicerArea.
- property array_slicer: ArraySlicer¶
class:
ArraySlicer.- Type:
The underlying
- classmethod from_dataset(ds, **kwargs)[source]¶
Restore a window from a dataset saved using
to_dataset().- Parameters:
ds (
Dataset) – The dataset.**kwargs – Additional keyword arguments passed to the constructor.
- classmethod from_file(filename, **kwargs)[source]¶
Restore a window from a file saved using
to_file().
- property slicer_area: ImageSlicerArea¶
class:
ImageSlicerArea.- Type:
The underlying
- class erlab.interactive.imagetool.ImageTool(data=None, **kwargs)[source]¶
Bases:
BaseImageToolThe ImageTool window class.
This class adds the menubar with keyboard shortcuts to
BaseImageTool. Use this class to create an ImageTool window.Instead of instantiating this class directly, users should use the convenience function
itool.- Parameters:
data (default:
None) – The data to be displayed.**kwargs – Additional keyword arguments to
BaseImageTool.
- Signals:
sigTitleChanged(str) – Emitted when the title of the window is changed by setting a new data or file. It is not emitted when the title is changed by other means such as
setWindowTitle().
- property mnb: ItoolMenuBar¶
- erlab.interactive.imagetool.itool(data, *, link=False, link_colors=True, manager=None, execute=None, **kwargs)[source]¶
Create and display ImageTool windows.
This tool can also conveniently accessed with
xarray.DataArray.qshow()andxarray.Dataset.qshow().- Parameters:
data (
DataArray,Dataset,DataTree,numpy.ndarray,listofDataArrayorlistofnumpy.ndarray) –The data to be displayed. Data can be provided as:
A
xarray.DataArraywith 2 to 4 dimensionsThe DataArray will be displayed in an ImageTool window.
A numpy array with 2 to 4 dimensions
The array will be converted to a DataArray and displayed in an ImageTool.
A list of the above objects
Multiple ImageTool windows will be created and displayed.
-
Every DataArray in the Dataset will be displayed across multiple ImageTool windows. Data variables that have less than 2 dimensions or more than 4 dimensions are ignored. Dimensions with length 1 are automatically squeezed.
-
Every leaf node will be parsed as a
xarray.Dataset.
link (
bool, default:False) – Whether to enable linking between multiple ImageTool windows whendatais a sequence or axarray.Dataset, by defaultFalse.link_colors (
bool, default:True) – Whether to link the color maps between multiple linked ImageTool windows, by defaultTrue. This argument has no effect iflinkis set toFalse.manager (
bool|None, default:None) –Whether to open the ImageTool window(s) using the
ImageToolManagerif it is running. If not provided, the manager will only be used if it is in the same process as the caller.Changed in version 3.4.0: Argument renamed from
use_managertomanager.execute (
bool|None, default:None) –Whether to execute the Qt event loop and display the window, by default
None. For more information, seeerlab.interactive.utils.setup_qapp().This argument has no effect when the ImageTool window(s) are opened in the manager.
**kwargs – Additional keyword arguments to be passed onto the underlying slicer area. For a full list of supported arguments, see the
erlab.interactive.imagetool.core.ImageSlicerAreadocumentation.
- Returns:
ImageToolorlistofImageToolorNone– The created ImageTool window(s).If the window(s) are executed, the function will return
None, since the event loop will prevent the function from returning until the window(s) are closed.If the window(s) are not executed, for example while running in an IPython shell with
%gui qt, the function will not block and return the ImageTool window(s) or a list of ImageTool windows depending on the input data.The function will also return
Noneif the windows are opened in theImageToolManager.- Return type:
Examples
>>> itool(data, cmap="gray", gamma=0.5) >>> itool([data1, data2], link=True)