playnano.io.loader module¶
Load AFM videos from instrument files and from playNano’s own exports.
load_afm_stack() picks a reader from the file extension:
Folders of frames:
.jpk(read_jpk_folder) and.spmor numbered.001,.002… files (read_spm_folder).Single files:
.h5-jpk(read_h5jpk),.asd(read_asd) and.aris(read_aris).playNano exports:
.npz,.h5, and.ome.tif,.ome.tiff,.tifor.tiff(data_loaders).
Extensions are matched without regard to case.
- playnano.io.loader.get_loader_for_file(file_path: Path, file_loaders: dict, folder_loaders: dict) callable[source]¶
Choose the reader for a single file.
- Parameters:
file_path (pathlib.Path) – The file.
file_loaders (dict) – Maps each extension (lower case, with the dot) to its reader. Combined extensions such as
.ome.tifare checked first.folder_loaders (dict) – Extensions of folder formats, used to give a helpful error when a single frame of a folder format is passed.
- Returns:
The extension and its reader.
- Return type:
- Raises:
ValueError – If the file has no extension, an unknown one, or one that belongs to a folder format (for example a single
.jpkframe).
- playnano.io.loader.get_loader_for_folder(folder_path: Path, folder_loaders: dict) tuple[str, callable][source]¶
Choose the folder reader for a folder of frame files.
- Parameters:
folder_path (pathlib.Path) – The folder.
folder_loaders (dict) – Maps each extension (lower case, with the dot) to its reader.
- Returns:
The extension and its reader. If the folder holds several known types,
.jpkis chosen if present, otherwise the most common. Numbered extensions such as.001count as.spm.- Return type:
- Raises:
FileNotFoundError – If the folder contains no file of a known type.
- playnano.io.loader.load_afm_stack(file_path: Path, channel: str = 'height_trace') AFMImageStack[source]¶
Load an AFM video from a file or a folder of frame files.
The reader is chosen from the extension (see the module description). Instrument readers return heights in nm for length channels; see each reader for details.
- Parameters:
file_path (str or pathlib.Path) – The file, or the folder of frame files.
channel (str, optional) – Channel to load, for example
"height_trace"for.h5-jpkfiles. Channel names depend on the format. Ignored for NPZ and HDF5 bundles. Default is"height_trace".
- Returns:
The loaded stack.
- Return type:
- Raises:
FileNotFoundError – If the path does not exist, or a folder contains no known file type.
ValueError – If the file type is not supported.
See also
playnano.afm_stack.AFMImageStack.load_dataThe usual way to call this.