subsample_affinity#

omnipose.utils.subsample_affinity(augmented_affinity, slc, mask)[source]#

Helper function to subsample an affinity graph according to an image crop slice and a foreground selection mask.

Parameters
  • augmented_affinity (NDarray, int64) -- Stacked neighbor coordinate array and affinity graph. For dimension d, augmented_affinity[:d] are the neighbor coordinates of shape (d,3**d,npix) and augmented_affinity[d] is the affinity graph of shape (3**d,npix).

  • slc (tuple, slice) -- tuple of slices along each dimension defining the crop window

  • mask (NDarray, bool) -- foreground selection mask, in the image space of the original graph (i.e., not already sliced)

Return type

Augmented affinity graph corresponding to the cropped/masked region.