Skip to content

Add CPD parameter tuning grid search#58

Open
Marei33 wants to merge 4 commits into
devfrom
cpd-parameter-tuning
Open

Add CPD parameter tuning grid search#58
Marei33 wants to merge 4 commits into
devfrom
cpd-parameter-tuning

Conversation

@Marei33

@Marei33 Marei33 commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Adds a standalone Optuna GridSampler-based grid search for tuning CPD (Coherent Point Drift) non-rigid registration parameters. Each parameter combination is scored by the mean Landmark Registration Error (LRE), the average distance (µm) between corresponding anatomical landmarks after CPD registration.

Tuned parameters: w (outlier weight), beta (Gaussian kernel width), lmd (regularization strength).

How it works

New Snakemake workflow workflows/cpd_optimization.smk, separate from the main registration pipeline:

input_to_n5add_landmarksprealignment_with_lmrigid_alignment_with_lmoptimize_cpd

  1. Embed user-provided corresponding landmarks into both segmentations as labeled spheres.
  2. Apply SVD prealignment and rigid alignment (carrying the landmarks).
  3. Optionally derive dataset-specific beta ranges from point spacing / extent (suggest_cpd_ranges.py).
  4. Grid-search CPD params, evaluating each trial by mean LRE; write best_cpd_params.yaml (drop-in for the registration config).

Search space is configurable: default, dataset-specific, or an explicit dict in the config.

Contents

  • matchmaker/cpd_parameter_tuning/cpd_optimization.py, add_landmarks.py, suggest_cpd_ranges.py, default param/range YAMLs, README
  • workflows/cpd_optimization.smk
  • examples/cpd_optimization_config.yaml
  • matchmaker/utils/vis.py — adds plot_landmark_qc (landmark QC plot) and a title param for visualize_displacement_field (used by trial plots)
  • environment.yml — enables optuna

Notes

Merge #57 and #56 first.

@Marei33

Marei33 commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator Author

solves #42

@Marei33 Marei33 marked this pull request as draft June 25, 2026 13:27
@Marei33 Marei33 marked this pull request as ready for review June 26, 2026 08:38
Marei33 and others added 4 commits June 26, 2026 11:18
Optuna GridSampler-based grid search over CPD non-rigid registration
parameters (w, beta, lmd, maxiter), evaluated by mean Landmark
Registration Error (LRE) between corresponding landmarks.

- matchmaker/cpd_parameter_tuning/: optimization, landmark embedding,
  dataset-specific beta-range suggestion, defaults and README
- workflows/cpd_optimization.smk: input_to_n5 -> add_landmarks ->
  prealignment_with_lm -> rigid_alignment_with_lm -> optimize_cpd
- examples/cpd_optimization_config.yaml: example config (nest
  axis_orientation under prealignment to match the workflow/registration
  config convention)
- matchmaker/utils/vis.py: add plot_landmark_qc and a title param for
  visualize_displacement_field (used by the tuning trial plots)
- environment.yml: enable optuna

Stacked on the visualisation branch (#57), which provides the PINK/CYAN
colormaps that add_landmarks imports. Target branch: dev.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Point the example usage at examples/cpd_optimization_config.yaml
  (not the cluster-specific data/brain_matching path)
- Generalize dataset-specific names (Igor/Seymour) and example paths
- Describe landmarks as labeled spheres, not single-voxel labels
- Fix a stray/unclosed backtick in the dataset-specific section

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Marei33 Marei33 force-pushed the cpd-parameter-tuning branch from 50ab1a6 to 63b993c Compare June 26, 2026 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement optimization of CPD parameters based on landmarks or signal correlation

1 participant