playnano.gui.window module¶
The playNano main window: playback, processing, colour scale and export.
See the GUI page of the user guide for how to use it.
- class playnano.gui.window.MainWindow(afm_stack: AFMImageStack, processing_steps: list[tuple[str, dict]] | None = None, output_dir: str | None = None, output_name: str = '', scale_bar_nm: int = 100, zmin: str = 'auto', zmax: str = 'auto', cmap: str = 'afm_brown', fps: float = 5.0)[source]¶
Bases:
QMainWindowWindow for playing, processing and exporting an AFM stack.
Usually opened with
playnano.gui.main.gui_entry(). The window has:the frame view, with optional time, scale bar and a “RAW” label when the unprocessed data is shown;
play/pause, a frame slider and the playback rate;
Apply Filters (F), which runs the processing steps (or, if none were given, a built-in default pipeline:
playnano.utils.constants.default_steps_with_kwargs), and Toggle Raw/Processed (R);a histogram of heights with draggable colour scale limits, number boxes and Auto (1st and 99th percentiles);
a colormap list;
an Export tab: animated exports (GIF, MP4, AVI, PNG folder; G writes only the GIF) and data exports (NPZ, OME-TIFF, HDF5; E), of the raw or processed data. All formats are ticked at the start.
If the stack already has
processed["raw"](for example a saved processed bundle), the window opens on the processed data and R shows the raw data.- Parameters:
afm_stack (AFMImageStack) – The stack to show. Applying filters changes it.
processing_steps (list of tuple, optional) – Processing steps, as
(name, parameters), run by Apply Filters. If None or empty, the default pipeline is used. Default is None.output_dir (str, optional) – Folder for exports. If None,
./output. Default is None.output_name (str, optional) – Start of the exported file names. If empty, the name of the file the stack was loaded from. Default is
"".scale_bar_nm (int, optional) – Scale bar length, in nm; 0 opens the window with the scale bar off (it is 100 nm if switched on). Default is 100.
zmin (float or str, optional) – Initial colour scale limits: a number,
"auto"or None. Default is"auto".zmax (float or str, optional) – Initial colour scale limits: a number,
"auto"or None. Default is"auto".cmap (str, optional) – Initial colormap. Names not in the window’s list are replaced by
"afm_brown", with a warning. Default is"afm_brown".fps (float, optional) – Initial playback rate, also used for animated exports. Default is 5.0.
- Raises:
ValueError – If
zminorzmaxis not a number,"auto"or None, orzminis greater thanzmax.
- apply_filters()[source]¶
Run the processing steps on the stack and show the result (F).
Uses the steps given to the window, or the default pipeline (
playnano.utils.constants.default_steps_with_kwargs) if there are none. The steps run onAFMImageStack.dataas it is, so pressing F again processes the already processed data again. The colour scale is worked out again for the processed data, and processed exports are enabled.- Raises:
Exception – Any error from the processing pipeline.
- keyPressEvent(ev)[source]¶
Handle the keyboard shortcuts.
Space plays or pauses, F applies the processing, R switches between raw and processed data, G exports a GIF and E exports the ticked data formats. Other keys are passed to Qt.
- Parameters:
ev (PySide6.QtGui.QKeyEvent) – The key press.
- show_frame(idx: int)[source]¶
Show one frame, with its time and scale bar.
- Parameters:
idx (int) – Frame index. The raw or processed frame is shown, depending on the current view.
- Raises:
IndexError – If
idxis out of range.
- staticMetaObject = PySide6.QtCore.QMetaObject("MainWindow" inherits "QMainWindow": )¶