twocan.pick_best_registration
- twocan.pick_best_registration(study_df)[source]
Calculate triangle score and return best trial from optimization results.
This function implements a balanced scoring approach for selecting the best registration trial from a set of optimization results. It combines three key metrics (logical AND, IoU, and correlation) using a triangular scoring scheme that balances all three aspects of registration quality.
The triangle score is calculated as:
(1/3) * |norm_and * norm_corr + norm_corr * norm_iou + norm_iou * norm_and|
where each metric is normalized to [0,1] within the group.
- Parameters:
study_df (pd.DataFrame) – DataFrame containing trial results with required columns: - ‘user_attrs_logical_and’: Logical AND overlap between images - ‘user_attrs_logical_iou’: Intersection over Union score - ‘user_attrs_reg_image_max_corr’: Maximum correlation between channels
- Returns:
DataFrame row containing the trial with the highest balanced score. The returned series includes all original columns plus computed normalization columns and the final ‘balanced_score’.
- Return type:
pd.Series
Notes
The logical AND values are log-transformed before normalization because they typically span several orders of magnitude. The triangle score approach ensures that no single metric dominates the selection, leading to more robust registration quality assessment.
Missing or NaN values in any of the required columns will result in NaN normalized scores, which may affect the final ranking.