flow_error#

omnipose.core.flow_error(maski, dP_net, coords=None, affinity_graph=None, use_gpu=False, device=None, omni=True)[source]#

error in flows from predicted masks vs flows predicted by network run on image

This function serves to benchmark the quality of masks, it works as follows 1. The predicted masks are used to create a flow diagram 2. The mask-flows are compared to the flows that the network predicted

If there is a discrepancy between the flows, it suggests that the mask is incorrect. Masks with flow_errors greater than 0.4 are discarded by default. Setting can be changed in Cellpose.eval or CellposeModel.eval.

Parameters
  • maski (ND-array (int)) -- masks produced from running dynamics on dP_net, where 0=NO masks; 1,2... are mask labels

  • dP_net (ND-array (float)) -- ND flows where dP_net.shape[1:] = maski.shape

Returns

  • flow_errors (float array with length maski.max()) -- mean squared error between predicted flows and flows from masks

  • dP_masks (ND-array (float)) -- ND flows produced from the predicted masks