linumpy.metrics.collectors#
Step-specific metric collectors for pipeline stages.
Each collect_* function records the relevant metrics for a single pipeline
step, saves the JSON file, and returns the populated PipelineMetrics.
Functions#
|
Collect metrics for intensity normalization step. |
|
Collect metrics for XY transform estimation step. |
|
Collect metrics for pairwise registration step. |
|
Collect metrics for interface cropping step. |
|
Collect metrics for PSF compensation step. |
|
Collect metrics for slice stacking step. |
|
Collect aggregate metrics for the slice-quality assessment step. |
|
Collect aggregate metrics for the rehoming-detection step. |
|
Collect aggregate metrics for the auto-exclude step. |
|
Collect aggregate metrics for the common-space alignment step. |
|
Collect aggregate metrics for the slice-interpolation finalise step. |
|
Collect metrics for 3D tile stitching step. |
Module Contents#
- linumpy.metrics.collectors.collect_normalization_metrics(vol_normalized, agarose_mask, otsu_threshold, background_thresholds, output_path, input_path=None, params=None)[source]#
Collect metrics for intensity normalization step.
- Parameters:
vol_normalized (np.ndarray) – The normalized volume.
agarose_mask (np.ndarray) – The agarose mask used.
otsu_threshold (float) – Otsu threshold computed.
background_thresholds (np.ndarray) – Background thresholds per slice.
output_path (str or Path) – Path to the output file.
input_path (str, optional) – Path to the input image.
params (dict, optional) – Dictionary of parameters used.
- Returns:
Metrics object (already saved).
- Return type:
- linumpy.metrics.collectors.collect_xy_transform_metrics(transform, tile_pairs_used, tile_shape, residuals, output_path, input_paths=None, params=None, n_tiles_x=None, n_tiles_y=None)[source]#
Collect metrics for XY transform estimation step.
- Parameters:
transform (np.ndarray) – The estimated 2x2 transform matrix.
tile_pairs_used (int) – Number of tile pairs used for estimation.
tile_shape (tuple) – Tile shape (rows, cols).
residuals (np.ndarray) – Residuals from least squares fit.
output_path (str or Path) – Path to the output transform file.
input_paths (list, optional) – List of input image paths.
params (dict, optional) – Dictionary of parameters used.
n_tiles_x (int, optional) – Number of tiles in the X (column) direction.
n_tiles_y (int, optional) – Number of tiles in the Y (row) direction.
- Returns:
Metrics object (already saved).
- Return type:
- linumpy.metrics.collectors.collect_pairwise_registration_metrics(registration_error, tx, ty, rotation_deg, best_z_index, expected_z_index, output_path, fixed_path=None, moving_path=None, params=None, z_correlation=0.0)[source]#
Collect metrics for pairwise registration step.
- Parameters:
registration_error (float) – Registration error value.
tx (float) – Translation in X and Y.
ty (float) – Translation in X and Y.
rotation_deg (float) – Rotation in degrees.
best_z_index (int) – Best matching z-index.
expected_z_index (int) – Expected z-index based on slice interval.
output_path (str or Path) – Path to the output directory.
fixed_path (str, optional) – Paths to fixed and moving volumes.
moving_path (str, optional) – Paths to fixed and moving volumes.
params (dict, optional) – Dictionary of parameters used.
z_correlation (float, optional) – Normalized cross-correlation score from Z-matching (0-1). Higher values indicate a reliable Z-match between the two slices.
- Returns:
Metrics object (already saved).
- Return type:
- linumpy.metrics.collectors.collect_interface_crop_metrics(detected_interface, crop_depth_px, start_idx, end_idx, input_shape, output_shape, resolution_um, output_path, input_path=None, padding_needed=False)[source]#
Collect metrics for interface cropping step.
- Parameters:
detected_interface (int) – Detected interface depth in voxels.
crop_depth_px (int) – Cropping depth in voxels.
start_idx (int) – Start and end indices for cropping.
end_idx (int) – Start and end indices for cropping.
input_shape (tuple) – Input and output volume shapes.
output_shape (tuple) – Input and output volume shapes.
resolution_um (float) – Resolution in microns.
output_path (str or Path) – Path to the output file.
input_path (str, optional) – Path to the input file.
padding_needed (bool) – Whether padding was required.
- Returns:
Metrics object (already saved).
- Return type:
- linumpy.metrics.collectors.collect_psf_compensation_metrics(psf, agarose_coverage, output_path, input_path=None, fit_gaussian=False)[source]#
Collect metrics for PSF compensation step.
- Parameters:
- Returns:
Metrics object (already saved).
- Return type:
- linumpy.metrics.collectors.collect_stack_metrics(output_shape, z_offsets, num_slices, resolution, output_path, blend_enabled=False, normalize_enabled=False, z_matches_df=None, decisions_df=None)[source]#
Collect metrics for slice stacking step.
- Parameters:
output_shape (tuple) – Final output shape.
z_offsets (np.ndarray) – Z-offsets between consecutive slices.
num_slices (int) – Number of slices stacked.
resolution (list) – Output resolution.
output_path (str or Path) – Path to the output file.
blend_enabled (bool) – Whether blending was enabled.
normalize_enabled (bool) – Whether normalization was enabled.
z_matches_df (pandas.DataFrame, optional) – Per-pair z-match diagnostics with at least a
correlationcolumn.decisions_df (pandas.DataFrame, optional) – Per-slice stacking decisions with optional columns
transform_loaded,manual_override,overlap_source.
- Returns:
Metrics object (already saved).
- Return type:
- linumpy.metrics.collectors.collect_quality_assessment_metrics(output_path, quality_results, excluded_ids, min_quality)[source]#
Collect aggregate metrics for the slice-quality assessment step.
- Parameters:
output_path (Path) – Path to the slice_config CSV that was written.
quality_results (dict) – Mapping
slice_id -> per-slice quality dict(with at least anoverallfield).excluded_ids (list of int) – Slices marked as excluded by the quality assessment.
min_quality (float) – Threshold used to flag low-quality slices.
- Return type:
- linumpy.metrics.collectors.collect_rehoming_metrics(output_path, n_total_transitions, tile_corrected_indices, spike_corrected_indices, n_unreliable, max_correction_mm=None)[source]#
Collect aggregate metrics for the rehoming-detection step.
- Parameters:
- Return type:
- linumpy.metrics.collectors.collect_auto_exclude_metrics(output_path, num_total_slices, excluded_ids, cluster_count, z_corr_threshold, consecutive_threshold)[source]#
Collect aggregate metrics for the auto-exclude step.
- Parameters:
- Return type:
- linumpy.metrics.collectors.collect_common_space_metrics(output_dir, n_selected_slices, n_excluded_slices, n_unreliable, n_refined_image_based, n_refined_rejected, refine_discrepancies_px=None)[source]#
Collect aggregate metrics for the common-space alignment step.
- Parameters:
- Return type:
- linumpy.metrics.collectors.collect_slice_interpolation_metrics(output_path, n_fragments, interpolated_ids, failed_ids, fallback_reasons=None, method_counts=None)[source]#
Collect aggregate metrics for the slice-interpolation finalise step.
- linumpy.metrics.collectors.collect_stitch_3d_metrics(input_shape, output_shape, num_tiles, resolution, output_path, input_path=None, blending_method='diffusion')[source]#
Collect metrics for 3D tile stitching step.
- Parameters:
input_shape (tuple) – Input mosaic grid shape.
output_shape (tuple) – Output stitched volume shape.
num_tiles (int) – Number of tiles stitched.
resolution (list) – Output resolution.
output_path (str or Path) – Path to the output file.
input_path (str, optional) – Path to the input file.
blending_method (str) – Blending method used.
- Returns:
Metrics object (already saved).
- Return type: