playnano.gui.window module

Main GUI window for browsing and exporting HS-AFM image stacks.

Provides: - Frame playback controls (play/pause, slider, FPS). - Raw vs. processed toggling and filter application. - Z-scale histogram with draggable range lines. - Export tabs for GIF, NPZ, OME-TIFF, HDF5.

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: QMainWindow

Main window for the playNano GUI application.

apply_filters()[source]

Apply the selected processing pipeline to the AFM stack.

Builds a ProcessingPipeline from self.processing_steps (or defaults), runs it, updates the flattened data (self._flat), recomputes display ranges, and refreshes the viewer.

Return type:

None

Raises:

RuntimeError – If the processing pipeline fails.

keyPressEvent(ev)[source]

Handle key press events for shortcuts.

Parameters:

ev (QKeyEvent) – The key event to handle.

Return type:

None

Raises:

None –

Notes

Key mapping: Space → toggle play/pause F → apply filters R → toggle raw/processed view G → export GIF E → export data in checked formats

show_frame(idx: int)[source]

Render a specific frame in the viewer.

Parameters:

idx (int) – Index of the frame to display (raw or processed, depending on state).

Return type:

None

Raises:

IndexError – If idx is out of bounds.

staticMetaObject = PySide6.QtCore.QMetaObject("MainWindow" inherits "QMainWindow": )
toggle_play()[source]

Start or stop automatic frame advancement.

If playing, stops the QTimer; if paused, starts it at the current FPS.

Return type:

None

toggle_processed()[source]

Flip between raw and processed (flattened) data views.

If no processed data exists yet, does nothing.

Return type:

None

playnano.gui.window.z_to_rgb(z_value, zmin, zmax, cmap_name='afm_brown')[source]

Map a single height value to an RGB triple via a matplotlib colormap.

Parameters:
  • z_value (float) – Height value to map.

  • zmin (float) – Data range for normalization. If zmax == zmin, returns black.

  • zmax (float) – Data range for normalization. If zmax == zmin, returns black.

  • cmap_name (str, default=DEFAULT_CMAP) – Name of the matplotlib colormap to use.

Returns:

rgb – (R, G, B) values in [0, 255].

Return type:

tuple of int