remove_bad_flow_masks#

omnipose.core.remove_bad_flow_masks(masks, flows, coords=None, affinity_graph=None, threshold=0.4, use_gpu=False, device=None, omni=True)[source]#

remove masks which have inconsistent flows

Uses metrics.flow_error to compute flows from predicted masks and compare flows to predicted flows from network. Discards masks with flow errors greater than the threshold.

Parameters
  • masks (int, 2D or 3D array) -- labelled masks, 0=NO masks; 1,2,...=mask labels, size [Ly x Lx] or [Lz x Ly x Lx]

  • flows (float, 3D or 4D array) -- flows [axis x Ly x Lx] or [axis x Lz x Ly x Lx]

  • threshold (float) -- masks with flow error greater than threshold are discarded

Returns

masks -- 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