Module Documentation¶
This page contains the full API docs of ColiCoords
Cell¶
-
class
colicoords.cell.
Cell
(data_object, name=None, init_coords=True, **kwargs)[source]¶ ColiCoords’ main single-cell object.
This class organizes all single-cell associated data together with an internal coordinate system.
Parameters: - data_object :
Data
Holds all data describing this single cell.
- coords :
Coordinates
Calculates transformations from/to cartesian and cellular coordinates.
- name :
str
Name identifying the cell (optional).
- **kwargs:
Additional kwargs passed to
Coordinates
.
Attributes: - data :
Data
Holds all data describing this single cell.
- coords :
Coordinates
Calculates and optimizes the cell’s coordinate system.
- name :
str
Name identifying the cell (optional).
Methods
copy
(self)Make a copy of the cell object and all its associated data elements. get_intensity
(self[, mask, data_name, func])Returns the mean fluorescence intensity. l_classify
(self[, data_name])Classifies foci in STORM-type data by they x-position along the long axis. l_dist
(self, nbins[, start, stop, …])Calculates the longitudinal distribution of signal for a given data element. measure_r
(self[, data_name, mode, in_place])Measure the radius of the cell. optimize
(self[, data_name, cell_function, …])Optimize the cell’s coordinate system. phi_dist
(self, step[, data_name, r_max, …])Calculates the angular distribution of signal for a given data element. r_dist
(self, stop, step[, data_name, …])Calculates the radial distribution of a given data element. reconstruct_image
(self, data_name[, norm_x, …])Reconstruct the image from a given data element and the cell’s current coordinate system. -
copy
(self)[source]¶ Make a copy of the cell object and all its associated data elements.
This is a deep copy meaning that all numpy data arrays are copied in memory and therefore modifying the copied cell object does not modify the original cell object.
Returns: - cell :
Cell
Copied cell object.
- cell :
-
get_intensity
(self, mask='binary', data_name='', func=<function mean at 0x7fdc6b3f5730>)[source]¶ Returns the mean fluorescence intensity.
Mean fluorescence intensity either in the region masked by the binary image or reconstructed binary image derived from the cell’s coordinate system.
Parameters: - mask :
str
Either ‘binary’ or ‘coords’ to specify the source of the mask used. ‘binary’ uses the binary image as mask, ‘coords’ uses reconstructed binary from coordinate system.
- data_name :
str
: The name of the image data element to get the intensity values from.
- func :
callable
This function is applied to the data elements pixels selected by the masking operation. The default is np.mean().
Returns: - value :
float
Mean fluorescence pixel value.
- mask :
-
l_classify
(self, data_name='')[source]¶ Classifies foci in STORM-type data by they x-position along the long axis.
The spots are classified into 3 categories: ‘poles’, ‘between’ and ‘mid’. The pole category are spots who are to the left and right of xl and xr, respectively. The class ‘mid’ is a section in the middle of the cell with a total length of half the cell’s length, the class ‘between’ is the remaining two quarters between ‘mid’ and ‘poles’.
Parameters: - data_name :
str
Name of the STORM-type data element to classify. When its not specified the first STORM data element is used.
Returns: - l_classes :
tuple
Tuple with number of spots in poles, between and mid classes, respectively.
- data_name :
-
l_dist
(self, nbins, start=None, stop=None, data_name='', norm_x=False, l_mean=None, r_max=None, storm_weight=False, method='gauss', sigma=0.5)[source]¶ Calculates the longitudinal distribution of signal for a given data element.
Parameters: - nbins :
int
Number of bins between start and stop.
- start :
float
Distance from xl as starting point for the distribution, units are either pixels or normalized units if norm_x=True.
- stop :
float
Distance from xr as end point for the distribution, units are are either pixels or normalized units if norm_x=True.
- data_name :
str
Name of the data element to use.
- norm_x :
bool
If True the output distribution will be normalized.
- l_mean :
float
, optional When norm_x is True, all length coordinates are divided by the length of the cell to normalize it. If l_mean is given, the length coordinates at the poles are divided by l_mean instead to allow equal scaling of all pole regions.
- r_max :
float
, optional Datapoints within r_max from the cell midline will be included. If None the value from the cell’s coordinate system will be used.
- storm_weight :
bool
If True the datapoints of the specified STORM-type data will be weighted by their intensity.
- method :
str
Method of averaging datapoints to calculate the final distribution curve.
- sigma :
float
Applies only when method is set to ‘gauss’. sigma gives the width of the gaussian used for convoluting datapoints.
Returns: - nbins :
-
measure_r
(self, data_name='brightfield', mode='max', in_place=True, **kwargs)[source]¶ Measure the radius of the cell.
The radius is found by the intensity-mid/min/max-point of the radial distribution derived from brightfield (default) or another data element.
Parameters: - data_name :
str
Name of the data element to use.
- mode :
str
Mode to find the radius. Can be either ‘min’, ‘mid’ or ‘max’ to use the minimum, middle or maximum value of the radial distribution, respectively.
- in_place :
bool
If True the found value of r is directly substituted in the cell’s coordinate system, otherwise the value is returned.
Returns: - radius :
float
The measured radius r if in_place is False, otherwise None.
- data_name :
-
optimize
(self, data_name='binary', cell_function=None, minimizer=<class 'symfit.core.minimizers.Powell'>, **kwargs)[source]¶ Optimize the cell’s coordinate system.
The optimization is performed on the data element given by
data_name
using the function cell_function. A default function depending on the data class is used of objective is omitted.Parameters: - data_name :
str
, optional Name of the data element to perform optimization on.
- cell_function
Optional subclass of
CellMinimizeFunctionBase
to use as objective function.- minimizer : Subclass of
symfit.core.minimizers.BaseMinimizer
orSequence
Minimizer to use for the optimization. Default is the
Powell
minimizer.- **kwargs :
Additional kwargs are passed to
execute()
.
Returns: - result :
FitResults
symfit
fit results object.
- data_name :
-
phi_dist
(self, step, data_name='', r_max=None, r_min=0, storm_weight=False, method='gauss', sigma=5)[source]¶ Calculates the angular distribution of signal for a given data element.
Parameters: - step :
float
Step size between datapoints.
- data_name :
str
Name of the data element to use.
- r_max :
float
, optional Datapoints within r_max from the cell midline will be included. If None the value from the cell’s coordinate system will be used.
- r_min :
float
, optional Datapoints outside of r_min from the cell midline will be included.
- storm_weight :
bool
If True the datapoints of the specified STORM-type data will be weighted by their intensity.
- method :
str
Method of averaging datapoints to calculate the final distribution curve.
- sigma :
float
Applies only when method is set to ‘gauss’. sigma gives the width of the gaussian used for convoluting datapoints.
Returns: - step :
-
r_dist
(self, stop, step, data_name='', norm_x=False, limit_l=None, storm_weight=False, method='gauss', sigma=0.3)[source]¶ Calculates the radial distribution of a given data element.
Parameters: - stop :
float
Until how far from the cell spine the radial distribution should be calculated.
- step :
float
The binsize of the returned radial distribution.
- data_name :
str
The name of the data element on which to calculate the radial distribution.
- norm_x :
bool
If True the returned distribution will be normalized with the cell’s radius set to 1.
- limit_l :
str
If None, all datapoints are used. This can be limited by providing the value full (omit poles only), ‘poles’ (include only poles), or a float value between 0 and 1 which will limit the data points by longitudinal coordinate around the midpoint of the cell.
- storm_weight :
bool
Only applicable for analyzing STORM-type data elements. If True the returned histogram is weighted with the values in the ‘Intensity’ field.
- method :
str
, either ‘gauss’ or ‘box’ Method of averaging datapoints to calculate the final distribution curve.
- sigma :
float
Applies only when method is set to ‘gauss’. sigma gives the width of the gaussian used for convoluting datapoints.
Returns: - stop :
-
reconstruct_image
(self, data_name, norm_x=False, r_scale=1, **kwargs)[source]¶ Reconstruct the image from a given data element and the cell’s current coordinate system.
Parameters: - data_name :
str
Name of the data element to use.
- norm_x :
bool
Boolean indicating whether or not to normalize to r=1.
- r_scale :
float
Stretch or compress the image in the radial direction by this factor. Values > 1 will compress the image.
- **kwargs
Optional keyword arguments are ‘stop’ and ‘step’ which are passed to r_dist.
Returns: - img :
ndarray
Image of the reconstructed cell.
- data_name :
- data_object :
-
class
colicoords.cell.
CellList
(cell_list)[source]¶ List equivalent of the
Cell
object.This Object holding a list of cell objects exposing several methods to either apply functions to all cells or to extract values from all cell objects. It supports iteration over Cell objects and Numpy-style array indexing.
Parameters: - cell_list :
list
ornumpy.ndarray
List of array of
Cell
objects.
Attributes: - cell_list :
ndarray
Numpy array of Cell objects
- data :
CellListData
Object with common attributes for all cells
Methods
append
(self, cell_obj)Append Cell object cell_obj to the list of cells. copy
(self)Make a copy of the CellList object and all its associated data elements. execute
(self, worker)Apply worker function worker to all cell objects and returns the results. execute_mp
(self, worker[, processes])Apply worker function worker to all cell objects and returns the results. get_intensity
(self[, mask, data_name, func])Returns the fluorescence intensity for each cell. l_classify
(self[, data_name])Classifies foci in STORM-type data by they x-position along the long axis. l_dist
(self, nbins[, start, stop, …])Calculates the longitudinal distribution of signal for a given data element for all cells. measure_r
(self[, data_name, mode, in_place])Measure the radius of the cells. optimize
(self[, data_name, cell_function, …])Optimize the cell’s coordinate system. optimize_mp
(self[, data_name, …])Optimize all cell’s coordinate systems using optimize through parallel computing. phi_dist
(self, step[, data_name, …])Calculates the angular distribution of signal for a given data element for all cells. r_dist
(self, stop, step[, data_name, …])Calculates the radial distribution for all cells of a given data element. -
append
(self, cell_obj)[source]¶ Append Cell object cell_obj to the list of cells.
Parameters: - cell_obj :
Cell
Cell object to append to current cell list.
- cell_obj :
-
copy
(self)[source]¶ Make a copy of the CellList object and all its associated data elements.
This is a deep copy meaning that all numpy data arrays are copied in memory and therefore modifying the copied cell objects does not modify the original cell objects.
Returns: - cell_list :
CellList
Copied CellList object
- cell_list :
-
execute
(self, worker)[source]¶ Apply worker function worker to all cell objects and returns the results.
Parameters: - worker :
callable
Worker function to be executed on all cell objects.
Returns: - res :
list
List of resuls returned from worker
- worker :
-
execute_mp
(self, worker, processes=None)[source]¶ Apply worker function worker to all cell objects and returns the results.
Parameters: Returns: - res :
list
List of results returned from
worker
.
- res :
-
get_intensity
(self, mask='binary', data_name='', func=<function mean at 0x7fdc6b3f5730>)[source]¶ Returns the fluorescence intensity for each cell.
Mean fluorescence intensity either in the region masked by the binary image or reconstructed binary image derived from the cell’s coordinate system. The default return value is the mean fluorescence intensity. Integrated intensity can be calculated by using func=np.sum.
Parameters: - mask :
str
Either ‘binary’ or ‘coords’ to specify the source of the mask used. ‘binary’ uses the binary image as mask, ‘coords’ uses reconstructed binary from coordinate system
- data_name :
str
The name of the image data element to get the intensity values from.
- func :
callable
This function is applied to the data elements pixels selected by the masking operation. The default is np.mean().
Returns: - value :
float
Mean fluorescence pixel value.
- mask :
-
l_classify
(self, data_name='')[source]¶ Classifies foci in STORM-type data by they x-position along the long axis.
The spots are classified into 3 categories: ‘poles’, ‘between’ and ‘mid’. The pole category are spots who are to the left and right of xl and xr, respectively. The class ‘mid’ is a section in the middle of the cell with a total length of half the cell’s length, the class ‘between’ is the remaining two quarters between ‘mid’ and ‘poles’
Parameters: - data_name :
str
Name of the STORM-type data element to classify. When its not specified the first STORM data element is used.
Returns: - array :
ndarray
Array of tuples with number of spots in poles, between and mid classes, respectively.
- data_name :
-
l_dist
(self, nbins, start=None, stop=None, data_name='', norm_x=True, method='gauss', r_max=None, storm_weight=False, sigma=None)[source]¶ Calculates the longitudinal distribution of signal for a given data element for all cells.
Normalization by cell length is enabled by default to remove cell-to-cell variations in length.
Parameters: - nbins :
int
Number of bins between start and stop.
- start :
float
Distance from xl as starting point for the distribution, units are either pixels or normalized units if norm_x=True.
- stop :
float
Distance from xr as end point for the distribution, units are are either pixels or normalized units if norm_x=True.
- data_name :
str
Name of the data element to use.
- norm_x :
bool
If True the output distribution will be normalized.
- r_max :
float
, optional Datapoints within r_max from the cell midline will be included. If None the value from the cell’s coordinate system will be used.
- storm_weight :
bool
If True the datapoints of the specified STORM-type data will be weighted by their intensity.
- method :
str
Method of averaging datapoints to calculate the final distribution curve.
- sigma :
float
or array_like Applies only when method is set to ‘gauss’. sigma gives the width of the gaussian used for convoluting datapoints. To use a different sigma for each cell sigma can be given as a list or array.
Returns: - nbins :
-
measure_r
(self, data_name='brightfield', mode='max', in_place=True, **kwargs)[source]¶ Measure the radius of the cells.
The radius is found by the intensity-mid/min/max-point of the radial distribution derived from brightfield (default) or another data element.
Parameters: - data_name :
str
Name of the data element to use.
- mode :
str
Mode to find the radius. Can be either ‘min’, ‘mid’ or ‘max’ to use the minimum, middle or maximum value of the radial distribution, respectively.
- in_place :
bool
If True the found value of r is directly substituted in the cell’s coordinate system, otherwise the value is returned.
Returns: - radius :
np.ndarray
The measured radius r values if in_place is False, otherwise None.
- data_name :
-
optimize
(self, data_name='binary', cell_function=None, minimizer=<class 'symfit.core.minimizers.Powell'>, **kwargs)[source]¶ Optimize the cell’s coordinate system.
The optimization is performed on the data element given by
data_name
using objective function objective. A default depending on the data class is used of objective is omitted.Parameters: - data_name :
str
, optional Name of the data element to perform optimization on.
- cell_function
Optional subclass of
CellMinimizeFunctionBase
to use as objective function.- minimizer : Subclass of
symfit.core.minimizers.BaseMinimizer
orSequence
Minimizer to use for the optimization. Default is the
Powell
minimizer.- **kwargs :
Additional kwargs are passed to
execute()
.
Returns: - res_list :
list
ofFitResults
List of symfit
FitResults
object.
- data_name :
-
optimize_mp
(self, data_name='binary', cell_function=None, minimizer=<class 'symfit.core.minimizers.Powell'>, processes=None, **kwargs)[source]¶ Optimize all cell’s coordinate systems using optimize through parallel computing.
A call to this method must be protected by if __name__ == ‘__main__’ if its not executed in jupyter notebooks.
Parameters: - data_name :
str
, optional Name of the data element to perform optimization on.
- cell_function
Optional subclass of
CellMinimizeFunctionBase
to use as objective function.- minimizer : Subclass of
symfit.core.minimizers.BaseMinimizer
orSequence
Minimizer to use for the optimization. Default is the
Powell
minimizer.- processes :
int
Number of parallel processes to spawn. Default is the number of logical processors on the host machine.
- **kwargs :
Additional kwargs are passed to
execute()
.
Returns: - res_list :
list
ofFitResults
List of symfit
FitResults
object.
- data_name :
-
phi_dist
(self, step, data_name='', storm_weight=False, method='gauss', sigma=5, r_max=None, r_min=0)[source]¶ Calculates the angular distribution of signal for a given data element for all cells.
Parameters: - step :
float
Step size between datapoints.
- data_name :
str
Name of the data element to use.
- r_max :
float
, optional Datapoints within r_max from the cell midline will be included. If None the value from the cell’s coordinate system will be used.
- r_min :
float
, optional Datapoints outside of r_min from the cell midline will be included.
- storm_weight :
bool
If True the datapoints of the specified STORM-type data will be weighted by their intensity.
- method :
str
Method of averaging datapoints to calculate the final distribution curve.
- sigma :
float
Applies only when method is set to ‘gauss’. sigma gives the width of the gaussian used for convoluting datapoints.
Returns: - step :
-
r_dist
(self, stop, step, data_name='', norm_x=False, limit_l=None, storm_weight=False, method='gauss', sigma=0.3)[source]¶ Calculates the radial distribution for all cells of a given data element.
Parameters: - stop :
float
Until how far from the cell spine the radial distribution should be calculated
- step :
float
The binsize of the returned radial distribution
- data_name :
str
The name of the data element on which to calculate the radial distribution
- norm_x :
bool
If True the returned distribution will be normalized with the cell’s radius set to 1.
- limit_l :
str
If None, all datapoints are used. This can be limited by providing the value full (omit poles only), ‘poles’ (include only poles), or a float value between 0 and 1 which will limit the data points by longitudinal coordinate around the midpoint of the cell.
- storm_weight :
bool
Only applicable for analyzing STORM-type data elements. If True the returned histogram is weighted with the values in the ‘Intensity’ field.
- method :
str
, either ‘gauss’ or ‘box’ Method of averaging datapoints to calculate the final distribution curve.
- sigma :
float
Applies only when method is set to ‘gauss’. sigma gives the width of the gaussian used for convoluting datapoints
Returns: - stop :
- cell_list :
-
class
colicoords.cell.
Coordinates
(data, initialize=True, **kwargs)[source]¶ Cell’s coordinate system described by the polynomial p(x) and associated functions.
Parameters: Attributes: Methods
calc_lc
(self, xp, yp)Calculates distance of xc along the midline the cell corresponding to the points (xp, yp). calc_perimeter
(self, xp, yp)Calculates how far along the perimeter of the cell the points (xp, yp) lay. calc_phi
(self, xp, yp)Calculates the angle between the line perpendical to the cell midline and the line between (xp, yp) and (xc, p(xc)). calc_rc
(self, xp, yp)Calculates the distance of (xp, yp) to (xc, p(xc)). calc_xc
(self, xp, yp)Calculates the coordinate xc on p(x) closest to xp, yp. calc_xc_mask
(self, xp, yp)Calculated whether point (xp, yp) is in either the left or right polar areas, or in between. calc_xc_masked
(self, xp, yp)Calculates the coordinate xc on p(x) closest to (xp, yp), where xl < xc < xr. full_transform
(self, xp, yp)Transforms image coordinates (xp, yp) to cell coordinates (xc, lc, rc, psi). get_core_points
(self[, xl, xr])Returns the coordinates of the roughly estimated ‘core’ points of the cell. get_idx_xc
(self, xp, yp)Finds the indices of the arrays xp an yp where they either belong to the left or right polar regions, as well as coordinates xc. p
(self, x_arr)Calculate p(x). p_dx
(self, x_arr)Calculate the derivative p’(x) evaluated at x. q
(self, x, xp)array_like: Returns q(x) where q(x) is the line perpendicular to p(x) at xp rev_calc_perimeter
(self, par_values)For a given distance along the perimeter calculate the xp, yp cartesian coordinates. rev_transform
(self, lc, rc, phi[, l_norm])Reverse transform from cellular coordinates lc, rc, phi to cartesian coordinates xp, yp. sub_par
(self, par_dict)Substitute the values in par_dict as the coordinate systems parameters. transform
(self, xp, yp)Transforms image coordinates (xp, yp) to cell coordinates (lc, rc, psi) -
a0
¶ float: Polynomial p(x) 0th degree coefficient.
-
a1
¶ float: Polynomial p(x) 1st degree coefficient.
-
a2
¶ float: Polynomial p(x) 2nd degree coefficient.
-
calc_lc
(self, xp, yp)[source]¶ Calculates distance of xc along the midline the cell corresponding to the points (xp, yp).
The returned value is the distance from the points (xp, yp) to the midline of the cell.
Parameters: Returns:
-
calc_perimeter
(self, xp, yp)[source]¶ Calculates how far along the perimeter of the cell the points (xp, yp) lay.
The perimeter of the cell is the current outline as described by the current coordinate system. The zero-point is the top-left point where the top membrane section starts (lc=0, phi=0) and increases along the perimeter clockwise.
Parameters: Returns:
-
calc_phi
(self, xp, yp)[source]¶ Calculates the angle between the line perpendical to the cell midline and the line between (xp, yp) and (xc, p(xc)).
The returned values are in degrees. The angle is defined to be 0 degrees for values in the upper half of the image (yp < p(xp)), running from 180 to zero along the right polar region, 180 degrees in the lower half and running back to 0 degrees along the left polar region.
Parameters: Returns:
-
calc_rc
(self, xp, yp)[source]¶ Calculates the distance of (xp, yp) to (xc, p(xc)).
The returned value is the distance from the points (xp, yp) to the midline of the cell.
Parameters: Returns:
-
calc_xc
(self, xp, yp)[source]¶ Calculates the coordinate xc on p(x) closest to xp, yp.
All coordinates are cartesian. Solutions are found by solving the cubic equation.
Parameters: Returns:
-
calc_xc_mask
(self, xp, yp)[source]¶ Calculated whether point (xp, yp) is in either the left or right polar areas, or in between.
Returned values are 1 for left pole, 2 for middle, 3 for right pole.
Parameters: Returns:
-
calc_xc_masked
(self, xp, yp)[source]¶ Calculates the coordinate xc on p(x) closest to (xp, yp), where xl < xc < xr.
Parameters: Returns:
-
full_transform
(self, xp, yp)[source]¶ Transforms image coordinates (xp, yp) to cell coordinates (xc, lc, rc, psi).
Parameters: Returns: - coordinates :
tuple
Tuple of cellular coordinates xc, lc, rc, psi.
- coordinates :
-
get_core_points
(self, xl=None, xr=None)[source]¶ Returns the coordinates of the roughly estimated ‘core’ points of the cell.
Used for determining the initial guesses for the coefficients of p(x).
Parameters: Returns: - xvals :
np.ndarray
Array of x coordinates of ‘core’ points.
- yvals :
np.ndarray
Array of y coordinates of ‘core’ points.
- xvals :
-
get_idx_xc
(self, xp, yp)[source]¶ Finds the indices of the arrays xp an yp where they either belong to the left or right polar regions, as well as coordinates xc.
Parameters: Returns:
-
p
(self, x_arr)[source]¶ Calculate p(x).
The function p(x) describes the midline of the cell.
Parameters: - x_arr :
ndarray
Input x values.
Returns: - p :
ndarray
Evaluated polynomial p(x)
- x_arr :
-
p_dx
(self, x_arr)[source]¶ Calculate the derivative p’(x) evaluated at x.
Parameters: - x_arr :class:`~numpy.ndarray`:
Input x values.
Returns: - p_dx :
ndarray
Evaluated function p’(x).
-
rev_calc_perimeter
(self, par_values)[source]¶ For a given distance along the perimeter calculate the xp, yp cartesian coordinates.
Parameters: Returns:
-
rev_transform
(self, lc, rc, phi, l_norm=True)[source]¶ Reverse transform from cellular coordinates lc, rc, phi to cartesian coordinates xp, yp.
Parameters: Returns:
-
sub_par
(self, par_dict)[source]¶ Substitute the values in par_dict as the coordinate systems parameters.
Parameters: - par_dict :
dict
Dictionary with parameters which values are set to the attributes.
- par_dict :
-
transform
(self, xp, yp)[source]¶ Transforms image coordinates (xp, yp) to cell coordinates (lc, rc, psi)
Parameters: Returns: - coordinates :
tuple
Tuple of cellular coordinates lc, rc, psi
- coordinates :
-
x_coords
¶ ndarray`
: Matrix of shape m x n equal to cell image with cartesian x-coordinates.
-
xc_mask
¶ ndarray
: Matrix of shape m x n equal to cell image where elements have values 1, 2, 3 for left pole, middle and right pole, respectively.
-
-
colicoords.cell.
calc_lc
(xl, xr, coeff)[source]¶ Calculate lc.
The returned length is the arc length from xl to xr integrated along the polynomial p(x) described by coeff.
Parameters: - xl : array_like
Left bound to calculate arc length from. Shape must be compatible with xl.
- xr : array_like
Right bound to calculate arc length to. Shape must be compatible with xr.
- coeff : array_like or
tuple
Array or tuple with coordinate polynomial coefficients a0, a1, a2.
Returns: - l : array_like
Calculated length lc.
-
colicoords.cell.
optimize_worker
(cell, **kwargs)[source]¶ Worker object for optimize multiprocessing.
Parameters: - cell :
Cell
Cell object to optimize.
- **kwargs
Additional keyword arguments passed to
optimize()
Returns: - result :
FitResults
- cell :
-
colicoords.cell.
solve_general
(a, b, c, d)[source]¶ Solve cubic polynomial in the form a*x^3 + b*x^2 + c*x + d.
Only works if polynomial discriminant < 0, then there is only one real root which is the one that is returned. [1]
Parameters: - a : array_like
Third order polynomial coefficient.
- b : array_like
Second order polynomial coefficient.
- c : array_like
First order polynomial coefficient.
- d : array_like
Zeroth order polynomial coefficient.
Returns: - array : array_like
Real root solution.
[1] https://en.wikipedia.org/wiki/Cubic_function#General_formula ..
-
colicoords.cell.
solve_length
(xr, xl, coeff, length)[source]¶ Used to find xc in reverse coordinate transformation.
Function used to find cellular x coordinate xr where the arc length from xl to xr is equal to length given a coordinate system with coeff as coefficients.
Parameters: Returns: - diff :
float
Difference between calculated length and specified length.
- diff :
-
colicoords.cell.
solve_trig
(a, b, c, d)[source]¶ Solve cubic polynomial in the form a*x^3 + b*x^2 + c*x + d Only for polynomial discriminant > 0, the polynomial has three real roots [1]
Parameters: - a : array_like
Third order polynomial coefficient.
- b : array_like
Second order polynomial coefficient.
- c : array_like
First order polynomial coefficient.
- d : array_like
Zeroth order polynomial coefficient.
Returns: - array : array_like
First real root solution.
[1] https://en.wikipedia.org/wiki/Cubic_function#Trigonometric_solution_for_three_real_roots ..
Data¶
-
class
colicoords.data_models.
CellListData
(cell_list)[source]¶ Data class for CellList with common attributes for all cells. Individual data elements are accessed per cell.
Parameters: - cell_list :
list
ornumpy.ndarray
List of array of
Cell
objects.
Attributes: -
dclasses
¶ list
: List of all data classes in theData
objects of the cells, if all are equal, else None.
-
names
¶ list
: List of all data names in theData
objects of the cells, if all are equal, else None.
- cell_list :
-
class
colicoords.data_models.
Data
[source]¶ Main data class holding data from different input channels.
The data class is designed to combine and organize all different channels (brightfield, binary, fluorescence, storm) into one object. The class provides basic functionality such as rotation and slicing.
Data elements can be accessed from data_dict or by attribute ‘<class>_<name>’, where class can be either ‘flu’, ‘storm’. Binary and brightfield can bre accessed as properties.
Attributes: Methods
add_data
(self, data, dclass[, name, metadata])Add data to form a new data element. copy
(self)Copy the data object. prune
(self, data_name)Removes localizations from the STORM-dataset with name data_name which lie outside of the associated image. rotate
(self, theta)Rotate all data elements and return a new Data
object with rotated data elements.next -
add_data
(self, data, dclass, name=None, metadata=None)[source]¶ Add data to form a new data element.
Parameters: - data : array_like
Input data. Either np.ndarray with ndim 2 or 3 (images / movies) or numpy structured array for STORM data.
- dclass :
str
Data class. Must be either ‘binary’, ‘brightfield’, ‘fluorescence’ or ‘storm’.
- name :
str
, optional The name to identify the data element. Default is equal to the data class.
- metadata :
dict
Associated metadata (load/save metadata currently not supported)
-
bf_img
¶ ndarray
: Returns the brightfield image if present, elseNone
-
binary_img
¶ ndarray
: Returns the binary image if present, elseNone
-
dclasses
¶ list
: List of all data classes in theData
object.
-
names
¶ list
: List of all data names in theData
object.
-
prune
(self, data_name)[source]¶ Removes localizations from the STORM-dataset with name data_name which lie outside of the associated image.
Parameters: - data_name :
str
Name of the data element to prune.
Returns: - None
- data_name :
-
rotate
(self, theta)[source]¶ Rotate all data elements and return a new
Data
object with rotated data elements.Parameters: - theta :
float
Rotation angle in degrees.
Returns: - data :
colicoords.data_models.Data
Rotated
Data
- theta :
-
-
class
colicoords.data_models.
MetaData
() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)[source]¶
Plot¶
-
class
colicoords.plot.
CellListPlot
(cell_list)[source]¶ Object for plotting single-cell derived data
Parameters: - cell_list :
CellList
CellList
object withCell
objects to plot.
Methods
figure
()Calls matplotlib.pyplot.figure() hist_intensity
(self[, mask, data_name, ax])Histogram all cell’s mean fluorescence intensity. hist_l_storm
(self[, data_name, ax])Makes a histogram of the longitudinal distribution of localizations. hist_phi_storm
(self[, ax, data_name])Makes a histogram of the angular distribution of localizations at the poles. hist_property
(self[, prop, ax])Plot a histogram of a given geometrical property. hist_r_storm
(self[, data_name, ax, norm_x, …])Makes a histogram of the radial distribution of localizations. plot_kymograph
(self[, mode, data_name, ax, …])Plot a kymograph of a chosen axis distribution for a given data element. plot_l_class
(self[, data_name, ax, yerr])Plots a bar chart of how many foci are in a given STORM data set in classes depending on x-position. plot_l_dist
(self[, ax, data_name, r_max, …])Plots the longitudinal distribution of a given data element. plot_phi_dist
(self[, ax, data_name, r_max, …])Plots the angular distribution of a given data element for all cells. plot_r_dist
(self[, ax, data_name, norm_x, …])Plots the radial distribution of a given data element. savefig
(\*args, \*\*kwargs)Calls matplotlib.pyplot.savefig(*args, **kwargs) show
()Calls matplotlib.pyplot.show() get_r_dist -
hist_intensity
(self, mask='binary', data_name='', ax=None, **kwargs)[source]¶ Histogram all cell’s mean fluorescence intensity. Intensities values are calculated by calling
Cell.get_intensity()
Parameters: - mask :
str
Either ‘binary’ or ‘coords’ to specify the source of the mask used ‘binary’ uses the binary images as mask, ‘coords’ uses reconstructed binary from coordinate system.
- data_name :
str
The name of the image data element to get the intensity values from.
- ax :
matplotlib.axes.Axes
, optinal Matplotlib axes to use for plotting.
- **kwargs
Additional kwargs passed to
ax.hist()
.
Returns: - tuple :
tuple
Return value is a tuple with n, bins, patches as returned by
hist()
.
- mask :
-
hist_l_storm
(self, data_name='', ax=None, **kwargs)[source]¶ Makes a histogram of the longitudinal distribution of localizations.
All cells are normalized by rescaling the longitudinal coordinates by the lenght of the cells. Polar regions are normalized by rescaling with the mean of the length of all cells to ensure uniform scaling of polar regions.
Parameters: - data_name :
str
, optional Name of the STORM data element to histogram. If omitted, the first STORM element is used.
- ax :
matplotlib.axes.Axes
Matplotlib axes to use for plotting.
- **kwargs
Additional kwargs passed to
ax.hist()
Returns: - data_name :
-
hist_phi_storm
(self, ax=None, data_name='', **kwargs)[source]¶ Makes a histogram of the angular distribution of localizations at the poles.
Parameters: - data_name :
str
, optional Name of the STORM data element to histogram. If omitted, the first STORM element is used.
- ax :
matplotlib.axes.Axes
Matplotlib axes to use for plotting.
- **kwargs
Additional kwargs passed to
ax.hist()
Returns: - data_name :
-
hist_property
(self, prop='length', ax=None, **kwargs)[source]¶ Plot a histogram of a given geometrical property.
Parameters: Returns: - tuple :
tuple
Return value is a tuple with n, bins, patches as returned by
hist()
.
- tuple :
-
hist_r_storm
(self, data_name='', ax=None, norm_x=True, limit_l=None, **kwargs)[source]¶ Makes a histogram of the radial distribution of localizations.
Parameters: - data_name :
str
, optional Name of the STORM data element to histogram. If omitted, the first STORM element is used.
- ax :
matplotlib.axes.Axes
Matplotlib axes to use for plotting.
- norm_x :
bool
If True all radial distances are normalized by dividing by the radius of the individual cells.
- limit_l :
str
If None, all datapoints are used. This can be limited by providing the value full (omit poles only), ‘poles’ (include only poles), or a float value between 0 and 1 which will limit the data points by longitudinal coordinate around the midpoint of the cell.
- **kwargs
Additional kwargs passed to
ax.hist()
Returns: - data_name :
-
plot_kymograph
(self, mode='r', data_name='', ax=None, time_factor=1, time_unit='frames', dist_kwargs=None, norm_y=True, aspect=1, **kwargs)[source]¶ Plot a kymograph of a chosen axis distribution for a given data element.
Each cell in the the
CellList
represents one point in time, where the first time point is the first cell in the list.Parameters: - ax :
matplotlib.axes.Axes
, optional Matplotlib axes to use for plotting.
- mode :
str
Axis of distribution to plot. Options are ‘r’, ‘l’ or ‘a’. Currently only ‘r’ is implemented.
- data_name :
str
Name of the data element to plot. Must be a 3D array
- time_factor :
float
Time factor per frame.
- time_unit :
str
Time unit.
- dist_kwargs :
dict
Additional kwargs passed to the function getting the distribution.
- norm_y :
bool
If True the output kymograph is normalized frame-wise.
- aspect :
float
Aspect ratio of output kymograph image.
- **kwargs
Additional keyword arguments passed to ax.imshow()
Returns: - image :
matplotlib.image.AxesImage
Matplotlib image artist object
- ax :
-
plot_l_class
(self, data_name='', ax=None, yerr='std', **kwargs)[source]¶ Plots a bar chart of how many foci are in a given STORM data set in classes depending on x-position.
Parameters: - data_name :
str
Name of the data element to plot. Must have the data class ‘storm’.
- ax :
matplotlib.axes.Axes
Matplotlib axes to use for plotting.
- yerr :
str
How to calculated error bars. Can be ‘std’ or ‘sem’ for standard deviation or standard error of the mean, respectively.
- **kwargs
Optional kwargs passed to ax.bar().
Returns: - container :
BarContainer
Container with all the bars.
- data_name :
-
plot_l_dist
(self, ax=None, data_name='', r_max=None, norm_y=False, zero=False, storm_weight=False, band_func=<function std at 0x7fdc6b3f58c8>, method='gauss', dist_kwargs=None, **kwargs)[source]¶ Plots the longitudinal distribution of a given data element.
The data is normalized along the long axis to allow the combining of multiple cells with different lengths.
Parameters: - ax :
matplotlib.axes.Axes
, optional Matplotlib axes to use for plotting.
- data_name :
str
Name of the data element to use.
- r_max :
float
Datapoints within r_max from the cell midline are included. If None the value from the cell’s coordinate system will be used.
- norm_y :
bool
If True the output data will be normalized in the y (intensity).
- zero :
bool
If True the output data will be zeroed.
- storm_weight :
bool
If True the datapoints of the specified STORM-type data will be weighted by their intensity.
- band_func :
callable
Callable to determine the fill area around the graph. Default is standard deviation.
- method :
str
, either ‘gauss’ or ‘box’ Method of averaging datapoints to calculate the final distribution curve.
- dist_kwargs :
dict
Additional kwargs to be passed to
l_dist()
- **kwargs
Optional kwargs passed to ax.plot()
Returns: - line
Line2D
Matplotlib line artist object
- ax :
-
plot_phi_dist
(self, ax=None, data_name='', r_max=None, r_min=0, storm_weight=False, band_func=<function std at 0x7fdc6b3f58c8>, method='gauss', dist_kwargs=None, **kwargs)[source]¶ Plots the angular distribution of a given data element for all cells.
Parameters: - ax :
matplotlib.axes.Axes
, optional Matplotlib axes to use for plotting.
- data_name :
str
Name of the data element to use.
- r_max: :
float
Datapoints within r_max from the cell midline are included. If None the value from the cell’s coordinate system will be used.
- r_min: :
float
Datapoints outside of r_min from the cell midline are included.
- storm_weight :
bool
If True the datapoints of the specified STORM-type data will be weighted by their intensity.
- band_func :
callable
Callable to determine the fill area around the graph. Default is standard deviation.
- method :
str
: Method of averaging datapoints to calculate the final distribution curve.
- dist_kwargs :
dict
Additional kwargs to be passed to
phi_dist()
Returns: - lines :
tuple
Tuple with Matplotlib line artist objects.
- ax :
-
plot_r_dist
(self, ax=None, data_name='', norm_x=False, norm_y=False, zero=False, storm_weight=False, limit_l=None, method='gauss', band_func=<function std at 0x7fdc6b3f58c8>, **kwargs)[source]¶ Plots the radial distribution of a given data element.
Parameters: - ax :
matplotlib.axes.Axes
Optional matplotlib axes to use for plotting.
- data_name :
str
Name of the data element to use.
- norm_x: :
bool
If True the output distribution will be normalized along the length axis.
- norm_y: :
bool
If True the output data will be normalized in the y (intensity).
- zero :
bool
If True the output data will be zeroed.
- storm_weight :
bool
If True the datapoints of the specified STORM-type data will be weighted by their intensity.
- limit_l :
str
If None, all datapoints are taking into account. This can be limited by providing the value full (omit poles only), ‘poles’ (include only poles), or a float value which will limit the data points with around the midline where xmid - xlim < x < xmid + xlim.method :
str
, either ‘gauss’ or ‘box’- method :
str
, either ‘gauss’ or ‘box’ Method of averaging datapoints to calculate the final distribution curve.
- band_func :
callable
Callable to determine the fill area around the graph. Default is standard deviation.
- **kwargs
Optional kwargs passed to ax.plot().
Returns: Line2D
Matplotlib line artist object
- ax :
- cell_list :
-
class
colicoords.plot.
CellPlot
(cell_obj)[source]¶ Object for plotting single-cell derived data.
Parameters: - cell_obj :
Cell
Single-cell object to plot.
Attributes: - cell_obj :
Cell
Single-cell object to plot.
Methods
figure
(\*args, \*\*kwargs)Calls matplotlib.pyplot.figure()
hist_l_storm
(self[, data_name, ax, norm_x])Makes a histogram of the longitudinal distribution of localizations. hist_phi_storm
(self[, ax, data_name])Makes a histogram of the angular distribution of localizations at the poles. hist_r_storm
(self[, data_name, ax, norm_x, …])Makes a histogram of the radial distribution of localizations. imshow
(self, img[, ax])Call to matplotlib’s imshow. plot_bin_fit_comparison
(self[, ax])Plot the cell’s binary image together with the calculated binary image from the coordinate system. plot_binary_img
(self[, ax])Plot the cell’s binary image. plot_kymograph
(self[, ax, mode, data_name, …])Plot a kymograph of a chosen axis distribution for a given data element. plot_l_class
(self[, ax, data_name])Plots a bar chart of how many foci are in a given STORM data set in classes depending on x-position. plot_l_dist
(self[, ax, data_name, r_max, …])Plots the longitudinal distribution of a given data element. plot_midline
(self[, ax])Plot the cell’s coordinate system midline. plot_outline
(self[, ax])Plot the outline of the cell based on the current coordinate system. plot_phi_dist
(self[, ax, data_name, r_max, …])Plots the angular distribution of a given data element. plot_r_dist
(self[, ax, data_name, norm_x, …])Plots the radial distribution of a given data element. plot_simulated_binary
(self[, ax])Plot the cell’s binary image calculated from the coordinate system. plot_storm
(self[, ax, data_name, method, …])Graphically represent STORM data. savefig
(\*args, \*\*kwargs)Calls matplotlib.pyplot.savefig()
show
(\*args, \*\*kwargs)Calls matplotlib.pyplot.show()
get_r_dist -
hist_l_storm
(self, data_name='', ax=None, norm_x=True, **kwargs)[source]¶ Makes a histogram of the longitudinal distribution of localizations.
Parameters: - data_name :
str
, optional Name of the STORM data element to histogram. If omitted, the first STORM element is used.
- ax :
matplotlib.axes.Axes
Matplotlib axes to use for plotting.
- norm_x :
bool
Normalizes the longitudinal distribution by dividing by the length of the cell.
- **kwargs
Additional kwargs passed to ax.hist()
Returns: - data_name :
-
hist_phi_storm
(self, ax=None, data_name='', **kwargs)[source]¶ Makes a histogram of the angular distribution of localizations at the poles.
Parameters: - data_name :
str
, optional Name of the STORM data element to histogram. If omitted, the first STORM element is used.
- ax :
matplotlib.axes.Axes
Matplotlib axes to use for plotting.
- **kwargs
Additional kwargs passed to ax.hist()
Returns: - data_name :
-
hist_r_storm
(self, data_name='', ax=None, norm_x=True, limit_l=None, **kwargs)[source]¶ Makes a histogram of the radial distribution of localizations.
Parameters: - data_name :
str
, optional Name of the STORM data element to histogram. If omitted, the first STORM element is used.
- ax :
matplotlib.axes.Axes
Matplotlib axes to use for plotting.
- norm_x :
bool
If True all radial distances are normalized by dividing by the radius of the individual cells.
- limit_l :
str
If None, all datapoints are taking into account. This can be limited by providing the value full (omit poles only), ‘poles’ (include only poles), or a float value which will limit the data points with around the midline where xmid - xlim < x < xmid + xlim.method :
str
, either ‘gauss’ or ‘box’- **kwargs
Additional kwargs passed to ax.hist()
Returns: - data_name :
-
imshow
(self, img, ax=None, **kwargs)[source]¶ Call to matplotlib’s imshow.
Default extent keyword arguments is provided to assure proper overlay of pixel and carthesian coordinates.
Parameters: - img :
str
orndarray
Image to show. It can be either a data name of the image-type data element to plot or a 2D numpy ndarray.
- ax :
matplotlib.axes.Axes
Optional matplotlib axes to use for plotting.
- **kwargs:
Additional kwargs passed to ax.imshow().
Returns: - image :
matplotlib.image.AxesImage
Matplotlib image artist object.
- img :
-
plot_bin_fit_comparison
(self, ax=None, **kwargs)[source]¶ Plot the cell’s binary image together with the calculated binary image from the coordinate system.
Parameters: - ax :
matplotlib.axes.Axes
, optional Matplotlib axes to use for plotting.
- **kwargs
Additional kwargs passed to ax.plot().
Returns: - image :
AxesImage
Matplotlib image artist object.
- ax :
-
plot_binary_img
(self, ax=None, **kwargs)[source]¶ Plot the cell’s binary image.
Equivalent to
CellPlot.imshow('binary')
.Parameters: - ax :
matplotlib.axes.Axes
, optional Optional matplotlib axes to use for plotting
- **kwargs
Additional kwargs passed to ax.imshow().
Returns: - image :
AxesImage
Matplotlib image artist object
- ax :
-
plot_kymograph
(self, ax=None, mode='r', data_name='', time_factor=1, time_unit='frames', dist_kwargs=None, norm_y=True, aspect=1, **kwargs)[source]¶ Plot a kymograph of a chosen axis distribution for a given data element.
The data element must be a 3D array (t, y, x) where the first axis is the time dimension.
Parameters: - ax :
matplotlib.axes.Axes
, optional Matplotlib axes to use for plotting.
- mode :
str
Axis of distribution to plot. Options are ‘r’, ‘l’ or ‘a’. Currently only ‘r’ is implemented.
- data_name :
str
Name of the data element to plot. Must be a 3D array
- time_factor :
float
Time factor per frame.
- time_unit :
str
Time unit.
- dist_kwargs :
dict
Additional kwargs passed to the function getting the distribution.
- norm_y :
bool
If True the output kymograph is normalized frame-wise.
- aspect :
float
Aspect ratio of output kymograph image.
- **kwargs
Additional keyword arguments passed to ax.imshow()
Returns: - image :
matplotlib.image.AxesImage
Matplotlib image artist object
- ax :
-
plot_l_class
(self, ax=None, data_name='', **kwargs)[source]¶ Plots a bar chart of how many foci are in a given STORM data set in classes depending on x-position.
Parameters: - ax :
matplotlib.axes.Axes
, optional Matplotlib axes to use for plotting.
- data_name :
str
Name of the data element to plot. Must have the data class ‘storm’.
- **kwargs
Optional kwargs passed to ax.bar().
Returns: - container :
BarContainer
Container with all the bars.
- ax :
-
plot_l_dist
(self, ax=None, data_name='', r_max=None, norm_x=False, norm_y=False, zero=False, storm_weight=False, method='gauss', dist_kwargs=None, **kwargs)[source]¶ Plots the longitudinal distribution of a given data element.
Parameters: - ax :
matplotlib.axes.Axes
, optional Matplotlib axes to use for plotting.
- data_name :
str
Name of the data element to use.
- r_max: :
float
Datapoints within r_max from the cell midline are included. If None the value from the cell’s coordinate system will be used.
- norm_x :
bool
If True the output distribution will be normalized along the length axis.
- norm_y: :
bool
If True the output data will be normalized in the y (intensity).
- zero :
bool
If True the output data will be zeroed.
- storm_weight :
bool
If True the datapoints of the specified STORM-type data will be weighted by their intensity.
- method :
str
: Method of averaging datapoints to calculate the final distribution curve.
- dist_kwargs :
dict
Additional kwargs to be passed to
l_dist()
Returns: - line :
Line2D
Matplotlib line artist object.
- ax :
-
plot_midline
(self, ax=None, **kwargs)[source]¶ Plot the cell’s coordinate system midline.
Parameters: - ax :
Axes
, optional Matplotlib axes to use for plotting.
- **kwargs
Additional kwargs passed to ax.plot().
Returns: - line :
Line2D
Matplotlib line artist object
- ax :
-
plot_outline
(self, ax=None, **kwargs)[source]¶ Plot the outline of the cell based on the current coordinate system.
The outline consists of two semicircles and two offset lines to the central parabola.[R114d31aa08a4-1]_[R114d31aa08a4-2]_
Parameters: - ax :
Axes
, optional Matplotlib axes to use for plotting.
- **kwargs
Additional kwargs passed to ax.plot().
Returns: - line :
Line2D
Matplotlib line artist object.
[1] T. W. Sederberg. “Computer Aided Geometric Design”. Computer Aided Geometric Design Course Notes. January 10, 2012
[2] Rida T.Faroukia, Thomas W. Sederberg, Analysis of the offset to a parabola, Computer Aided Geometric Design vol 12, issue 6, 1995
- ax :
-
plot_phi_dist
(self, ax=None, data_name='', r_max=None, r_min=0, storm_weight=False, method='gauss', dist_kwargs=None, **kwargs)[source]¶ Plots the angular distribution of a given data element.
Parameters: - ax :
matplotlib.axes.Axes
, optional Matplotlib axes to use for plotting.
- data_name :
str
Name of the data element to use.
- r_max: :
float
Datapoints within r_max from the cell midline are included. If None the value from the cell’s coordinate system will be used.
- r_min: :
float
Datapoints outside of r_min from the cell midline are included.
- storm_weight :
bool
If True the datapoints of the specified STORM-type data will be weighted by their intensity.
- method :
str
: Method of averaging datapoints to calculate the final distribution curve.
- dist_kwargs :
dict
Additional kwargs to be passed to
phi_dist()
Returns: - lines :
tuple
Tuple with Matplotlib line artist objects.
- ax :
-
plot_r_dist
(self, ax=None, data_name='', norm_x=False, norm_y=False, zero=False, storm_weight=False, limit_l=None, method='gauss', dist_kwargs=None, **kwargs)[source]¶ Plots the radial distribution of a given data element.
Parameters: - ax :
Axes
, optional Matplotlib axes to use for plotting.
- data_name :
str
Name of the data element to use.
- norm_x :
bool
If True the output distribution will be normalized along the length axis.
- norm_y: :
bool
If True the output data will be normalized in the y (intensity).
- zero :
bool
If True the output data will be zeroed.
- storm_weight :
bool
If True the datapoints of the specified STORM-type data will be weighted by their intensity.
- limit_l :
str
If None, all datapoints are used. This can be limited by providing the value full (omit poles only), ‘poles’ (include only poles), or a float value between 0 and 1 which will limit the data points by longitudinal coordinate around the midpoint of the cell.
- method :
str
Method of averaging datapoints to calculate the final distribution curve.
- dist_kwargs :
dict
Additional kwargs to be passed to
colicoords.cell.Cell.r_dist()
- **kwargs
Optional kwargs passed to
ax.plot()
.
Returns: - line :
Line2D
Matplotlib line artist object
- ax :
-
plot_simulated_binary
(self, ax=None, **kwargs)[source]¶ Plot the cell’s binary image calculated from the coordinate system.
Parameters: - ax :
matplotlib.axes.Axes
, optional. Matplotlib axes to use for plotting.
- **kwargs
Additional kwargs passed to ax.imshow().
Returns: - image :
AxesImage
Matplotlib image artist object
- ax :
-
plot_storm
(self, ax=None, data_name='', method='plot', upscale=5, alpha_cutoff=None, storm_weight=False, sigma=0.25, **kwargs)[source]¶ Graphically represent STORM data.
Parameters: - ax :
Axes
Optional matplotlib axes to use for plotting.
- data_name :
str
Name of the data element to plot. Must be of data class ‘storm’.
- method :
str
Method of visualization. Options are ‘plot’, ‘hist’, or ‘gauss’ just plotting points, histogram plot or gaussian kernel plot.
- upscale :
int
Upscale factor for the output image. Number of pixels is increased w.r.t. data.shape with a factor upscale**2
- alpha_cutoff :
float
Values (normalized) below alpha_cutoff are transparent, where the alpha is linearly scaled between 0 and alpha_cutoff
- storm_weight :
bool
If True the STORM data points are weighted by their intensity.
- sigma :
float
orstring
orndarray
Only applies for method ‘gauss’. The value is the sigma which describes the gaussian kernel. If sigma is a scalar, the same sigma value is used for all data points. If sigma is a string it is interpreted as the name of the field in the STORM array to use. Otherwise, sigma can be an array with equal length to the number of datapoints.
- **kwargs
Additional kwargs passed to ax.plot() or ax.imshow().
Returns: - ax :
- cell_obj :
Optimizers¶
-
class
colicoords.fitting.
CellBinaryFunction
(cell_obj, data_name)[source]¶ Binary data element objective function.
Calling this object with coordinate system parameters returns a binary image by thresholding the radial distance image with the radius of the cell.
Methods
__call__
(self, \*\*parameters)Call self as a function.
-
class
colicoords.fitting.
CellImageFunction
(cell_obj, data_name)[source]¶ Image element objective function.
Calling this object with coordinate system parameters returns a reconstructed image of the target data element.
Methods
__call__
(self, \*\*parameters)Call self as a function.
-
class
colicoords.fitting.
CellMinimizeFunctionBase
(cell_obj, data_name)[source]¶ Base class for Objective objects used by
CellFit
to optimize the coordinate system.The base class takes a
Cell
object and the name of target data element to perform optimization on. Subclasses ofCellMinimizeFunctionBase
must implement the __call__ builtin, which takes the coordinate system’s parameters as keyword arguments.Note that this is not an objective function to be minimized, but instead the return value is compared with the specified data element or specific target data to give the chi-squared.
Parameters:
-
class
colicoords.fitting.
CellSTORMMembraneFunction
(*args, **kwargs)[source]¶ STORM membrane objective function.
Calling this object with coordinate system parameters returns a reconstructed image of the target data element.
Attributes: target_data
Dependent (target) data for coordinate optimization based on STORM membrane markers
Methods
__call__
(self, \*\*parameters)Call self as a function. -
target_data
¶ Dependent (target) data for coordinate optimization based on STORM membrane markers
-
class
colicoords.fitting.
DepCellFit
(cell_obj, data_name='binary', objective=None, minimizer=<class 'symfit.core.minimizers.Powell'>, **kwargs)[source]¶ Attributes: - data_elem
Methods
execute_stepwise fit_parameters renew_fit
-
class
colicoords.fitting.
LinearModelFit
(model, *args, **kwargs)[source]¶ Fitting of a model with linear parameters where the linear parameters are not fitted by
symfit
but instead solved as a system of linear equations.Parameters: - model : :
Methods
execute
(self, \*\*kwargs)Execute the fit.
-
class
colicoords.fitting.
RadialData
(cell_obj, length)[source]¶ Class mimicking a numpy ndarray used as dependent data for fitting STORM-membrane data.
The apparent value of this object is an array with length length and whoes values are all equal to the radius of cell_obj.
Parameters: Attributes: - shape
- value