erlab.interactive.imagetool¶
Interactive visualization tool for multidimensional image-like data.
Modules¶
Provides core functionality of ImageTool. |
|
Linking and history decorators for ImageTool viewer widgets. |
|
State and input parsing helpers for ImageTool viewer widgets. |
|
Helper functions for fast slicing |
|
Helpers for fast slicing of 2D, 3D, and 4D arrays. |
|
Fast parallelized averaging for multidimensional arrays. |
|
Widgets for controlling ImageTool slicers. |
|
Dialogs for data manipulation found in the menu bar. |
|
Manager for multiple ImageTool windows. |
|
Public ImageTool provenance API. |
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
- duplicate(**kwargs)[source]¶
Create a duplicate of the current ImageTool window.
This method creates a new instance of the ImageTool with the same data and state as the current one.
- Parameters:
kwargs – Additional keyword arguments passed to the constructor of the new ImageTool.
- Returns:
tool– The duplicated ImageTool window.- Return type:
- 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 provenance_spec: ToolProvenanceSpec | None¶
Canonical replay provenance for the current ImageTool data.
- set_provenance_spec(provenance_spec)[source]¶
Set canonical replay provenance for the current ImageTool data.
- property slicer_area: ImageSlicerArea¶
class:
ImageSlicerArea.- Type:
The underlying
- to_file(filename)[source]¶
Save the data, state, title, and geometry of the tool to a file.
The saved netcdf dataset can be used to recreate the ImageTool with the class method
from_file().
- 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, replace=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.
-
If the Dataset contains multiple displayable DataArrays, ImageTool asks which variables to open. 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. If the DataTree contains multiple displayable DataArrays, ImageTool asks which variables to open, grouped by DataTree node path.
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|int|None, default:None) –Whether to open the ImageTool window(s) using the
ImageToolManagerif it is running. An integer targets a specific 0-based manager index. IfTrue, the current process default manager is used, or the only live manager if no default is set. If multiple managers are live and no default has been selected, an error is raised. 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.Changed in version 3.22.0: Integer manager indexes select a specific ImageTool Manager instance.
replace (
Collection[int] |int|None, default:None) –When using the manager, this argument specifies which existing ImageTool windows should be replaced with the new data. If the manager is not used, this argument is ignored.
replacecan be set to:None(default): no existing windows are replaced. New windows are created for the new data.A single integer: this can be a valid existing index (replace that window), one greater than the current largest index (create a new window), or a negative index from the end (for example,
-1means the largest existing index).A list of integers: each integer is interpreted as described above. The list length must match the number of windows
datais expected to create.
If this argument is used, the
link,link_colors, andkwargsarguments are ignored, since no new windows are created.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.viewer.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)