get_masks_cp#

omnipose.core.get_masks_cp(p, iscell=None, rpad=20, flows=None, use_gpu=False, device=None)[source]#

create masks using pixel convergence after running dynamics

Makes a histogram of final pixel locations p, initializes masks at peaks of histogram and extends the masks from the peaks so that they include all pixels with more than 2 final pixels p. Discards masks with flow errors greater than the threshold.

Parameters
  • p (float32, 3D or 4D array) -- final locations of each pixel after dynamics, size [axis x Ly x Lx] or [axis x Lz x Ly x Lx].

  • iscell (bool, 2D or 3D array) -- if iscell is not None, set pixels that are iscell False to stay in their original location.

  • rpad (int (optional, default 20)) -- histogram edge padding

  • flows (float, 3D or 4D array (optional, default None)) -- flows [axis x Ly x Lx] or [axis x Lz x Ly x Lx]. If flows is not None, then masks with inconsistent flows are removed using remove_bad_flow_masks.

Returns

M0 -- masks with inconsistent flow masks removed, 0=NO masks; 1,2,...=mask labels, size [Ly x Lx] or [Lz x Ly x Lx]

Return type

int, 2D or 3D array