playnano.io.loader module

Common loader for various high speed AFM video formats and playNano export bundles.

Supported extensions:
  • .jpk (folder)

  • .spm (folder)

  • .h5-jpk (single-file JPK)

  • .asd (single-file ASD)

  • .ome.tif / .tif (OME-TIFF bundles)

  • .npz (playNano NPZ bundles)

  • .h5 (playNano HDF5 bundles)

playnano.io.loader.get_loader_for_file(file_path: Path, file_loaders: dict, folder_loaders: dict) callable[source]

Determine the appropriate loader for a single multi-frame AFM file.

Parameters:
  • file_path (Path) – Path to the file.

  • file_loaders (dict) – Mapping from file extensions to file loader functions.

  • folder_loaders (dict) – Mapping from extensions for folder loaders (for error handling).

Returns:

The file extention string and the loader function for the file.

Return type:

(str, callable)

Raises:

ValueError – If the file type is unsupported or better handled as a folder.

playnano.io.loader.get_loader_for_folder(folder_path: Path, folder_loaders: dict) tuple[str, callable][source]

Determine the appropriate loader for a folder containing AFM data.

Parameters:
  • folder_path (Path) – Path to the folder.

  • folder_loaders (dict) – Mapping from file extension to loader function.

Returns:

The chosen extension and loader function.

Return type:

(str, callable)

Raises:

FileNotFoundError – If no known file types are found.

playnano.io.loader.load_afm_stack(file_path: Path, channel: str = 'height_trace') AFMImageStack[source]

Unified interface to load AFM stacks from various file formats.

High speed AFM videos can be saved as either individual frames within a folder or as multiple frames within a single file. This loader splits these two approaches and loads both into the common AFMImageStack object for processing.

As well as the file formats exported from AFM instruments, this function also read raw and processed exports from playnano (NPZ, OME_TIF and HDF5).

All data values with length units (i.e. m) are converted to nm.

Parameters:
  • file_path (Path | str) – Path to the AFM data file or folder of files.

  • channel (str) – Scan channel name.

Returns:

Loaded image stack with metadata.

Return type:

AFMImageStack