spectral_unmixing.correct_intra_stack_z_drift
- spectral_unmixing.correct_intra_stack_z_drift(stack, *, registration_channel=0, method='phase_cross_correlation', reference_mode='neighbor', neighbor_window_size=3, pre_median_filter=False, post_median_filter=False, median_kernel_size=3, verbose=True)[source]
Correct XY drift between Z slices within each time point of a TZCYX stack.
- Parameters:
stack (array-like) – Input stack in canonical
TZCYXorder.registration_channel (int, optional) – Channel used to estimate the slice-wise XY shifts. The computed shifts are then applied to all channels of the corresponding Z slice.
method ({“phase_cross_correlation”, “pystackreg”}, optional) – Backend used for shift estimation.
reference_mode ({“neighbor”, “full_projection”}, optional) – Strategy used to build the per-slice reference image.
"neighbor"uses a local max projection around each slice."full_projection"uses the max projection across the entire Z stack of the current time point.neighbor_window_size (int, optional) – Odd number of slices used for
reference_mode="neighbor".3meansz-1, z, z+1;5meansz-2throughz+2.pre_median_filter (bool, optional) – If True, apply a slice-wise median filter to the registration channel before building the reference images. This affects only shift estimation.
post_median_filter (bool, optional) – If True, apply a 2D median filter to both the moving slice and the reference image just before shift estimation.
median_kernel_size (int, optional) – Median filter kernel size used by the optional pre/post filters.
verbose (bool, optional) – If True, print the estimated shifts line-wise for each
tandz.
- Return type:
ndarray- Returns:
np.ndarray – Z-drift-corrected stack with the same
TZCYXshape as the input.
Notes
This function estimates XY shifts independently for each Z slice within each time point. The shifts are computed from a user-selected registration channel, but are applied to all channels of the affected slice.