playnano.processing.stack_edit module¶
Functions for removing or selecting frames of an AFM image stack.
Only drop_frames() changes a stack. The other functions return the
indices of the frames to drop; in a
ProcessingPipeline these indices are
passed to drop_frames(), so every edit is recorded the same way in the
provenance. The pipeline also removes the matching entries from the stack’s
frame metadata and keeps a copy of the metadata from before the first edit.
drop_frames()removes the given frames.drop_frame_range()drops the frames fromstartup to, but not including,end.select_frames()keeps only the given frames.drop_final_frames()drops frames from the end (by default, the last one).
- playnano.processing.stack_edit.drop_final_frames(data: ndarray, n_frames_to_drop: int = 1) list[int][source]¶
Return the indices of the last frames of a stack, to drop.
- Parameters:
data (numpy.ndarray) – 3D image stack of shape (n_frames, height, width).
n_frames_to_drop (int, optional) – Number of frames to drop from the end. Default is 1.
- Returns:
Indices of the last
n_frames_to_dropframes (empty if it is 0).- Return type:
- Raises:
ValueError – If
datais not 3D, orn_frames_to_dropis negative or larger than the number of frames.
- playnano.processing.stack_edit.drop_frame_range(data: ndarray, start: int, end: int) list[int][source]¶
Return the indices of a range of frames to drop.
- Parameters:
data (numpy.ndarray) – 3D image stack of shape (n_frames, height, width).
start (int) – First frame to drop (inclusive).
end (int) – Frame after the last one to drop (exclusive).
- Returns:
[start, start + 1, ..., end - 1].- Return type:
- Raises:
ValueError – If
datais not 3D,start < 0,end > n_framesorstart >= end.
- playnano.processing.stack_edit.drop_frames(data: ndarray, indices_to_drop: list[int]) ndarray[source]¶
Remove the given frames from a stack.
- Parameters:
data (numpy.ndarray) – 3D image stack of shape (n_frames, height, width).
indices_to_drop (list of int) – Indices of the frames to remove. Duplicates are ignored; negative indices are not allowed.
- Returns:
A new array without the given frames.
datais not changed.- Return type:
- Raises:
ValueError – If
datais not 3D or an index is outside0 .. n_frames - 1.
- playnano.processing.stack_edit.register_stack_edit_processing() dict[str, Callable][source]¶
Return the built-in stack edit functions.
- Returns:
Maps each step name (str) to its function, for example
"drop_frames"todrop_frames().- Return type:
- playnano.processing.stack_edit.select_frames(data: ndarray, keep_indices: list[int]) list[int][source]¶
Return the indices of the frames to drop so that only the given frames are kept.
- Parameters:
data (numpy.ndarray) – 3D image stack of shape (n_frames, height, width).
keep_indices (list of int) – Indices of the frames to keep. Duplicates are ignored.
- Returns:
Sorted indices of every other frame.
- Return type:
- Raises:
ValueError – If
datais not 3D or an index is outside0 .. n_frames - 1.