PYME.recipes.localisations module¶
- class PYME.recipes.localisations.AddMeasurementsByLabel(parent=None, invalidate_parent=True, **kwargs)¶
Bases:
ModuleBase
- input_measurements = <PYME.recipes.traits.Input object>¶
- input_points = <PYME.recipes.traits.Input object>¶
- label_key = <PYME.misc.mock_traits.CStr object>¶
- output_points = <PYME.recipes.traits.Output object>¶
- run(input_points, input_measurements)¶
Propagate measurements from e.g. MeasureClusters3D back to points they were calcualted from. This is particularly useful for visualizing e.g. the gyration radius of a cluster in PYMEVis while looking at the original localization data.
- Parameters
- input_pointsPYME.IO.tabular.TabularBase
points used to generate the measurements
- input_measurementsPYME.IO.tabular.TabularBase
measurements to propagate back to the points
- Returns
- PYME.IO.tabular.TabularBase
point data with new columns added, one for each scalar measurement in input_measurements, which can be accessed by ‘<label_key>_<measurement_key>’, e.g. ‘clumpIndex_gyrationRadius’.
- class PYME.recipes.localisations.AutocorrelationDriftCorrection(parent=None, invalidate_parent=True, **kwargs)¶
Bases:
ModuleBase
Perform drift correction using autocorrelation between subsets of the point data
- binsize = <PYME.misc.mock_traits.Float object>¶
- calcCorrDrift(x, y, t)¶
- inputName = <PYME.recipes.traits.Input object>¶
- outputName = <PYME.recipes.traits.Output object>¶
- run(inputName)¶
OVERRIDE THIS in derived classes to implement module functionality. Parameters are passed in by keyword, and keyword names must be a 1:1 match to the module input traits.
The function should return either a dict (multiple outputs, keyed with output trait keys), or
- step = <PYME.misc.mock_traits.CStr object>¶
- window = <PYME.misc.mock_traits.CStr object>¶
- class PYME.recipes.localisations.ClusterCountVsImagingTime(parent=None, invalidate_parent=True, **kwargs)¶
Bases:
ModuleBase
WARNING: This module will likely move, dissapear, or be refactored
ClusterCountVsImagingTime iteratively filters a dictionary-like object on t, and at each step counts the number of labeled objects (e.g. DBSCAN clusters) which contain at least N-points. It does this for two N-points, so one can be set according to density with all frames included, and the other can be set for one of the earlier frame-counts.
- args:
stepSize: number of frames to add in on each iteration labelsKey: key containing labels for each localization lowerMinPtsPerCluster: higherMinPtsPerCluster:
- returns:
- dictionary-like object with the following keys:
t: upper bound on frame number included in calculations on each iteration. N_labelsWithLowMinPoints: N_labelsWithHighMinPoints:
From wikipedia: “While minPts intuitively is the minimum cluster size, in some cases DBSCAN can produce smaller clusters. A DBSCAN cluster consists of at least one core point. As other points may be border points to more than one cluster, there is no guarantee that at least minPts points are included in every cluster.”
- higherMinPtsPerCluster = <PYME.misc.mock_traits.CStr object>¶
- inputName = <PYME.recipes.traits.Input object>¶
- labelsKey = <PYME.misc.mock_traits.CStr object>¶
- lowerMinPtsPerCluster = <PYME.misc.mock_traits.CStr object>¶
- outputName = <PYME.recipes.traits.Output object>¶
- run(inputName)¶
OVERRIDE THIS in derived classes to implement module functionality. Parameters are passed in by keyword, and keyword names must be a 1:1 match to the module input traits.
The function should return either a dict (multiple outputs, keyed with output trait keys), or
- stepSize = <PYME.misc.mock_traits.CStr object>¶
- class PYME.recipes.localisations.DBSCANClustering(parent=None, invalidate_parent=True, **kwargs)¶
Bases:
ModuleBase
Performs DBSCAN clustering on input dictionary
- Parameters
- searchRadiusfloat
search radius for clustering [nm]
- minPtsForCoreint
number of points within SearchRadius required for a given point to be considered a core point
Notes
See sklearn.cluster.dbscan for more details about the underlying algorithm and parameter meanings.
- clumpColumnName = <PYME.misc.mock_traits.CStr object>¶
- columns = <PYME.misc.mock_traits.CStr object>¶
- property hide_in_overview¶
- inputName = <PYME.recipes.traits.Input object>¶
- minClumpSize = <PYME.misc.mock_traits.CStr object>¶
- multiprocessing = <module 'multiprocessing' from '/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/multiprocessing/__init__.py'>¶
- multithreaded = <PYME.misc.mock_traits.CStr object>¶
- numberOfJobs = <PYME.misc.mock_traits.CStr object>¶
- outputName = <PYME.recipes.traits.Output object>¶
- run(inputName)¶
OVERRIDE THIS in derived classes to implement module functionality. Parameters are passed in by keyword, and keyword names must be a 1:1 match to the module input traits.
The function should return either a dict (multiple outputs, keyed with output trait keys), or
- searchRadius = <PYME.misc.mock_traits.Float object>¶
- class PYME.recipes.localisations.DensityMapping(parent=None, invalidate_parent=True, **kwargs)¶
Bases:
ModuleBase
Use density estimation methods to generate an image from localizations
- MCProbability = <PYME.misc.mock_traits.Float object>¶
- available_renderers = ['3D Gaussian', '3D Histogram', '3D Triangularisation', 'Density Fit', 'Gaussian', 'Histogram', 'Jittered Triangulation', 'Jittered Triangulation - weighted', 'Log Likelihood', 'QuadTree', 'Voronoi']¶
- colours = <PYME.misc.mock_traits.List object>¶
- inputLocalizations = <PYME.recipes.traits.Input object>¶
- jitterScale = <PYME.misc.mock_traits.Float object>¶
- jitterScaleZ = <PYME.misc.mock_traits.Float object>¶
- jitterVariable = <PYME.misc.mock_traits.CStr object>¶
- jitterVariableZ = <PYME.misc.mock_traits.CStr object>¶
- manualXYBounds = <PYME.misc.mock_traits.List object>¶
- numSamples = <PYME.misc.mock_traits.CStr object>¶
- outputImage = <PYME.recipes.traits.Output object>¶
- pixelSize = <PYME.misc.mock_traits.Float object>¶
- renderingModule = <PYME.misc.mock_traits.CStr object>¶
- run(inputLocalizations)¶
OVERRIDE THIS in derived classes to implement module functionality. Parameters are passed in by keyword, and keyword names must be a 1:1 match to the module input traits.
The function should return either a dict (multiple outputs, keyed with output trait keys), or
- softRender = <PYME.misc.mock_traits.CStr object>¶
- xyBoundsMode = <PYME.misc.mock_traits.CStr object>¶
- zBounds = <PYME.misc.mock_traits.List object>¶
- zBoundsMode = <PYME.misc.mock_traits.CStr object>¶
- zSliceThickness = <PYME.misc.mock_traits.Float object>¶
- class PYME.recipes.localisations.ExtractTableChannel(parent=None, invalidate_parent=True, **kwargs)¶
Bases:
ModuleBase
Create and return a ColourFilter which has filtered out one colour channel from a table of localizations.
- channel = <PYME.misc.mock_traits.CStr object>¶
- inputName = <PYME.recipes.traits.Input object>¶
- outputName = <PYME.recipes.traits.Output object>¶
- run(inputName)¶
OVERRIDE THIS in derived classes to implement module functionality. Parameters are passed in by keyword, and keyword names must be a 1:1 match to the module input traits.
The function should return either a dict (multiple outputs, keyed with output trait keys), or
- class PYME.recipes.localisations.FiducialCorrection(parent=None, invalidate_parent=True, **kwargs)¶
Bases:
ModuleBase
Maps each point in the input table to a pixel in a labelled image, and extracts the pixel value at that location to use as a label for the point data.
- clumpRadiusMultiplier = <PYME.misc.mock_traits.Float object>¶
- clumpRadiusVar = <PYME.misc.mock_traits.CStr object>¶
- inputFiducials = <PYME.recipes.traits.Input object>¶
- inputLocalizations = <PYME.recipes.traits.Input object>¶
- outputFiducials = <PYME.recipes.traits.Output object>¶
- outputName = <PYME.recipes.traits.Output object>¶
- run(inputLocalizations, inputFiducials)¶
OVERRIDE THIS in derived classes to implement module functionality. Parameters are passed in by keyword, and keyword names must be a 1:1 match to the module input traits.
The function should return either a dict (multiple outputs, keyed with output trait keys), or
- temporalFilter = <PYME.misc.mock_traits.CStr object>¶
- temporalFilterScale = <PYME.misc.mock_traits.Float object>¶
- timeWindow = <PYME.misc.mock_traits.CStr object>¶
- class PYME.recipes.localisations.IDTransientFrames(parent=None, invalidate_parent=True, **kwargs)¶
Bases:
ModuleBase
Adds an ‘isTransient’ column to the input datasource so that one can filter localizations that are from frames acquired during z-translation
- framesPerStep = <PYME.misc.mock_traits.Float object>¶
- inputEvents = <PYME.recipes.traits.Input object>¶
- inputName = <PYME.recipes.traits.Input object>¶
- outputName = <PYME.recipes.traits.Output object>¶
- run(inputName, inputEvents)¶
OVERRIDE THIS in derived classes to implement module functionality. Parameters are passed in by keyword, and keyword names must be a 1:1 match to the module input traits.
The function should return either a dict (multiple outputs, keyed with output trait keys), or
- class PYME.recipes.localisations.LabelsFromImage(parent=None, invalidate_parent=True, **kwargs)¶
Bases:
ModuleBase
Maps each point in the input table to a pixel in a labelled image, and extracts the pixel value at that location to use as a label for the point data.
- inputImage = <PYME.recipes.traits.Input object>¶
- inputName = <PYME.recipes.traits.Input object>¶
- label_count_key_name = <PYME.misc.mock_traits.CStr object>¶
- label_key_name = <PYME.misc.mock_traits.CStr object>¶
- minimum_localizations = <PYME.misc.mock_traits.CStr object>¶
- outputName = <PYME.recipes.traits.Output object>¶
- run(inputName, inputImage)¶
OVERRIDE THIS in derived classes to implement module functionality. Parameters are passed in by keyword, and keyword names must be a 1:1 match to the module input traits.
The function should return either a dict (multiple outputs, keyed with output trait keys), or
- class PYME.recipes.localisations.MapAstigZ(parent=None, invalidate_parent=True, **kwargs)¶
Bases:
ModuleBase
Uses astigmatism calibration (widths of PSF along each dimension as a function of z) to determine the z-position of localizations relative to the focal plane of the frame during which it was imaged. Note this is the single channel version and does not work for combined biplane and astigmatism (see Multiview.MapAstigZ). It also uses the more robust but less precise dsigma method.
- Parameters
- input_nametraits.Input
localizations as PYME.IO.Tabular types
- astigmatism_calibration_locationtraits.File
file path or URL to astigmatism calibration file
- Returns
- output_nametraits.Output
output is a json wrapped by PYME.IO.ragged.RaggedCache
- astigmatism_calibration_location = <PYME.recipes.traits.FileOrURI object>¶
- execute(namespace)¶
takes a namespace (a dictionary like object) from which it reads its inputs and into which it writes outputs
NOTE: This was previously the function to define / override to make a module work. To support automatic metadata propagation and reduce the ammount of boiler plate, new modules should override the run() method instead.
- input_name = <PYME.recipes.traits.Input object>¶
- output_name = <PYME.recipes.traits.Output object>¶
- rough_knot_spacing = <PYME.misc.mock_traits.Float object>¶
- z_scale = <PYME.misc.mock_traits.Float object>¶
- class PYME.recipes.localisations.MeasureClusters3D(parent=None, invalidate_parent=True, **kwargs)¶
Bases:
ModuleBase
Measures the 3D morphology of clusters of points
- Parameters
- labelKey: name of column to use as a label identifying clusters
Notes
Measures calculated (to be expanded)
- Count
int Number of localizations (points) in the cluster
- X
float x center of mass
- Y
float y center of mass
- Z
float z center of mass
- :gyrationRadiusfloat
root mean square displacement to center of cluster, a measure of compaction or spatial extent see also supplemental text of DOI: 10.1038/nature16496
- :axis0ndarray, shape (3,)
principle axis which accounts for the largest variance of the cluster, i.e. corresponds to the largest eigenvalue
- :axis1ndarray, shape (3,)
next principle axis
- :axis2ndarray, shape (3,)
principle axis corresponding to the smallest eigenvalue
- :sigma0float
standard deviation along axis0
- :sigma1float
standard deviation along axis1
- :sigma2float
standard deviation along axis2
- :anisotropyfloat
metric of anisotropy based on the spread along principle axes. Standard deviations of alpha * [1, 0, 0], where alpha is a scalar, will result in an ‘anisotropy’ value of 1, i.e. maximally anisotropic. Completely isotropic clusters will have equal standard deviations, i.e. alpha * [1, 1, 1], which corresponds to an ‘anisotropy’ value of 0. Intermediate cases result in values between 0 and 1.
- :thetafloat
Azimuthal angle, in radians, along which the principle axis (axis0) points
- :phifloat
Zenith angle, in radians, along which the principle axis (axis0) points
- inputName = <PYME.recipes.traits.Input object>¶
- labelKey = <PYME.misc.mock_traits.CStr object>¶
- outputName = <PYME.recipes.traits.Output object>¶
- run(inputName)¶
OVERRIDE THIS in derived classes to implement module functionality. Parameters are passed in by keyword, and keyword names must be a 1:1 match to the module input traits.
The function should return either a dict (multiple outputs, keyed with output trait keys), or
- class PYME.recipes.localisations.MergeClumps(parent=None, invalidate_parent=True, **kwargs)¶
Bases:
ModuleBase
Create a new mapping object which derives mapped keys from original ones
- discardTrivial = <PYME.misc.mock_traits.CStr object>¶
- inputName = <PYME.recipes.traits.Input object>¶
- labelKey = <PYME.misc.mock_traits.CStr object>¶
- outputName = <PYME.recipes.traits.Output object>¶
- run(inputName)¶
OVERRIDE THIS in derived classes to implement module functionality. Parameters are passed in by keyword, and keyword names must be a 1:1 match to the module input traits.
The function should return either a dict (multiple outputs, keyed with output trait keys), or
- class PYME.recipes.localisations.Pipelineify(parent=None, invalidate_parent=True, **kwargs)¶
Bases:
ModuleBase
Perform standard mappings, including those derived from acquisition events.
- Parameters
- inputFitResultsstring - the name of a tabular.TabularBase object
Typically the FitResults table of an h5r file
- inputEventsstring - name of a tabular.TabularBase object containing acquisition events [optional]
This is not usually required as the IO methods attach .events as a datasource attribute. Use when events come from a separate file or when there are intervening processing steps between IO and this module (the .events attribute does not propagate through recipe modules). TODO - do we really want to be attaching events as an attribute or should they be there own entry in the recipe namespace TODO - should we change this to the processed events???
- pixelSizeNMfloat
Scaling factor to get ‘x’ and ‘y’ into units of nanometers. Useful if handling external data input in pixel units. Defaults to 1.
- Returns
- outputLocalizationstabular.MappingFilter
- foreshortening = <PYME.misc.mock_traits.Float object>¶
- inputEvents = <PYME.recipes.traits.Input object>¶
- inputFitResults = <PYME.recipes.traits.Input object>¶
- outputLocalizations = <PYME.recipes.traits.Output object>¶
- pixelSizeNM = <PYME.misc.mock_traits.Float object>¶
- run(inputFitResults, inputEvents=None)¶
OVERRIDE THIS in derived classes to implement module functionality. Parameters are passed in by keyword, and keyword names must be a 1:1 match to the module input traits.
The function should return either a dict (multiple outputs, keyed with output trait keys), or
- class PYME.recipes.localisations.ProcessColour(parent=None, invalidate_parent=True, **kwargs)¶
Bases:
ModuleBase
- input = <PYME.recipes.traits.Input object>¶
- output = <PYME.recipes.traits.Output object>¶
- ratios_from_metadata = <PYME.misc.mock_traits.CStr object>¶
- run(input)¶
OVERRIDE THIS in derived classes to implement module functionality. Parameters are passed in by keyword, and keyword names must be a 1:1 match to the module input traits.
The function should return either a dict (multiple outputs, keyed with output trait keys), or
- species_dyes = <PYME.misc.mock_traits.CStr object>¶
- species_ratios = <PYME.misc.mock_traits.CStr object>¶
- class PYME.recipes.localisations.TimeBlocks(parent=None, invalidate_parent=True, **kwargs)¶
Bases:
ModuleBase
Divides series into alternating time blocks to generate 2 fake colour channels for Fourier Ring / Fourier shell correlation.
This is probably a better approach than taking random subsets as the later will tend to generate unrealistically high correlation values for repeated localizations.
Adapted from Christian Soeller’s ‘splitRender’ implementation.
- block_size = <PYME.misc.mock_traits.CStr object>¶
- input = <PYME.recipes.traits.Input object>¶
- output = <PYME.recipes.traits.Output object>¶
- run(input)¶
OVERRIDE THIS in derived classes to implement module functionality. Parameters are passed in by keyword, and keyword names must be a 1:1 match to the module input traits.
The function should return either a dict (multiple outputs, keyed with output trait keys), or