Vizualization

Contents

2. Vizualization#

Functions to help visualize datasets.

mbo_utilities.graphics.run_gui(data_in: str | Path | None = None, roi: int | tuple[int, ...] | None = None, widget: bool = True, metadata_only: bool = False, select_only: bool = False)#

Open a GUI to preview data of any supported type.

Works both as a CLI command and as a Python function for Jupyter/scripts. In Jupyter, returns the ImageWidget so you can interact with it. In standalone mode, runs the event loop (blocking).

Parameters:
data_instr, Path, optional

Path to data file or directory. If None, shows file selection dialog.

roiint, tuple of int, optional

ROI index(es) to display. None shows all ROIs for raw files.

widgetbool, default True

Enable PreviewDataWidget for raw ScanImage tiffs.

metadata_onlybool, default False

If True, only show metadata inspector (no image viewer).

select_onlybool, default False

If True, only show file selection dialog and return the selected path. Does not load data or open the image viewer.

Returns:
ImageWidget, Path, or None

In Jupyter: returns the ImageWidget (already shown via iw.show()). In standalone: returns None (runs event loop until closed). With select_only=True: returns the selected path (str or Path).

Examples

From Python/Jupyter: >>> from mbo_utilities.graphics import run_gui >>> # Option 1: Just show the GUI >>> run_gui(“path/to/data.tif”) >>> # Option 2: Get reference to manipulate it >>> iw = run_gui(“path/to/data.tif”, roi=1, widget=False) >>> iw.cmap = “viridis” # Change colormap >>> # Option 3: Just get file path from dialog >>> path = run_gui(select_only=True) >>> print(f”Selected: {path}”)

From command line: $ mbo path/to/data.tif $ mbo path/to/data.tif –roi 1 –no-widget $ mbo path/to/data.tif –metadata-only $ mbo –select-only # Just open file dialog