playnano.processing.stack_edit module¶
Functions for editing AFM image stacks by removing or selecting frames.
These functions are designed to be called by the ProcessingPipeline, which handles provenance tracking and updates to the AFMImageStack object. The functions here operate purely on data arrays or frame index lists.
Only ‘drop_frames’ performs actual stack edits. Other registered stack_edit functions return indices to drop, which are then passed to ‘drop_frames’ to ensure consistent provenance tracking.
Functions¶
drop_frames : Remove specific frames from a 3D array.
drop_frame_range : Generate a list of frame indices to drop within a given range.
select_frames : Generate a list of frame indices to drop, keeping only the selected frames.
- playnano.processing.stack_edit.drop_frame_range(data: ndarray, start: int, end: int) list[int][source]¶
Generate indices to drop within a given range of frames.
- Parameters:
- Returns:
List of indices that should be dropped.
- Return type:
- Raises:
ValueError – If the range is invalid or out of bounds.
- playnano.processing.stack_edit.drop_frames(data: ndarray, indices_to_drop: list[int]) ndarray[source]¶
Remove specific frames from a 3D array.
- Parameters:
- Returns:
New array with the specified frames removed.
- Return type:
np.ndarray
- Raises:
ValueError – If any provided indices are out of bounds or if data is not 3D.
Notes
The function does not modify the input array in place.
The ProcessingPipeline is responsible for updating metadata and provenance.
- playnano.processing.stack_edit.register_stack_edit_processing() dict[str, Callable][source]¶
Return a dictionary of registered stack editing processing filters.
Keys are names of the operations, values are the functions themselves. drop_frames is the operational function takes a 3D stack (n_frames, H, W) and a list of indicies and returns a ndarray. drop_frame_range and select_frames are helper functions that return lists of indices to drop which can be passed to drop_frames.
- playnano.processing.stack_edit.select_frames(data: ndarray, keep_indices: list[int]) list[int][source]¶
Generate a list of frame indices to drop, keeping only the selected frames.
- Parameters:
- Returns:
List of frame indices that should be dropped.
- Return type:
- Raises:
ValueError – If keep_indices contains out-of-range values.