imfun.mvm¶
Functions and variables¶
Functions for Multiscale vision model implementation
- imfun.mvm.find_objects(arr, k=3, level=5, noise_std=None, coefs=None, supp=None, dec_fn=<function decompose at 0x7fcac6e0b050>, retraw=False, start_scale=0, weights=[1.0, 1.0, 1.0, 1.0, 1.0], deblendp=True, min_px_size=200, min_nscales=2, rec_variant=2, modulus=False)¶
Use MVM to find objects in the input array.
- Parameters:
- arr: (numpy array) – 1D, 2D or 3D numpy array. Input data.
- k : (number) – threshold to regard wavelet coefficient as
significant, in
(in noise standard deviations) - level: (int) – level of wavelet transform
- noise_std: (number or None) – if known, provide noise

- coefs: if already calculated, provide wavelet coefficients
- supp: if already calculated, provide support of significant wavelet coefficients
- start_scale: (int) – start reconstruction at this scale (decomposition level)
- weights: (list of numbers) – weight coefficients at different levels before reconstruction
- min_px_size: an MVMNode should contain at least this number of pixels
- min_nscales: an object should have at least this scales/levels
- modulus: if False, only search for light sources
- retraw : only used for debugging
- Returns:
- a list of recovered objects as embedddings around non-zero voxels. see embedding function for details
- imfun.mvm.framewise_find_objects(*args, **kwargs)¶
Framewise search for objects with multiscale vision model (MVM)
- Parameters:
- frames: list of 2D arrays or array-like – frames to call mvm.find_objects on iteratively
- min_frames: (int) – an object should span at least this many frames
- verbose: (Bool) – announce number of frames processed?
- testfn : (funct) – function to judge if two 2D objects in two frames really belong to one multi-frame object
- *args, **kwargs: arguments to be passed to mvm.find_objects
- Returns:
- List of recovered 3D objects. Each object is an embedding, i.e. a tuple of the form (data, (sh, slices)), where data is bounding of the 3D object, and sh is the full shape of the array, and slices are slices which define the indices for the bounding box.
- imfun.mvm.embedding(arr, delarrp=True)¶
Return an embeding of the non-zero portion of an array.
- Parameters:
- arr: array
- delarrp: predicate whether to delete the arr
- Returns tuple (out, (sh, slices)) of:
- out: array, which is a bounding box around non-zero elements of an input array
- sh: full shape of the input data
- slices: a list of slices which define the bounding box
- imfun.mvm.embedded_to_full(x)¶
Restore ‘full’ object from it’s embedding, e.g. full image from object subframe
- imfun.mvm.get_structures(coefs, support)¶
Label contiguous regions in significant coefficients and convert them to MVM nodes.
- Parameters:
- coefs : atrous wavelet coefficients
- support : masks of significant wavelet coefficients
- Returns:
- a list of MVM nodes
TODO: Switch from coefs and support to numpy masked arrays
- imfun.mvm.connectivity_graph(structures, min_nscales=2)¶
Create the interscale connectivity graph from labelled regions of signigicant wavelet coefficients.
- Parameters:
- structures : as returned from get_structures
- min_nscales : (int) – minimal number of scales in a structure
- Returns:
- a list of root MVM nodes, the leave ones being linked to the root ones
- imfun.mvm.deblend_node(node, coefs, acc=None)¶
Make an attempt to deblend overlapping objects.
- Parameters:
- node: (MVMNode) – a root node representing an object
- coefs: (list) – atrous wavelet coefs of the input data
- acc: (list or None) – used by deblend_node in recursion
- min_scales: (int) – minimum number of scales an object should have
- Returns:
- acc: a list of deblended objests, represented by the root MVMNode.
- imfun.mvm.deblend_all(objects, coefs, min_scales=2)¶
Deblend all objects, each object being represented as a root MVMNode.
- Parameters:
- objects: (list of MVMNode instances) – root nodes
- coefs: (list) – a list of atrous wavelet coefficients
- min_scales: (int) – minimum number of scales an object should have
- Returns:
- a list of deblended objests, represented by the root MVMNode instances.