masks_to_flows_torch#

omnipose.core.masks_to_flows_torch(masks, affinity_graph, coords=None, dists=None, device=device(type='cpu'), omni=True, affinity_field=False, smooth=False, normalize=False, n_iter=None, weight=1, return_flows=True, edges=None, initialize=False, verbose=False)[source]#

Convert ND masks to flows.

Omnipose find distance field, Cellpose uses diffusion from center of mass.

Parameters
  • masks (int, ND array) -- labelled masks, 0 = background, 1,2,...,N = mask labels

  • dists (ND array, float) -- array of (nonnegative) distance field values

  • device (torch device) -- what compute hardware to use to run the code (GPU VS CPU)

  • omni (bool) -- flag to generate Omnipose flows instead of Cellpose flows

  • smooth (bool) -- use relaxation to smooth out distance and therby flow field

  • n_iter (int) -- override number of iterations

Returns

  • mu (float, 3D or 4D array) -- flows in Y = mu[-2], flows in X = mu[-1]. if masks are 3D, flows in Z or T = mu[0].

  • dist (float, 2D or 3D array) -- scalar field representing temperature distribution (Cellpose) or the smooth distance field (Omnipose)