PYME.Analysis.points.multiview module¶
- PYME.Analysis.points.multiview.apply_shifts_to_points(datasource, shiftWallet)¶
applyShiftmaps loads multiview shiftmap parameters from multiviewMapper.shiftWallet, reconstructs the shiftmap objects, applies them to the multiview data, and maps the positions registered to the first channel to the pipeline
- Args:
x: vector of localization x-positions y: vector of localization y-positions numChan: number of multiview channels
- Returns: nothing
Adds shifts into the pipeline which will then be applied automatically by the mappingFilter (see foldX)
- PYME.Analysis.points.multiview.calc_shifts_for_points(datasource, shiftWallet)¶
- PYME.Analysis.points.multiview.coalesce_dict_sorted(inD, assigned, keys, weights_by_key, discard_trivial=False)¶
Agregates clumps to a single event
- Parameters
- inDdict
input dictionary containing fit results
- assignedndarray
clump assignments to be coalesced. Cluster assignment index can start at 0 or 1 (the latter following PYME cluster labeling convention), however any index present will be coalesced (including the 0 cluster, if present).
- keyslist
elements are strings corresponding to keys to be copied from the input to output dictionaries
- weights_by_keydict
maps weighting keys to coalescing weights or coalescing style (mean, min, sum).
- discard_trivialbool
by default, the output of aggregation/coalescing is indexable by the original clump ID and contains entries for the unassigned (0) clump and any other clumps which might have been lost to filtering. Setting discard_trial to true returns only those clumps for which idx >=1 and which contain at least 1 point.
- Returns
- fres: dict
coalesced results
Notes
This will evaluate the lazy pipeline events and add them into the dict as an array, not a code object.
- PYME.Analysis.points.multiview.correlative_shift(x0, y0, which_channel, pix_size_nm=115.0)¶
Laterally shifts all channels to the first using cross correlations
- Parameters
- x0ndarray
array of localization x positions; not yet registered
- y0ndarray
array of localization y positions; not yet registered
- which_channelndarray
contains the channel ID for each localization
- pix_size_nmfloat
size of pixels to be used in generating 2D histograms which the correlations are then performed on
- Returns
- xndarray
array of localization x positions registered to the first channel
- yndarray
array of localization y positions registered to the first channel
- PYME.Analysis.points.multiview.find_clumps(datasource, gap_tolerance, radius_scale, radius_offset, inject=False)¶
- PYME.Analysis.points.multiview.find_clumps_within_channel(datasource, gap_tolerance, radius_scale, radius_offset, inject=False)¶
- Args:
datasource: PYME datasource object - dictionary-like object with addColumn method gap_tolerance: number of frames acceptable for a molecule to go MIA and still be called the same molecule when
it returns
radius_scale: multiplicative factor applied to the error_x term in deciding search radius for pairing radius_offset: term added to radius_scale*error_x to set search radius
- Returns:
Nothing, but adds clumpIndex column to datasource input
FIXME: This function should probably not exist as channel handling should ideally only be in one place within the code base. A prefered solution would be to split using a colour filter, clump each channel separately, and then merge channels.
- PYME.Analysis.points.multiview.foldX(datasource, mdh, inject=False, chroma_mappings=False)¶
At this point the origin of x should be the corner of the concatenated frame
- Args:
datasource:
- Returns: nothing
Adds folded x-coordinates to the datasource Adds channel assignments to the datasource
- PYME.Analysis.points.multiview.load_shiftmap(uri)¶
helper function to handle I/O of two versions of shiftmaps. Note that HDF is prefered :param uri: str
path or url to shiftmap-containing file (hdf, or [less ideal] json)
- Returns
dict shiftmap
- PYME.Analysis.points.multiview.merge_clumps(datasource, numChan, labelKey='clumpIndex')¶
- PYME.Analysis.points.multiview.pair_molecules(t_index, x0, y0, which_chan, delta_x=[None], appear_in=array([0, 1, 2, 3]), n_frame_sep=5, return_paired=True, pix_size_nm=115.0)¶
pair_molecules uses pyDeClump functions to group localization clumps into molecules for registration.
- Parameters
- t_index: from fitResults
- x0: ndarray
x positions of localizations AFTER having been folded into the first channel
- y0: ndarray
y positions of localizations
- which_chan: ndarray
contains channel assignments for each localization
- delta_x: list
distance within which neighbors will be clumped is set by 2*delta_x[i])**2. If None, will default to 100 nm
- appear_in: list
a clump must have localizations in each of these channels in order to be a keep-clump
- n_frame_sep: int
number of frames a molecule is allowed to blink off and still be clumped as the same molecule
- return_paired: bool
flag to return a boolean array where True indicates that the molecule is a member of a clump whose members span the appearIn channels.
- Returns
- assigned: ndarray
clump assignments for each localization. Note that molecules whose which_chan entry is set to a negative value will not be clumped, i.e. they will have a unique value in assigned.
- keep: ndarray
a boolean vector encoding which molecules are in kept clumps
Notes
Outputs are of length #molecules, and the keep vector that is returned needs to be applied as: x_kept = x[keep] in order to only look at kept molecules.