omnipose.core¶
|
Convert affinity graph to boundary map. |
|
Convert affinity graph to label matrix using connected components. |
|
Faster replacement for affinity_to_masks using union-find. |
|
|
|
This function converts boundary+interior labels to an affinity graph. |
|
|
|
Compute masks using dynamics from dP, dist, and boundary outputs. |
|
|
|
Calculate the mean cell diameter from a label matrix. |
|
Convert positive distance field values to a mean diameter. |
|
Normalize the flow magnitude to rescaled 0-1 divergence. |
|
Computes divergence of vector field |
Divergence for a batched D-vector field stored as |
|
|
Wrapper function for affine transformations during augmentation. |
|
fill holes in masks (2D/3D) and discard masks smaller than min_size (2D) |
|
error in flows from predicted masks vs flows predicted by network run on image |
|
define pixels and run dynamics to recover masks in 2D |
|
One way to get boundaries by considering flow dot products. |
|
Sort 2D boundaries into cyclic paths. |
|
Public wrapper: convert an iterable of (a,b) link tuples into a 2D array and call the jitted helper. |
|
|
|
Omnipose mask recontruction algorithm. |
|
create masks using pixel convergence after running dynamics |
|
Get number of iterations. |
|
Convert labels (list of masks or flows) to flows for training model. |
|
|
|
Deprecated. |
|
Loss function for Omnipose. :param lbl: transformed labels in array [nimg x nchan x xy[0] x xy[1]] lbl[:,0] cell masks lbl[:,1] thresholded mask layer lbl[:,2] boundary field lbl[:,3] smooth distance field lbl[:,4] boundary-emphasizing weights lbl[:,5:] flow components :type lbl: ND-array, float :param y: network predictions, with dimension D, these are: y[:,:D] flow field components at 0,1,...,D-1 y[:,D] distance fields at D y[:,D+1] boundary fields at D+1 :type y: ND-tensor, float. |
|
Convert label matrix to affinity graph. |
|
Convert masks to flows. |
|
Batch process flows. |
|
Convert ND masks to flows. |
|
super fast mode filter (compared to scipy, idk about PIL) to clean up interpolated labels |
|
|
|
This sub-fuction of random_rotate_and_resize() recursively performs random cropping until a minimum number of cell pixels are found, then proceeds with augemntations. |
|
augmentation by random rotation and resizing |
|
remove masks which have inconsistent flows |
|
The sigmoid function. |
|
Convert affinity graph in (S,N) format to (S,*DIMS) format. |
|
Split lineage labels into frame-by-frame labels and Cell ID / spacetime labeling. |
|
Euler integration suppression factor. |
|
Euler integration of pixel locations p subject to flow dP for niter steps in N dimensions. |
|
Dispatch to torch_and_cpu or torch_and_gpu depending on the device of the first tensor in tensors. |
|
Pair-wise logical AND using functools.reduce. |
|
Vectorized logical AND via torch.all after stacking. |
omnipose.utils¶
|
|
|
|
|
average results of network over tiles |
|
Compute the counts of values in bins. |
|
Return flat indices of border values in ND. |
|
Delete boundary masks below a given size threshold within a certain distance from the boundary. |
|
Compute the density of points along a curve. |
|
Compute a pair of quantiles of a sorted array. |
|
|
|
Gets the number of m-dimensional hypercubes connected to the n-cube, including itself. |
|
curveFilter : calculates the curvatures of an image. |
|
|
|
Compute boundaries of labeled instances in an N-dimensional array. |
|
Find files in a directory matching a suffix, excluding specific suffixes. |
|
Find text between string1 and string2. |
|
|
|
Generate slices for cropping an image into crops of size crop_size. |
|
Finds and returns masks that are largely cut off by the edge of the image. |
|
|
|
|
|
For L pixels and S steps, find the neighboring pixel indexes 0,1,...,L for each step. |
|
Get the neighbor coordinates for each pixel in coords for each offset in steps. |
|
This version not yet used/tested. |
|
|
|
Get a symmetrical list of all 3**N points in a hypercube represented by a list of all possible sequences of -1, 0, and 1 in ND. |
|
For each step 'v', find all pairs (i, j) such that steps[i] + steps[j] == steps[v], excluding the center index. |
|
Extract the file name. |
|
Pytorch implementation of skimage.filters.apply_hysteresis_threshold(). |
|
|
|
Get relevant kernel information for the hypercube of interest. |
|
Helper function to load affinity graphs. |
|
|
|
|
|
make tiles of image to run at test-time |
|
Apply a color overlay to a grayscale image based on a label matrix. |
|
|
|
|
|
normalize array/tensor so 0.0 is 0.01st percentile and 1.0 is 99.99th percentile Upper and lower percentile ranges configurable. |
|
normalize array/tensor using 1% and 99% quantiles |
|
normalize all nonzero field vectors to magnitude 1 |
|
Normalize image by rescaling from 0 to 1 and then adjusting gamma to bring average background to specified value (0.5 by default). |
|
normalize array/tensor using p-norm |
|
Boolean mask telling whether both a pixel and its neighbour at offset steps[k] are inside an N-D volume. |
|
|
|
|
|
|
|
|
|
|
|
Division ignoring zeros and NaNs in the denominator. |
|
Helper function to save affinity graphs. |
|
Find the indices where value should be inserted in tensor to maintain order. |
|
|
|
Get indices of the hupercubes sharing m-faces on the central n-cube. |
|
Helper function to subsample an affinity graph according to an image crop slice and a foreground selection mask. |
|
|
|
Rescale image [0,2^16-1] and then cast to uint16. |
|
Rescale image [0,2^8-1] and then cast to uint8. |
|
Wrapper for torch.linalg.norm to handle ARM architecture. |
|
reverse test-time augmentations for averaging |
|
omnipose.plot¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
A faster version of colorize_dask that uses a single matrix multiply instead of explicit loops or opt_einsum for the core contraction step. |
|
Create a colormap based on the average color of each label in the image. |
|
|
|
|
|
|
|
|
|
|
|
Display one or more images. |
|
Render an affinity graph as line segments laid over an optional image. |
|
Meant for stacks of dP, unsqueeze if using on a single plane. |
|
|
|
|
|
|
|
|
|
|
|