PYME.Analysis.points.ripleys module

PYME.Analysis.points.ripleys.mc_points_from_mask(mask, n_points, three_d=True, coord_origin=(0, 0, 0))

Calculate coordinate positions in nm from a Monte-Carlo-sampled mask.

Parameters
masknp.array

Mask image (array of 0s and 1s)

n_pointsint

Number of points to return.

three_dbool

Return 2D or 3D coordinates

coord_origin3-tuple

Offset in nm of the x, y, and z coordinates w.r.t. the camera origin (used to make sure mask aligns)

PYME.Analysis.points.ripleys.mc_sampling_statistics(K, n_points, n_bins, bin_size, mask, three_d, significance=0.05, n_sim=20, threaded=False, sampling=5.0, coord_origin=(0, 0, 0))

Calculates simulation envelope and significance of clustering on a mask by simulating random uniform distributions on the mask using Monte-Carlo sampling.

Parameters
Knp.array

Ripley’s K-values for real points to be compared to simulations. Expects output from ripleys_k.

n_pointsint

Number of real points. Defines size of simulations.

n_binsint

Number of spatial bins

bin_size: float

Width of spatial bins (nm)

maskPYME.IO.image.ImageStack

a mask of allowing the Ripleys to be computed within a given area

three_dbool

Indicates if the real points are in 2D or 3D space

n_simint

Number of Monte-Carlo simulations to run. More simulations = more statistical power.

threadedbool

Calculate pairwise distances using multithreading (faster)

samplingfloat

spacing (in nm) of samples from mask / region.

coord_origin3-tuple

Offset in nm of the x, y, and z coordinates w.r.t. the camera origin (used to make sure mask aligns)

PYME.Analysis.points.ripleys.points_from_mask(mask, sampling, three_d=True, coord_origin=(0, 0, 0))

Calculate coordinate positions in nm from a regularly-sampled mask.

Parameters
masknp.array

Mask image (array of 0s and 1s)

samplingfloat

Sampling rate of mask image in nm.

three_dbool

Return 2D or 3D coordinates

coord_origin3-tuple

Offset in nm of the x, y, and z coordinates w.r.t. the camera origin (used to make sure mask aligns)

PYME.Analysis.points.ripleys.ripleys_dh(bb, K, d=2)

Derivative of the H-function.

Parameters
bbnp.array

Histogram bins associated with K.

Knp.array

Ripley’s K-function, calculated from PYME.Analysis.points.spatial_descriptive.ripleys_k

dint

Dimension of the input data to calculate K (2 or 3).

PYME.Analysis.points.ripleys.ripleys_dl(bb, K, d=2)

Derivative of the H-function.

Parameters
bbnp.array

Histogram bins associated with K.

Knp.array

Ripley’s K-function, calculated from PYME.Analysis.points.spatial_descriptive.ripleys_k

dint

Dimension of the input data to calculate K (2 or 3).

PYME.Analysis.points.ripleys.ripleys_h(bb, K, d=2)

Normalizes Ripley’s K-function to an H-function such that > 0 indicates clustering and H < 0 indicates dispersion.

Parameters
bbnp.array

Histogram bins associated with K.

Knp.array

Ripley’s K-function, calculated from PYME.Analysis.points.spatial_descriptive.ripleys_k

dint

Dimension of the input data to calculate K (2 or 3).

PYME.Analysis.points.ripleys.ripleys_k(x, y, n_bins, bin_size, mask=None, bbox=None, z=None, threaded=False, sampling=5.0, coord_origin=(0, 0, 0))

Ripley’s K-function for examining clustering and dispersion of points within a region R, where R is defined by a mask (2D or 3D) of the data.

xnp.array

x-position of raw data

ynp.array

y-position of raw data

n_binsint

Number of spatial bins

bin_size: float

Width of spatial bins (nm)

maskPYME.IO.image.ImageStack

a mask of allowing the Ripleys to be computed within a given area

bboxoptional, a tuple (x0, y0, x1, y1), or (x0, y0, z0, x1, y1, z1)

bounding box of the region to consider if no mask provided (defaults to min and max of supplied data)

zoptional, np.array

z-position of raw data

threadedbool

Calculate pairwise distances using multithreading (faster)

samplingfloat

spacing (in nm) of samples from mask / region.

coord_origin3-tuple

Offset in nm of the x, y, and z coordinates w.r.t. the camera origin (used to make sure mask aligns)

PYME.Analysis.points.ripleys.ripleys_k_from_mask_points(x, y, xu, yu, n_bins, bin_size, mask_area, area_per_mask_point, z=None, zu=None, threaded=False)

Ripley’s K-function for examining clustering and dispersion of points within a region R, where R is defined by a mask (2D or 3D) of the data.

Parameters
xnp.array

x-position of raw data

ynp.array

y-position of raw data

xunp.array

x-position of simulated uniform random data over region R

yunp.array

y-position of simulated uniform random data over region R

n_binsint

Number of spatial bins

bin_size: float

Width of spatial bins (nm)

mask_areafloat

Area of region R (sum of the mask)

area_per_mask_pointfloat

Scaling factor for weight calculations

znp.array

z-position of raw data

zunp.array

z-position of simulated uniform random data over region R

threadedbool

Calculate pairwise distances using multithreading (faster)

PYME.Analysis.points.ripleys.ripleys_l(bb, K, d=2)

Normalizes Ripley’s K-function to an L-function.

Parameters
bbnp.array

Histogram bins associated with K.

Knp.array

Ripley’s K-function, calculated from PYME.Analysis.points.spatial_descriptive.ripleys_k

dint

Dimension of the input data to calculate K (2 or 3).