Registration
register(msims, transform_key=None, points_key='beads', prefilter_markers=False, reg_channel_index=None, reg_channel=None, new_transform_key=None, registration_binning=None, reg_res_level=None, overlap_tolerance=0.0, pairwise_reg_func=phase_correlation_registration, pairwise_reg_func_kwargs=None, groupwise_resolution_method='global_optimization', groupwise_resolution_kwargs=None, pre_registration_pruning_method='alternating_pattern', pre_reg_pruning_method_kwargs=None, post_registration_do_quality_filter=False, post_registration_quality_threshold=0.2, plot_summary=False, pairs=None, scheduler=None, n_parallel_pairwise_regs=None, return_dict=False)
Register a list of views to a common extrinsic coordinate system.
High-level flow: 1) Build the overlap graph. 2) Run pairwise registrations for selected edges. 3) Resolve global transforms from the pairwise results.
Parameters
msims : list of MultiscaleSpatialImage
Input views
reg_channel_index : int, optional
Index of channel to be used for registration, by default None
reg_channel : str, optional
Name of channel to be used for registration, by default None
Overrides reg_channel_index
transform_key : str, optional
Extrinsic coordinate system to use as a starting point
for the registration, by default None
points_key : str, optional
Named point set to use for marker-aware pairwise registration functions.
prefilter_markers : bool, optional
If True, restrict markers to each pairwise overlap before marker-based
pairwise registration. By default False.
new_transform_key : str, optional
If set, the registration result will be registered as a new extrinsic
coordinate system in the input views (with the given name), by default None
registration_binning : dict, optional
Binning applied to each dimension during registration, by default None.
If reg_res_level is also provided, the binning factors must be compatible
with the resolution level.
reg_res_level : int, optional
Resolution level to use for registration (e.g., 0 for scale0, 1 for scale1).
If None and registration_binning is provided, the optimal resolution level
is automatically determined. By default None.
overlap_tolerance : float or dict, optional
Extend overlap regions considered for pairwise registration.
- if 0, the overlap region is the intersection of the bounding boxes.
- if > 0, the overlap region is the intersection of the bounding boxes
extended by this value in all spatial dimensions.
- if None, the full images are used for registration
pairwise_reg_func : Callable, optional
Function used for registration. See the docs for the function API.
By default, phase_correlation_registration is used. Another useful built-in
registration function is pairwise_reg_func=registration.registration_ANTsPy
for translation, rigid, similarity or affine registration using ANTsPy.
pairwise_reg_func_kwargs : dict, optional
Additional keyword arguments passed to the registration function.
In the case of pairwise_reg_func=registration_ANTsPy, this can include e.g:
- 'transform_type': ['Translation', 'Rigid' 'Affine'] or ['Similarity']
For further parameters, see the docstring of the registration function.
groupwise_resolution_method : str, optional
Method used to resolve global transforms from pairwise registrations:
- 'global_optimization' (transform: translation|rigid|similarity|affine)
- 'shortest_paths' (uses the transform type defined by the pairwise registrations)
- 'linear_two_pass' (transform: translation|rigid)
Custom component-level methods can be registered via
param_resolution.register_groupwise_resolution_method(...) and
referenced by name.
groupwise_resolution_kwargs : dict, optional
Additional keyword arguments passed to the groupwise resolver.
Parameters are method-specific. Common options include:
- 'transform': final transform type (see method notes above)
- 'reference_view': node index to keep fixed
See the resolver docstrings for full details.
pre_registration_pruning_method : str, optional
Method used to eliminate registration edges (e.g. diagonals) from the view adjacency
graph before registration. Available methods:
- None: No pruning, useful when no regular arrangement is present.
- 'alternating_pattern': Prune to edges between squares of differering
colors in checkerboard pattern. Useful for regular 2D tile arrangements (of both 2D or 3D data).
- 'shortest_paths_overlap_weighted': Prune to shortest paths in overlap graph
(weighted by overlap). Useful to minimize the number of pairwise registrations.
- 'otsu_threshold_on_overlap': Prune to edges with overlap above Otsu threshold.
This is useful for regular 2D or 3D grid arrangements, as diagonal edges will be pruned.
- 'keep_axis_aligned': Keep only edges that align with tile axes. This is useful for regular grid
arrangements and to explicitely prune diagonals, e.g. when other methods fail.
pre_reg_pruning_method_kwargs : dict, optional
Additional keyword arguments passed to the pre-registration pruning method, e.g.
- 'keep_axis_aligned': 'max_angle' (larger angles between stack axis and pair edge are discarded, default 0.2)
post_registration_do_quality_filter : bool, optional
post_registration_quality_threshold : float, optional
Threshold used to filter edges by quality after registration,
by default None (no filtering)
plot_summary : bool, optional
If True (and new_transform_key is set), plot graphs summarising the registration process and results:
1) Cross correlation values of pairwise registrations
(stack boundaries shown as before registration)
2) Residual distances between registration edges after global parameter resolution.
Grey edges have been removed during glob param res (stack boundaries shown as after registration).
Solid edges were used by the resolver, dotted edges were unused.
Stack boundary positions reflect the registration result.
By default False
pairs : list of tuples, optional
If set, initialises the view adjacency graph using the indicates
pairs of view/tile indices, by default None
scheduler : str, optional
(Deprecated since >0.1.28) Dask scheduler to use for parallel computation, by default None
This parameter is deprecated and no longer used.
Use a context manager instead to set the dask scheduler used within register(), e.g.
with dask.config.set(scheduler='threads'): register(...)
n_parallel_pairwise_regs : int, optional
Number of parallel pairwise registrations to run. Setting this is specifically
useful for limiting memory usage.
By default None (all pairwise registrations are run in parallel)
return_dict : bool, optional
If True, return a dict containing params, registration metrics and more, by default False
Returns
list of xr.DataArray Parameters mapping each view into a new extrinsic coordinate system or dict Dictionary containing the following keys: - 'params': Parameters mapping each view into a new extrinsic coordinate system - 'pairwise_registration': Dictionary containing the following - 'summary_plot': Tuple containing the figure and axis of the summary plot - 'graph': networkx graph of pairwise registrations - 'metrics': Dictionary containing the following metrics: - 'qualities': Edge registration qualities - 'groupwise_resolution': Dictionary containing the following - 'summary_plot': Tuple containing the figure and axis of the summary plot - 'metrics': Dictionary containing the following metrics: - 'edge_residuals': Dict[int, dict[tuple, float]] mapping timepoint index to edge residuals - 'used_edges': Dict[int, list[tuple]] mapping timepoint index to edges used by the resolution method
Source code in src/multiview_stitcher/registration.py
2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 | |
registration_ITKElastix(fixed_data, moving_data, *, fixed_origin, moving_origin, fixed_spacing, moving_spacing, initial_affine, transform_types=None, **elastix_registration_kwargs)
Use ITKElastix to perform registration between two spatial images.
Parameters
transform_types : list of str, optional Sequence of transform types to apply in successive stages. Supported values: 'Translation', 'Rigid', 'Similarity', 'Affine'. By default ['Translation', 'Rigid', 'Similarity']. **elastix_registration_kwargs Additional keyword arguments. The following are handled explicitly and applied to the elastix parameter map for each stage:
number_of_resolutions : int, optional
Number of resolution levels in the multi-resolution scheme,
by default 2.
number_of_iterations : int, optional
Maximum number of optimizer iterations per resolution level.
If None, the elastix default for the chosen transform type is used.
metric : str, optional
Similarity metric used by elastix. If None, the elastix default
for the chosen transform type is used. Common values:
- 'AdvancedMattesMutualInformation' (default for most transforms)
- 'AdvancedMeanSquares'
- 'AdvancedNormalizedCorrelation'
- 'NormalizedMutualInformation'
Remaining kwargs are forwarded to ``itk.elastix_registration_method``
(e.g. ``log_to_console=True``).
Source code in src/multiview_stitcher/registration.py
2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 | |