magscope.auto_bead_selection#

Attributes#

Exceptions#

AutoBeadSearchCancelled

Raised when auto bead matching is canceled between correlation chunks.

Classes#

Functions#

copy_latest_image(→ numpy.ndarray)

Copy a recent image snapshot in the same orientation shown in the UI.

crop_roi(→ numpy.ndarray)

Return the ROI crop from a viewer-oriented (height, width) image.

normalized_cross_correlation(→ numpy.ndarray)

Compute 2D normalized cross-correlation over valid ROI-sized positions.

_ones_kernel(→ numpy.ndarray)

_correlate2d_valid_chunked(→ numpy.ndarray)

Compute correlate2d(..., mode='valid') in row stripes.

_window_sum_integral(→ numpy.ndarray)

Compute valid sliding-window sums via a summed-area table.

_mark_blocked_roi(→ None)

Mark all top-left positions whose ROI would overlap roi.

normalized_cross_correlation_chunked(→ numpy.ndarray)

Compute 2D normalized cross-correlation over valid ROI-sized positions.

roi_overlaps(→ bool)

roi_is_within_image(→ bool)

filter_candidates_by_score_threshold(...)

default_candidate_score_threshold(→ float)

Choose a default score threshold that favors the strongest score cluster.

detect_matching_beads(→ tuple[numpy.ndarray, ...)

Detect non-overlapping ROI candidates that match the seed ROI template.

run_auto_bead_search_process(→ None)

Serve auto-bead search requests from a temporary worker process.

Module Contents#

magscope.auto_bead_selection._DEFAULT_CORRELATION_CHUNK_ROWS = 20[source]#
magscope.auto_bead_selection._CANDIDATE_PROGRESS_UPDATE_INTERVAL = 512[source]#
magscope.auto_bead_selection._MIN_CANDIDATE_SCORE[source]#
exception magscope.auto_bead_selection.AutoBeadSearchCancelled[source]#

Bases: RuntimeError

Raised when auto bead matching is canceled between correlation chunks.

class magscope.auto_bead_selection.AutoBeadCandidate[source]#
roi: tuple[int, int, int, int][source]#
score: float[source]#
magscope.auto_bead_selection.copy_latest_image(image_bytes: memoryview | bytes | bytearray, image_shape: tuple[int, int], dtype: numpy.dtype) numpy.ndarray[source]#

Copy a recent image snapshot in the same orientation shown in the UI.

magscope.auto_bead_selection.crop_roi(image: numpy.ndarray, roi: tuple[int, int, int, int]) numpy.ndarray[source]#

Return the ROI crop from a viewer-oriented (height, width) image.

magscope.auto_bead_selection.normalized_cross_correlation(image: numpy.ndarray, template: numpy.ndarray) numpy.ndarray[source]#

Compute 2D normalized cross-correlation over valid ROI-sized positions.

magscope.auto_bead_selection._ones_kernel(shape: tuple[int, int]) numpy.ndarray[source]#
magscope.auto_bead_selection._correlate2d_valid_chunked(image: numpy.ndarray, kernel: numpy.ndarray, *, chunk_rows: int, cancel_check: collections.abc.Callable[[], bool] | None = None, progress_callback: collections.abc.Callable[[int, int], None] | None = None) numpy.ndarray[source]#

Compute correlate2d(..., mode='valid') in row stripes.

magscope.auto_bead_selection._window_sum_integral(image: numpy.ndarray, window_shape: tuple[int, int]) numpy.ndarray[source]#

Compute valid sliding-window sums via a summed-area table.

magscope.auto_bead_selection._mark_blocked_roi(blocked_mask: numpy.ndarray, roi: tuple[int, int, int, int], roi_size: tuple[int, int]) None[source]#

Mark all top-left positions whose ROI would overlap roi.

magscope.auto_bead_selection.normalized_cross_correlation_chunked(image: numpy.ndarray, template: numpy.ndarray, *, chunk_rows: int = _DEFAULT_CORRELATION_CHUNK_ROWS, cancel_check: collections.abc.Callable[[], bool] | None = None, progress_callback: collections.abc.Callable[[int, int], None] | None = None) numpy.ndarray[source]#

Compute 2D normalized cross-correlation over valid ROI-sized positions.

magscope.auto_bead_selection.roi_overlaps(roi_a: tuple[int, int, int, int], roi_b: tuple[int, int, int, int]) bool[source]#
magscope.auto_bead_selection.roi_is_within_image(roi: tuple[int, int, int, int], image_shape: tuple[int, int]) bool[source]#
magscope.auto_bead_selection.filter_candidates_by_score_threshold(candidates: Iterable[AutoBeadCandidate], threshold: float) list[AutoBeadCandidate][source]#
magscope.auto_bead_selection.default_candidate_score_threshold(candidates: Iterable[AutoBeadCandidate]) float[source]#

Choose a default score threshold that favors the strongest score cluster.

magscope.auto_bead_selection.detect_matching_beads(image: numpy.ndarray, seed_roi: tuple[int, int, int, int], existing_rois: Iterable[tuple[int, int, int, int]], *, chunk_rows: int = _DEFAULT_CORRELATION_CHUNK_ROWS, cancel_check: collections.abc.Callable[[], bool] | None = None, progress_callback: collections.abc.Callable[[int, int], None] | None = None) tuple[numpy.ndarray, list[AutoBeadCandidate]][source]#

Detect non-overlapping ROI candidates that match the seed ROI template.

magscope.auto_bead_selection.run_auto_bead_search_process(request_queue, result_queue, active_request_id: multiprocessing.sharedctypes.Synchronized, *, chunk_rows: int = _DEFAULT_CORRELATION_CHUNK_ROWS) None[source]#

Serve auto-bead search requests from a temporary worker process.