repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_documentation_string stringlengths 1 47.2k | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|
CellProfiler/centrosome | centrosome/cpmorphology.py | find_neighbors | def find_neighbors(labels):
'''Find the set of objects that touch each object in a labels matrix
Construct a "list", per-object, of the objects 8-connected adjacent
to that object.
Returns three 1-d arrays:
* array of #'s of neighbors per object
* array of indexes per object to that object'... | python | def find_neighbors(labels):
'''Find the set of objects that touch each object in a labels matrix
Construct a "list", per-object, of the objects 8-connected adjacent
to that object.
Returns three 1-d arrays:
* array of #'s of neighbors per object
* array of indexes per object to that object'... | Find the set of objects that touch each object in a labels matrix
Construct a "list", per-object, of the objects 8-connected adjacent
to that object.
Returns three 1-d arrays:
* array of #'s of neighbors per object
* array of indexes per object to that object's list of neighbors
* array hol... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/cpmorphology.py#L3507-L3581 |
CellProfiler/centrosome | centrosome/cpmorphology.py | distance_color_labels | def distance_color_labels(labels):
'''Recolor a labels matrix so that adjacent labels have distant numbers
'''
#
# Color labels so adjacent ones are most distant
#
colors = color_labels(labels, True)
#
# Order pixels by color, then label #
#
rlabels = labels.ravel()
orde... | python | def distance_color_labels(labels):
'''Recolor a labels matrix so that adjacent labels have distant numbers
'''
#
# Color labels so adjacent ones are most distant
#
colors = color_labels(labels, True)
#
# Order pixels by color, then label #
#
rlabels = labels.ravel()
orde... | Recolor a labels matrix so that adjacent labels have distant numbers | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/cpmorphology.py#L3583-L3607 |
CellProfiler/centrosome | centrosome/cpmorphology.py | color_labels | def color_labels(labels, distance_transform = False):
'''Color a labels matrix so that no adjacent labels have the same color
distance_transform - if true, distance transform the labels to find out
which objects are closest to each other.
Create a label coloring matrix which assigns ... | python | def color_labels(labels, distance_transform = False):
'''Color a labels matrix so that no adjacent labels have the same color
distance_transform - if true, distance transform the labels to find out
which objects are closest to each other.
Create a label coloring matrix which assigns ... | Color a labels matrix so that no adjacent labels have the same color
distance_transform - if true, distance transform the labels to find out
which objects are closest to each other.
Create a label coloring matrix which assigns a color (1-n) to each pixel
in the labels matrix such tha... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/cpmorphology.py#L3609-L3679 |
CellProfiler/centrosome | centrosome/cpmorphology.py | skeletonize | def skeletonize(image, mask=None, ordering = None):
'''Skeletonize the image
Take the distance transform.
Order the 1 points by the distance transform.
Remove a point if it has more than 1 neighbor and if removing it
does not change the Euler number.
image - the binary image to be skel... | python | def skeletonize(image, mask=None, ordering = None):
'''Skeletonize the image
Take the distance transform.
Order the 1 points by the distance transform.
Remove a point if it has more than 1 neighbor and if removing it
does not change the Euler number.
image - the binary image to be skel... | Skeletonize the image
Take the distance transform.
Order the 1 points by the distance transform.
Remove a point if it has more than 1 neighbor and if removing it
does not change the Euler number.
image - the binary image to be skeletonized
mask - only skeletonize pixels within the... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/cpmorphology.py#L3681-L3753 |
CellProfiler/centrosome | centrosome/cpmorphology.py | skeletonize_labels | def skeletonize_labels(labels):
'''Skeletonize a labels matrix'''
#
# The trick here is to separate touching labels by coloring the
# labels matrix and then processing each color separately
#
colors = color_labels(labels)
max_color = np.max(colors)
if max_color == 0:
return label... | python | def skeletonize_labels(labels):
'''Skeletonize a labels matrix'''
#
# The trick here is to separate touching labels by coloring the
# labels matrix and then processing each color separately
#
colors = color_labels(labels)
max_color = np.max(colors)
if max_color == 0:
return label... | Skeletonize a labels matrix | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/cpmorphology.py#L3755-L3769 |
CellProfiler/centrosome | centrosome/cpmorphology.py | label_skeleton | def label_skeleton(skeleton):
'''Label a skeleton so that each edge has a unique label
This operation produces a labels matrix where each edge between
two branchpoints has a different label. If the skeleton has been
properly eroded, there are three kinds of points:
1) point adjacent to 0 or 1 o... | python | def label_skeleton(skeleton):
'''Label a skeleton so that each edge has a unique label
This operation produces a labels matrix where each edge between
two branchpoints has a different label. If the skeleton has been
properly eroded, there are three kinds of points:
1) point adjacent to 0 or 1 o... | Label a skeleton so that each edge has a unique label
This operation produces a labels matrix where each edge between
two branchpoints has a different label. If the skeleton has been
properly eroded, there are three kinds of points:
1) point adjacent to 0 or 1 other points = end of edge
2) poin... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/cpmorphology.py#L3771-L3849 |
CellProfiler/centrosome | centrosome/cpmorphology.py | skeleton_length | def skeleton_length(labels, indices=None):
'''Compute the length of all skeleton branches for labeled skeletons
labels - a labels matrix
indices - the indexes of the labels to be measured. Default is all
returns an array of one skeleton length per label.
'''
global __skel_length_table
... | python | def skeleton_length(labels, indices=None):
'''Compute the length of all skeleton branches for labeled skeletons
labels - a labels matrix
indices - the indexes of the labels to be measured. Default is all
returns an array of one skeleton length per label.
'''
global __skel_length_table
... | Compute the length of all skeleton branches for labeled skeletons
labels - a labels matrix
indices - the indexes of the labels to be measured. Default is all
returns an array of one skeleton length per label. | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/cpmorphology.py#L3853-L3903 |
CellProfiler/centrosome | centrosome/cpmorphology.py | distance_to_edge | def distance_to_edge(labels):
'''Compute the distance of a pixel to the edge of its object
labels - a labels matrix
returns a matrix of distances
'''
colors = color_labels(labels)
max_color = np.max(colors)
result = np.zeros(labels.shape)
if max_color == 0:
return resul... | python | def distance_to_edge(labels):
'''Compute the distance of a pixel to the edge of its object
labels - a labels matrix
returns a matrix of distances
'''
colors = color_labels(labels)
max_color = np.max(colors)
result = np.zeros(labels.shape)
if max_color == 0:
return resul... | Compute the distance of a pixel to the edge of its object
labels - a labels matrix
returns a matrix of distances | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/cpmorphology.py#L3905-L3921 |
CellProfiler/centrosome | centrosome/cpmorphology.py | regional_maximum | def regional_maximum(image, mask = None, structure=None, ties_are_ok=False):
'''Return a binary mask containing only points that are regional maxima
image - image to be transformed
mask - mask of relevant pixels
structure - binary structure giving the neighborhood and connectivity
... | python | def regional_maximum(image, mask = None, structure=None, ties_are_ok=False):
'''Return a binary mask containing only points that are regional maxima
image - image to be transformed
mask - mask of relevant pixels
structure - binary structure giving the neighborhood and connectivity
... | Return a binary mask containing only points that are regional maxima
image - image to be transformed
mask - mask of relevant pixels
structure - binary structure giving the neighborhood and connectivity
in which to search for maxima. Default is 8-connected.
ties_are_ok - if ... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/cpmorphology.py#L3923-L4009 |
CellProfiler/centrosome | centrosome/cpmorphology.py | all_connected_components | def all_connected_components(i,j):
'''Associate each label in i with a component #
This function finds all connected components given an array of
associations between labels i and j using a depth-first search.
i & j give the edges of the graph. The first step of the algorithm makes
bidirec... | python | def all_connected_components(i,j):
'''Associate each label in i with a component #
This function finds all connected components given an array of
associations between labels i and j using a depth-first search.
i & j give the edges of the graph. The first step of the algorithm makes
bidirec... | Associate each label in i with a component #
This function finds all connected components given an array of
associations between labels i and j using a depth-first search.
i & j give the edges of the graph. The first step of the algorithm makes
bidirectional edges, (i->j and j<-i), so it's bes... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/cpmorphology.py#L4011-L4041 |
CellProfiler/centrosome | centrosome/cpmorphology.py | pairwise_permutations | def pairwise_permutations(i, j):
'''Return all permutations of a set of groups
This routine takes two vectors:
i - the label of each group
j - the members of the group.
For instance, take a set of two groups with several members each:
i | j
------
1 | 1
1 | 2
1 | 3... | python | def pairwise_permutations(i, j):
'''Return all permutations of a set of groups
This routine takes two vectors:
i - the label of each group
j - the members of the group.
For instance, take a set of two groups with several members each:
i | j
------
1 | 1
1 | 2
1 | 3... | Return all permutations of a set of groups
This routine takes two vectors:
i - the label of each group
j - the members of the group.
For instance, take a set of two groups with several members each:
i | j
------
1 | 1
1 | 2
1 | 3
2 | 1
2 | 4
2 | 5
2 | 6... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/cpmorphology.py#L4043-L4186 |
CellProfiler/centrosome | centrosome/cpmorphology.py | is_local_maximum | def is_local_maximum(image, labels, footprint):
'''Return a boolean array of points that are local maxima
image - intensity image
labels - find maxima only within labels. Zero is reserved for background.
footprint - binary mask indicating the neighborhood to be examined
must be a ma... | python | def is_local_maximum(image, labels, footprint):
'''Return a boolean array of points that are local maxima
image - intensity image
labels - find maxima only within labels. Zero is reserved for background.
footprint - binary mask indicating the neighborhood to be examined
must be a ma... | Return a boolean array of points that are local maxima
image - intensity image
labels - find maxima only within labels. Zero is reserved for background.
footprint - binary mask indicating the neighborhood to be examined
must be a matrix with odd dimensions, center is taken to
... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/cpmorphology.py#L4188-L4260 |
CellProfiler/centrosome | centrosome/cpmorphology.py | angular_distribution | def angular_distribution(labels, resolution=100, weights=None):
'''For each object in labels, compute the angular distribution
around the centers of mass. Returns an i x j matrix, where i is
the number of objects in the label matrix, and j is the resolution
of the distribution (default 100), mapped fro... | python | def angular_distribution(labels, resolution=100, weights=None):
'''For each object in labels, compute the angular distribution
around the centers of mass. Returns an i x j matrix, where i is
the number of objects in the label matrix, and j is the resolution
of the distribution (default 100), mapped fro... | For each object in labels, compute the angular distribution
around the centers of mass. Returns an i x j matrix, where i is
the number of objects in the label matrix, and j is the resolution
of the distribution (default 100), mapped from -pi to pi.
Optionally, the distributions can be weighted by pixe... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/cpmorphology.py#L4262-L4306 |
CellProfiler/centrosome | centrosome/cpmorphology.py | feret_diameter | def feret_diameter(chulls, counts, indexes):
'''Return the minimum and maximum Feret diameter for each object
This function takes the convex hull data, as generated by convex_hull
and returns the minimum and maximum Feret diameter for each convex hull.
chulls - an n x 3 matrix giving the la... | python | def feret_diameter(chulls, counts, indexes):
'''Return the minimum and maximum Feret diameter for each object
This function takes the convex hull data, as generated by convex_hull
and returns the minimum and maximum Feret diameter for each convex hull.
chulls - an n x 3 matrix giving the la... | Return the minimum and maximum Feret diameter for each object
This function takes the convex hull data, as generated by convex_hull
and returns the minimum and maximum Feret diameter for each convex hull.
chulls - an n x 3 matrix giving the label #, the i coordinate and the
j co... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/cpmorphology.py#L4308-L4506 |
CellProfiler/centrosome | centrosome/cpmorphology.py | is_obtuse | def is_obtuse(p1, v, p2):
'''Determine whether the angle, p1 - v - p2 is obtuse
p1 - N x 2 array of coordinates of first point on edge
v - N x 2 array of vertex coordinates
p2 - N x 2 array of coordinates of second point on edge
returns vector of booleans
'''
p1x = p1[:,1]
p1y ... | python | def is_obtuse(p1, v, p2):
'''Determine whether the angle, p1 - v - p2 is obtuse
p1 - N x 2 array of coordinates of first point on edge
v - N x 2 array of vertex coordinates
p2 - N x 2 array of coordinates of second point on edge
returns vector of booleans
'''
p1x = p1[:,1]
p1y ... | Determine whether the angle, p1 - v - p2 is obtuse
p1 - N x 2 array of coordinates of first point on edge
v - N x 2 array of vertex coordinates
p2 - N x 2 array of coordinates of second point on edge
returns vector of booleans | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/cpmorphology.py#L4508-L4527 |
CellProfiler/centrosome | centrosome/cpmorphology.py | get_outline_pts | def get_outline_pts(labels, idxs):
'''Get the outline points of objects in clockwise order
Given a labels matrix of contiguously-labeled objects, trace
the exteriors of those objects to get the points of the outline
in clockwise order.
labels - a labels matrix
idxs - return points... | python | def get_outline_pts(labels, idxs):
'''Get the outline points of objects in clockwise order
Given a labels matrix of contiguously-labeled objects, trace
the exteriors of those objects to get the points of the outline
in clockwise order.
labels - a labels matrix
idxs - return points... | Get the outline points of objects in clockwise order
Given a labels matrix of contiguously-labeled objects, trace
the exteriors of those objects to get the points of the outline
in clockwise order.
labels - a labels matrix
idxs - return points for the labels named by this array
... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/cpmorphology.py#L4553-L4693 |
CellProfiler/centrosome | centrosome/princomp.py | princomp | def princomp(x):
"""Determine the principal components of a vector of measurements
Determine the principal components of a vector of measurements
x should be a M x N numpy array composed of M observations of n variables
The output is:
coeffs - the NxN correlation matrix that can be used to tran... | python | def princomp(x):
"""Determine the principal components of a vector of measurements
Determine the principal components of a vector of measurements
x should be a M x N numpy array composed of M observations of n variables
The output is:
coeffs - the NxN correlation matrix that can be used to tran... | Determine the principal components of a vector of measurements
Determine the principal components of a vector of measurements
x should be a M x N numpy array composed of M observations of n variables
The output is:
coeffs - the NxN correlation matrix that can be used to transform x into its compone... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/princomp.py#L4-L24 |
CellProfiler/centrosome | centrosome/index.py | all_pairs | def all_pairs(n):
'''Return an (n*(n - 1)) x 2 array of all non-identity pairs of n things
n - # of things
The array is (cleverly) ordered so that the first m * (m - 1) elements
can be used for m < n things:
n = 3
[[0, 1], # n = 2
[1, 0], # n = 2
[0, 2],
[1, 2],
... | python | def all_pairs(n):
'''Return an (n*(n - 1)) x 2 array of all non-identity pairs of n things
n - # of things
The array is (cleverly) ordered so that the first m * (m - 1) elements
can be used for m < n things:
n = 3
[[0, 1], # n = 2
[1, 0], # n = 2
[0, 2],
[1, 2],
... | Return an (n*(n - 1)) x 2 array of all non-identity pairs of n things
n - # of things
The array is (cleverly) ordered so that the first m * (m - 1) elements
can be used for m < n things:
n = 3
[[0, 1], # n = 2
[1, 0], # n = 2
[0, 2],
[1, 2],
[2, 0],
[2, 1]] | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/index.py#L116-L138 |
CellProfiler/centrosome | centrosome/filter.py | stretch | def stretch(image, mask=None):
'''Normalize an image to make the minimum zero and maximum one
image - pixel data to be normalized
mask - optional mask of relevant pixels. None = don't mask
returns the stretched image
'''
image = np.array(image, float)
if np.product(image.shape) == 0:
... | python | def stretch(image, mask=None):
'''Normalize an image to make the minimum zero and maximum one
image - pixel data to be normalized
mask - optional mask of relevant pixels. None = don't mask
returns the stretched image
'''
image = np.array(image, float)
if np.product(image.shape) == 0:
... | Normalize an image to make the minimum zero and maximum one
image - pixel data to be normalized
mask - optional mask of relevant pixels. None = don't mask
returns the stretched image | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L22-L57 |
CellProfiler/centrosome | centrosome/filter.py | median_filter | def median_filter(data, mask, radius, percent=50):
'''Masked median filter with octagonal shape
data - array of data to be median filtered.
mask - mask of significant pixels in data
radius - the radius of a circle inscribed into the filtering octagon
percent - conceptually, order the significant pi... | python | def median_filter(data, mask, radius, percent=50):
'''Masked median filter with octagonal shape
data - array of data to be median filtered.
mask - mask of significant pixels in data
radius - the radius of a circle inscribed into the filtering octagon
percent - conceptually, order the significant pi... | Masked median filter with octagonal shape
data - array of data to be median filtered.
mask - mask of significant pixels in data
radius - the radius of a circle inscribed into the filtering octagon
percent - conceptually, order the significant pixels in the octagon,
count them and choose t... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L68-L107 |
CellProfiler/centrosome | centrosome/filter.py | bilateral_filter | def bilateral_filter(image, mask, sigma_spatial, sigma_range,
sampling_spatial = None, sampling_range = None):
"""Bilateral filter of an image
image - image to be bilaterally filtered
mask - mask of significant points in image
sigma_spatial - standard deviation of the spatial Gaus... | python | def bilateral_filter(image, mask, sigma_spatial, sigma_range,
sampling_spatial = None, sampling_range = None):
"""Bilateral filter of an image
image - image to be bilaterally filtered
mask - mask of significant points in image
sigma_spatial - standard deviation of the spatial Gaus... | Bilateral filter of an image
image - image to be bilaterally filtered
mask - mask of significant points in image
sigma_spatial - standard deviation of the spatial Gaussian
sigma_range - standard deviation of the range Gaussian
sampling_spatial - amt to reduce image array extents when sampling
... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L116-L250 |
CellProfiler/centrosome | centrosome/filter.py | laplacian_of_gaussian | def laplacian_of_gaussian(image, mask, size, sigma):
'''Perform the Laplacian of Gaussian transform on the image
image - 2-d image array
mask - binary mask of significant pixels
size - length of side of square kernel to use
sigma - standard deviation of the Gaussian
'''
half_size = size//... | python | def laplacian_of_gaussian(image, mask, size, sigma):
'''Perform the Laplacian of Gaussian transform on the image
image - 2-d image array
mask - binary mask of significant pixels
size - length of side of square kernel to use
sigma - standard deviation of the Gaussian
'''
half_size = size//... | Perform the Laplacian of Gaussian transform on the image
image - 2-d image array
mask - binary mask of significant pixels
size - length of side of square kernel to use
sigma - standard deviation of the Gaussian | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L252-L291 |
CellProfiler/centrosome | centrosome/filter.py | canny | def canny(image, mask, sigma, low_threshold, high_threshold):
'''Edge filter an image using the Canny algorithm.
sigma - the standard deviation of the Gaussian used
low_threshold - threshold for edges that connect to high-threshold
edges
high_threshold - threshold of a high-threshol... | python | def canny(image, mask, sigma, low_threshold, high_threshold):
'''Edge filter an image using the Canny algorithm.
sigma - the standard deviation of the Gaussian used
low_threshold - threshold for edges that connect to high-threshold
edges
high_threshold - threshold of a high-threshol... | Edge filter an image using the Canny algorithm.
sigma - the standard deviation of the Gaussian used
low_threshold - threshold for edges that connect to high-threshold
edges
high_threshold - threshold of a high-threshold edge
Canny, J., A Computational Approach To Edge Detection, IE... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L298-L461 |
CellProfiler/centrosome | centrosome/filter.py | roberts | def roberts(image, mask=None):
'''Find edges using the Roberts algorithm
image - the image to process
mask - mask of relevant points
The algorithm returns the magnitude of the output of the two Roberts
convolution kernels.
The following is the canonical citation for the algorithm:
L. Rob... | python | def roberts(image, mask=None):
'''Find edges using the Roberts algorithm
image - the image to process
mask - mask of relevant points
The algorithm returns the magnitude of the output of the two Roberts
convolution kernels.
The following is the canonical citation for the algorithm:
L. Rob... | Find edges using the Roberts algorithm
image - the image to process
mask - mask of relevant points
The algorithm returns the magnitude of the output of the two Roberts
convolution kernels.
The following is the canonical citation for the algorithm:
L. Roberts Machine Perception of 3-D Solids,... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L463-L504 |
CellProfiler/centrosome | centrosome/filter.py | sobel | def sobel(image, mask=None):
'''Calculate the absolute magnitude Sobel to find the edges
image - image to process
mask - mask of relevant points
Take the square root of the sum of the squares of the horizontal and
vertical Sobels to get a magnitude that's somewhat insensitive to
direction.
... | python | def sobel(image, mask=None):
'''Calculate the absolute magnitude Sobel to find the edges
image - image to process
mask - mask of relevant points
Take the square root of the sum of the squares of the horizontal and
vertical Sobels to get a magnitude that's somewhat insensitive to
direction.
... | Calculate the absolute magnitude Sobel to find the edges
image - image to process
mask - mask of relevant points
Take the square root of the sum of the squares of the horizontal and
vertical Sobels to get a magnitude that's somewhat insensitive to
direction.
Note that scipy's Sobel returns a ... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L506-L519 |
CellProfiler/centrosome | centrosome/filter.py | prewitt | def prewitt(image, mask=None):
'''Find the edge magnitude using the Prewitt transform
image - image to process
mask - mask of relevant points
Return the square root of the sum of squares of the horizontal
and vertical Prewitt transforms.
'''
return np.sqrt(hprewitt(image,mask)**2 + vprewi... | python | def prewitt(image, mask=None):
'''Find the edge magnitude using the Prewitt transform
image - image to process
mask - mask of relevant points
Return the square root of the sum of squares of the horizontal
and vertical Prewitt transforms.
'''
return np.sqrt(hprewitt(image,mask)**2 + vprewi... | Find the edge magnitude using the Prewitt transform
image - image to process
mask - mask of relevant points
Return the square root of the sum of squares of the horizontal
and vertical Prewitt transforms. | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L567-L576 |
CellProfiler/centrosome | centrosome/filter.py | hprewitt | def hprewitt(image, mask=None):
'''Find the horizontal edges of an image using the Prewitt transform
image - image to process
mask - mask of relevant points
We use the following kernel and return the absolute value of the
result at each point:
1 1 1
0 0 0
-1 -1 -1
'''
... | python | def hprewitt(image, mask=None):
'''Find the horizontal edges of an image using the Prewitt transform
image - image to process
mask - mask of relevant points
We use the following kernel and return the absolute value of the
result at each point:
1 1 1
0 0 0
-1 -1 -1
'''
... | Find the horizontal edges of an image using the Prewitt transform
image - image to process
mask - mask of relevant points
We use the following kernel and return the absolute value of the
result at each point:
1 1 1
0 0 0
-1 -1 -1 | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L578-L599 |
CellProfiler/centrosome | centrosome/filter.py | gabor | def gabor(image, labels, frequency, theta):
'''Gabor-filter the objects in an image
image - 2-d grayscale image to filter
labels - a similarly shaped labels matrix
frequency - cycles per trip around the circle
theta - angle of the filter. 0 to 2 pi
Calculate the Gabor filter centered on the ce... | python | def gabor(image, labels, frequency, theta):
'''Gabor-filter the objects in an image
image - 2-d grayscale image to filter
labels - a similarly shaped labels matrix
frequency - cycles per trip around the circle
theta - angle of the filter. 0 to 2 pi
Calculate the Gabor filter centered on the ce... | Gabor-filter the objects in an image
image - 2-d grayscale image to filter
labels - a similarly shaped labels matrix
frequency - cycles per trip around the circle
theta - angle of the filter. 0 to 2 pi
Calculate the Gabor filter centered on the centroids of each object
in the image. Summing th... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L624-L673 |
CellProfiler/centrosome | centrosome/filter.py | enhance_dark_holes | def enhance_dark_holes(image, min_radius, max_radius, mask=None):
'''Enhance dark holes using a rolling ball filter
image - grayscale 2-d image
radii - a vector of radii: we enhance holes at each given radius
'''
#
# Do 4-connected erosion
#
se = np.array([[False, True, False],
... | python | def enhance_dark_holes(image, min_radius, max_radius, mask=None):
'''Enhance dark holes using a rolling ball filter
image - grayscale 2-d image
radii - a vector of radii: we enhance holes at each given radius
'''
#
# Do 4-connected erosion
#
se = np.array([[False, True, False],
... | Enhance dark holes using a rolling ball filter
image - grayscale 2-d image
radii - a vector of radii: we enhance holes at each given radius | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L675-L702 |
CellProfiler/centrosome | centrosome/filter.py | granulometry_filter | def granulometry_filter(image, min_radius, max_radius, mask=None):
'''Enhances bright structures within a min and max radius using a rolling ball filter
image - grayscale 2-d image
radii - a vector of radii: we enhance holes at each given radius
'''
#
# Do 4-connected erosion
#
se = np.... | python | def granulometry_filter(image, min_radius, max_radius, mask=None):
'''Enhances bright structures within a min and max radius using a rolling ball filter
image - grayscale 2-d image
radii - a vector of radii: we enhance holes at each given radius
'''
#
# Do 4-connected erosion
#
se = np.... | Enhances bright structures within a min and max radius using a rolling ball filter
image - grayscale 2-d image
radii - a vector of radii: we enhance holes at each given radius | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L705-L734 |
CellProfiler/centrosome | centrosome/filter.py | circular_average_filter | def circular_average_filter(image, radius, mask=None):
'''Blur an image using a circular averaging filter (pillbox)
image - grayscale 2-d image
radii - radius of filter in pixels
The filter will be within a square matrix of side 2*radius+1
This code is translated straight from MATLAB's fspecial f... | python | def circular_average_filter(image, radius, mask=None):
'''Blur an image using a circular averaging filter (pillbox)
image - grayscale 2-d image
radii - radius of filter in pixels
The filter will be within a square matrix of side 2*radius+1
This code is translated straight from MATLAB's fspecial f... | Blur an image using a circular averaging filter (pillbox)
image - grayscale 2-d image
radii - radius of filter in pixels
The filter will be within a square matrix of side 2*radius+1
This code is translated straight from MATLAB's fspecial function | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L736-L792 |
CellProfiler/centrosome | centrosome/filter.py | velocity_kalman_model | def velocity_kalman_model():
'''Return a KalmanState set up to model objects with constant velocity
The observation and measurement vectors are i,j.
The state vector is i,j,vi,vj
'''
om = np.array([[1,0,0,0], [0, 1, 0, 0]])
tm = np.array([[1,0,1,0],
[0,1,0,1],
... | python | def velocity_kalman_model():
'''Return a KalmanState set up to model objects with constant velocity
The observation and measurement vectors are i,j.
The state vector is i,j,vi,vj
'''
om = np.array([[1,0,0,0], [0, 1, 0, 0]])
tm = np.array([[1,0,1,0],
[0,1,0,1],
... | Return a KalmanState set up to model objects with constant velocity
The observation and measurement vectors are i,j.
The state vector is i,j,vi,vj | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L1010-L1021 |
CellProfiler/centrosome | centrosome/filter.py | reverse_velocity_kalman_model | def reverse_velocity_kalman_model():
'''Return a KalmanState set up to model going backwards in time'''
om = np.array([[1,0,0,0], [0, 1, 0, 0]])
tm = np.array([[1,0,-1,0],
[0,1,0,-1],
[0,0,1,0],
[0,0,0,1]])
return KalmanState(om, tm) | python | def reverse_velocity_kalman_model():
'''Return a KalmanState set up to model going backwards in time'''
om = np.array([[1,0,0,0], [0, 1, 0, 0]])
tm = np.array([[1,0,-1,0],
[0,1,0,-1],
[0,0,1,0],
[0,0,0,1]])
return KalmanState(om, tm) | Return a KalmanState set up to model going backwards in time | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L1023-L1030 |
CellProfiler/centrosome | centrosome/filter.py | kalman_filter | def kalman_filter(kalman_state, old_indices, coordinates, q, r):
'''Return the kalman filter for the features in the new frame
kalman_state - state from last frame
old_indices - the index per feature in the last frame or -1 for new
coordinates - Coordinates of the features in the new frame.
q - ... | python | def kalman_filter(kalman_state, old_indices, coordinates, q, r):
'''Return the kalman filter for the features in the new frame
kalman_state - state from last frame
old_indices - the index per feature in the last frame or -1 for new
coordinates - Coordinates of the features in the new frame.
q - ... | Return the kalman filter for the features in the new frame
kalman_state - state from last frame
old_indices - the index per feature in the last frame or -1 for new
coordinates - Coordinates of the features in the new frame.
q - the process error covariance - see equ 1.3 and 1.10 from Welch
r - ... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L1039-L1171 |
CellProfiler/centrosome | centrosome/filter.py | line_integration | def line_integration(image, angle, decay, sigma):
'''Integrate the image along the given angle
DIC images are the directional derivative of the underlying
image. This filter reconstructs the original image by integrating
along that direction.
image - a 2-dimensional array
angle - shear angle ... | python | def line_integration(image, angle, decay, sigma):
'''Integrate the image along the given angle
DIC images are the directional derivative of the underlying
image. This filter reconstructs the original image by integrating
along that direction.
image - a 2-dimensional array
angle - shear angle ... | Integrate the image along the given angle
DIC images are the directional derivative of the underlying
image. This filter reconstructs the original image by integrating
along that direction.
image - a 2-dimensional array
angle - shear angle in radians. We integrate perpendicular to this angle
... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L1173-L1230 |
CellProfiler/centrosome | centrosome/filter.py | variance_transform | def variance_transform(img, sigma, mask=None):
'''Calculate a weighted variance of the image
This function caluclates the variance of an image, weighting the
local contributions by a Gaussian.
img - image to be transformed
sigma - standard deviation of the Gaussian
mask - mask of relevant pixe... | python | def variance_transform(img, sigma, mask=None):
'''Calculate a weighted variance of the image
This function caluclates the variance of an image, weighting the
local contributions by a Gaussian.
img - image to be transformed
sigma - standard deviation of the Gaussian
mask - mask of relevant pixe... | Calculate a weighted variance of the image
This function caluclates the variance of an image, weighting the
local contributions by a Gaussian.
img - image to be transformed
sigma - standard deviation of the Gaussian
mask - mask of relevant pixels in the image | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L1232-L1258 |
CellProfiler/centrosome | centrosome/filter.py | inv_n | def inv_n(x):
'''given N matrices, return N inverses'''
#
# The inverse of a small matrix (e.g. 3x3) is
#
# 1
# ----- C(j,i)
# det(A)
#
# where C(j,i) is the cofactor of matrix A at position j,i
#
assert x.ndim == 3
assert x.shape[1] == x.shape[2]
c = np.array([ [... | python | def inv_n(x):
'''given N matrices, return N inverses'''
#
# The inverse of a small matrix (e.g. 3x3) is
#
# 1
# ----- C(j,i)
# det(A)
#
# where C(j,i) is the cofactor of matrix A at position j,i
#
assert x.ndim == 3
assert x.shape[1] == x.shape[2]
c = np.array([ [... | given N matrices, return N inverses | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L1313-L1329 |
CellProfiler/centrosome | centrosome/filter.py | det_n | def det_n(x):
'''given N matrices, return N determinants'''
assert x.ndim == 3
assert x.shape[1] == x.shape[2]
if x.shape[1] == 1:
return x[:,0,0]
result = np.zeros(x.shape[0])
for permutation in permutations(np.arange(x.shape[1])):
sign = parity(permutation)
result += np... | python | def det_n(x):
'''given N matrices, return N determinants'''
assert x.ndim == 3
assert x.shape[1] == x.shape[2]
if x.shape[1] == 1:
return x[:,0,0]
result = np.zeros(x.shape[0])
for permutation in permutations(np.arange(x.shape[1])):
sign = parity(permutation)
result += np... | given N matrices, return N determinants | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L1331-L1343 |
CellProfiler/centrosome | centrosome/filter.py | parity | def parity(x):
'''The parity of a permutation
The parity of a permutation is even if the permutation can be
formed by an even number of transpositions and is odd otherwise.
The parity of a permutation is even if there are an even number of
compositions of even size and odd otherwise. A composition... | python | def parity(x):
'''The parity of a permutation
The parity of a permutation is even if the permutation can be
formed by an even number of transpositions and is odd otherwise.
The parity of a permutation is even if there are an even number of
compositions of even size and odd otherwise. A composition... | The parity of a permutation
The parity of a permutation is even if the permutation can be
formed by an even number of transpositions and is odd otherwise.
The parity of a permutation is even if there are an even number of
compositions of even size and odd otherwise. A composition is a cycle:
for i... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L1345-L1372 |
CellProfiler/centrosome | centrosome/filter.py | cofactor_n | def cofactor_n(x, i, j):
'''Return the cofactor of n matrices x[n,i,j] at position i,j
The cofactor is the determinant of the matrix formed by removing
row i and column j.
'''
m = x.shape[1]
mr = np.arange(m)
i_idx = mr[mr != i]
j_idx = mr[mr != j]
return det_n(x[:, i_idx[:, np.newa... | python | def cofactor_n(x, i, j):
'''Return the cofactor of n matrices x[n,i,j] at position i,j
The cofactor is the determinant of the matrix formed by removing
row i and column j.
'''
m = x.shape[1]
mr = np.arange(m)
i_idx = mr[mr != i]
j_idx = mr[mr != j]
return det_n(x[:, i_idx[:, np.newa... | Return the cofactor of n matrices x[n,i,j] at position i,j
The cofactor is the determinant of the matrix formed by removing
row i and column j. | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L1374-L1385 |
CellProfiler/centrosome | centrosome/filter.py | dot_n | def dot_n(x, y):
'''given two tensors N x I x K and N x K x J return N dot products
If either x or y is 2-dimensional, broadcast it over all N.
Dot products are size N x I x J.
Example:
x = np.array([[[1,2], [3,4], [5,6]],[[7,8], [9,10],[11,12]]])
y = np.array([[[1,2,3], [4,5,6]],[[7,8,9],[10,... | python | def dot_n(x, y):
'''given two tensors N x I x K and N x K x J return N dot products
If either x or y is 2-dimensional, broadcast it over all N.
Dot products are size N x I x J.
Example:
x = np.array([[[1,2], [3,4], [5,6]],[[7,8], [9,10],[11,12]]])
y = np.array([[[1,2,3], [4,5,6]],[[7,8,9],[10,... | given two tensors N x I x K and N x K x J return N dot products
If either x or y is 2-dimensional, broadcast it over all N.
Dot products are size N x I x J.
Example:
x = np.array([[[1,2], [3,4], [5,6]],[[7,8], [9,10],[11,12]]])
y = np.array([[[1,2,3], [4,5,6]],[[7,8,9],[10,11,12]]])
print dot_... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L1387-L1425 |
CellProfiler/centrosome | centrosome/filter.py | permutations | def permutations(x):
'''Given a listlike, x, return all permutations of x
Returns the permutations of x in the lexical order of their indices:
e.g.
>>> x = [ 1, 2, 3, 4 ]
>>> for p in permutations(x):
>>> print p
[ 1, 2, 3, 4 ]
[ 1, 2, 4, 3 ]
[ 1, 3, 2, 4 ]
[ 1, 3, 4, 2 ]
... | python | def permutations(x):
'''Given a listlike, x, return all permutations of x
Returns the permutations of x in the lexical order of their indices:
e.g.
>>> x = [ 1, 2, 3, 4 ]
>>> for p in permutations(x):
>>> print p
[ 1, 2, 3, 4 ]
[ 1, 2, 4, 3 ]
[ 1, 3, 2, 4 ]
[ 1, 3, 4, 2 ]
... | Given a listlike, x, return all permutations of x
Returns the permutations of x in the lexical order of their indices:
e.g.
>>> x = [ 1, 2, 3, 4 ]
>>> for p in permutations(x):
>>> print p
[ 1, 2, 3, 4 ]
[ 1, 2, 4, 3 ]
[ 1, 3, 2, 4 ]
[ 1, 3, 4, 2 ]
[ 1, 4, 2, 3 ]
[ 1, 4, 3... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L1427-L1476 |
CellProfiler/centrosome | centrosome/filter.py | convex_hull_transform | def convex_hull_transform(image, levels=256, mask = None,
chunksize = CONVEX_HULL_CHUNKSIZE,
pass_cutoff = 16):
'''Perform the convex hull transform of this image
image - image composed of integer intensity values
levels - # of levels that we separate the... | python | def convex_hull_transform(image, levels=256, mask = None,
chunksize = CONVEX_HULL_CHUNKSIZE,
pass_cutoff = 16):
'''Perform the convex hull transform of this image
image - image composed of integer intensity values
levels - # of levels that we separate the... | Perform the convex hull transform of this image
image - image composed of integer intensity values
levels - # of levels that we separate the image into
mask - mask of points to consider or None to consider all points
chunksize - # of points processed in first pass of convex hull
for each intensity... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L1478-L1695 |
CellProfiler/centrosome | centrosome/filter.py | circular_hough | def circular_hough(img, radius, nangles = None, mask=None):
'''Circular Hough transform of an image
img - image to be transformed.
radius - radius of circle
nangles - # of angles to measure, e.g. nangles = 4 means accumulate at
0, 90, 180 and 270 degrees.
Return the Hough transform... | python | def circular_hough(img, radius, nangles = None, mask=None):
'''Circular Hough transform of an image
img - image to be transformed.
radius - radius of circle
nangles - # of angles to measure, e.g. nangles = 4 means accumulate at
0, 90, 180 and 270 degrees.
Return the Hough transform... | Circular Hough transform of an image
img - image to be transformed.
radius - radius of circle
nangles - # of angles to measure, e.g. nangles = 4 means accumulate at
0, 90, 180 and 270 degrees.
Return the Hough transform of the image which is the accumulators
for the transform x + r... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L1697-L1734 |
CellProfiler/centrosome | centrosome/filter.py | hessian | def hessian(image, return_hessian=True, return_eigenvalues=True, return_eigenvectors=True):
'''Calculate hessian, its eigenvalues and eigenvectors
image - n x m image. Smooth the image with a Gaussian to get derivatives
at different scales.
return_hessian - true to return an n x m x 2 x 2 matr... | python | def hessian(image, return_hessian=True, return_eigenvalues=True, return_eigenvectors=True):
'''Calculate hessian, its eigenvalues and eigenvectors
image - n x m image. Smooth the image with a Gaussian to get derivatives
at different scales.
return_hessian - true to return an n x m x 2 x 2 matr... | Calculate hessian, its eigenvalues and eigenvectors
image - n x m image. Smooth the image with a Gaussian to get derivatives
at different scales.
return_hessian - true to return an n x m x 2 x 2 matrix of the hessian
at each pixel
return_eigenvalues - true to return an n ... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L1736-L1843 |
CellProfiler/centrosome | centrosome/filter.py | poisson_equation | def poisson_equation(image, gradient=1, max_iter=100, convergence=.01, percentile = 90.0):
'''Estimate the solution to the Poisson Equation
The Poisson Equation is the solution to gradient(x) = h^2/4 and, in this
context, we use a boundary condition where x is zero for background
pixels. Also, we set h... | python | def poisson_equation(image, gradient=1, max_iter=100, convergence=.01, percentile = 90.0):
'''Estimate the solution to the Poisson Equation
The Poisson Equation is the solution to gradient(x) = h^2/4 and, in this
context, we use a boundary condition where x is zero for background
pixels. Also, we set h... | Estimate the solution to the Poisson Equation
The Poisson Equation is the solution to gradient(x) = h^2/4 and, in this
context, we use a boundary condition where x is zero for background
pixels. Also, we set h^2/4 = 1 to indicate that each pixel is a distance
of 1 from its neighbors.
The estimatio... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L1845-L1909 |
CellProfiler/centrosome | centrosome/filter.py | KalmanState.predicted_state_vec | def predicted_state_vec(self):
'''The predicted state vector for the next time point
From Welch eqn 1.9
'''
if not self.has_cached_predicted_state_vec:
self.p_state_vec = dot_n(
self.translation_matrix,
self.state_vec[:, :, np.newaxis])[:,:,0]... | python | def predicted_state_vec(self):
'''The predicted state vector for the next time point
From Welch eqn 1.9
'''
if not self.has_cached_predicted_state_vec:
self.p_state_vec = dot_n(
self.translation_matrix,
self.state_vec[:, :, np.newaxis])[:,:,0]... | The predicted state vector for the next time point
From Welch eqn 1.9 | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L895-L904 |
CellProfiler/centrosome | centrosome/filter.py | KalmanState.predicted_obs_vec | def predicted_obs_vec(self):
'''The predicted observation vector
The observation vector for the next step in the filter.
'''
if not self.has_cached_obs_vec:
self.obs_vec = dot_n(
self.observation_matrix,
self.predicted_state_vec[:,:,np.newaxis... | python | def predicted_obs_vec(self):
'''The predicted observation vector
The observation vector for the next step in the filter.
'''
if not self.has_cached_obs_vec:
self.obs_vec = dot_n(
self.observation_matrix,
self.predicted_state_vec[:,:,np.newaxis... | The predicted observation vector
The observation vector for the next step in the filter. | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L912-L921 |
CellProfiler/centrosome | centrosome/filter.py | KalmanState.map_frames | def map_frames(self, old_indices):
'''Rewrite the feature indexes based on the next frame's identities
old_indices - for each feature in the new frame, the index of the
old feature
'''
nfeatures = len(old_indices)
noldfeatures = len(self.state_vec)
... | python | def map_frames(self, old_indices):
'''Rewrite the feature indexes based on the next frame's identities
old_indices - for each feature in the new frame, the index of the
old feature
'''
nfeatures = len(old_indices)
noldfeatures = len(self.state_vec)
... | Rewrite the feature indexes based on the next frame's identities
old_indices - for each feature in the new frame, the index of the
old feature | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L923-L951 |
CellProfiler/centrosome | centrosome/filter.py | KalmanState.add_features | def add_features(self, kept_indices, new_indices,
new_state_vec, new_state_cov, new_noise_var):
'''Add new features to the state
kept_indices - the mapping from all indices in the state to new
indices in the new version
new_indices - the indices of t... | python | def add_features(self, kept_indices, new_indices,
new_state_vec, new_state_cov, new_noise_var):
'''Add new features to the state
kept_indices - the mapping from all indices in the state to new
indices in the new version
new_indices - the indices of t... | Add new features to the state
kept_indices - the mapping from all indices in the state to new
indices in the new version
new_indices - the indices of the new features in the new version
new_state_vec - the state vectors for the new indices
new_state_cov - the c... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L953-L995 |
CellProfiler/centrosome | centrosome/filter.py | KalmanState.deep_copy | def deep_copy(self):
'''Return a deep copy of the state'''
c = KalmanState(self.observation_matrix, self.translation_matrix)
c.state_vec = self.state_vec.copy()
c.state_cov = self.state_cov.copy()
c.noise_var = self.noise_var.copy()
c.state_noise = self.state_noise.copy()... | python | def deep_copy(self):
'''Return a deep copy of the state'''
c = KalmanState(self.observation_matrix, self.translation_matrix)
c.state_vec = self.state_vec.copy()
c.state_cov = self.state_cov.copy()
c.noise_var = self.noise_var.copy()
c.state_noise = self.state_noise.copy()... | Return a deep copy of the state | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L997-L1005 |
CellProfiler/centrosome | centrosome/bg_compensate.py | prcntiles | def prcntiles(x,percents):
'''Equivalent to matlab prctile(x,p), uses linear interpolation.'''
x=np.array(x).flatten()
listx = np.sort(x)
xpcts=[]
lenlistx=len(listx)
refs=[]
for i in range(0,lenlistx):
r=100*((.5+i)/lenlistx) #refs[i] is percentile of listx[i] in matrix x
re... | python | def prcntiles(x,percents):
'''Equivalent to matlab prctile(x,p), uses linear interpolation.'''
x=np.array(x).flatten()
listx = np.sort(x)
xpcts=[]
lenlistx=len(listx)
refs=[]
for i in range(0,lenlistx):
r=100*((.5+i)/lenlistx) #refs[i] is percentile of listx[i] in matrix x
re... | Equivalent to matlab prctile(x,p), uses linear interpolation. | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/bg_compensate.py#L22-L48 |
CellProfiler/centrosome | centrosome/bg_compensate.py | automode | def automode(data):
'''Tries to guess if the image contains dark objects on a bright background (1)
or if the image contains bright objects on a dark background (-1),
or if it contains both dark and bright objects on a gray background (0).'''
pct=prcntiles(np.array(data),[1,20,80,99])
upper=... | python | def automode(data):
'''Tries to guess if the image contains dark objects on a bright background (1)
or if the image contains bright objects on a dark background (-1),
or if it contains both dark and bright objects on a gray background (0).'''
pct=prcntiles(np.array(data),[1,20,80,99])
upper=... | Tries to guess if the image contains dark objects on a bright background (1)
or if the image contains bright objects on a dark background (-1),
or if it contains both dark and bright objects on a gray background (0). | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/bg_compensate.py#L51-L97 |
CellProfiler/centrosome | centrosome/bg_compensate.py | spline_factors | def spline_factors(u):
'''u is np.array'''
X = np.array([(1.-u)**3 , 4-(6.*(u**2))+(3.*(u**3)) , 1.+(3.*u)+(3.*(u**2))-(3.*(u**3)) , u**3]) * (1./6)
return X | python | def spline_factors(u):
'''u is np.array'''
X = np.array([(1.-u)**3 , 4-(6.*(u**2))+(3.*(u**3)) , 1.+(3.*u)+(3.*(u**2))-(3.*(u**3)) , u**3]) * (1./6)
return X | u is np.array | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/bg_compensate.py#L99-L104 |
CellProfiler/centrosome | centrosome/bg_compensate.py | pick | def pick(picklist,val):
'''Index to first value in picklist that is larger than val.
If none is larger, index=len(picklist).'''
assert np.all(np.sort(picklist) == picklist), "pick list is not ordered correctly"
val = np.array(val)
i_pick, i_val = np.mgrid[0:len(picklist),0:len(val)]
#
# Mar... | python | def pick(picklist,val):
'''Index to first value in picklist that is larger than val.
If none is larger, index=len(picklist).'''
assert np.all(np.sort(picklist) == picklist), "pick list is not ordered correctly"
val = np.array(val)
i_pick, i_val = np.mgrid[0:len(picklist),0:len(val)]
#
# Mar... | Index to first value in picklist that is larger than val.
If none is larger, index=len(picklist). | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/bg_compensate.py#L106-L123 |
CellProfiler/centrosome | centrosome/bg_compensate.py | confine | def confine(x,low,high):
'''Confine x to [low,high]. Values outside are set to low/high.
See also restrict.'''
y=x.copy()
y[y < low] = low
y[y > high] = high
return y | python | def confine(x,low,high):
'''Confine x to [low,high]. Values outside are set to low/high.
See also restrict.'''
y=x.copy()
y[y < low] = low
y[y > high] = high
return y | Confine x to [low,high]. Values outside are set to low/high.
See also restrict. | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/bg_compensate.py#L125-L132 |
CellProfiler/centrosome | centrosome/bg_compensate.py | gauss | def gauss(x,m_y,sigma):
'''returns the gaussian with mean m_y and std. dev. sigma,
calculated at the points of x.'''
e_y = [np.exp((1.0/(2*float(sigma)**2)*-(n-m_y)**2)) for n in np.array(x)]
y = [1.0/(float(sigma) * np.sqrt(2 * np.pi)) * e for e in e_y]
return np.array(y) | python | def gauss(x,m_y,sigma):
'''returns the gaussian with mean m_y and std. dev. sigma,
calculated at the points of x.'''
e_y = [np.exp((1.0/(2*float(sigma)**2)*-(n-m_y)**2)) for n in np.array(x)]
y = [1.0/(float(sigma) * np.sqrt(2 * np.pi)) * e for e in e_y]
return np.array(y) | returns the gaussian with mean m_y and std. dev. sigma,
calculated at the points of x. | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/bg_compensate.py#L134-L141 |
CellProfiler/centrosome | centrosome/bg_compensate.py | d2gauss | def d2gauss(x,m_y,sigma):
'''returns the second derivative of the gaussian with mean m_y,
and standard deviation sigma, calculated at the points of x.'''
return gauss(x,m_y,sigma)*[-1/sigma**2 + (n-m_y)**2/sigma**4 for n in x] | python | def d2gauss(x,m_y,sigma):
'''returns the second derivative of the gaussian with mean m_y,
and standard deviation sigma, calculated at the points of x.'''
return gauss(x,m_y,sigma)*[-1/sigma**2 + (n-m_y)**2/sigma**4 for n in x] | returns the second derivative of the gaussian with mean m_y,
and standard deviation sigma, calculated at the points of x. | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/bg_compensate.py#L143-L147 |
CellProfiler/centrosome | centrosome/bg_compensate.py | spline_matrix2d | def spline_matrix2d(x,y,px,py,mask=None):
'''For boundary constraints, the first two and last two spline pieces are constrained
to be part of the same cubic curve.'''
V = np.kron(spline_matrix(x,px),spline_matrix(y,py))
lenV = len(V)
if mask is not None:
indices = np.nonzero(mask.T.fla... | python | def spline_matrix2d(x,y,px,py,mask=None):
'''For boundary constraints, the first two and last two spline pieces are constrained
to be part of the same cubic curve.'''
V = np.kron(spline_matrix(x,px),spline_matrix(y,py))
lenV = len(V)
if mask is not None:
indices = np.nonzero(mask.T.fla... | For boundary constraints, the first two and last two spline pieces are constrained
to be part of the same cubic curve. | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/bg_compensate.py#L175-L191 |
CellProfiler/centrosome | centrosome/bg_compensate.py | splinefit2d | def splinefit2d(x, y, z, px, py, mask=None):
'''Make a least squares fit of the spline (px,py,pz) to the surface (x,y,z).
If mask is given, only masked points are used for the regression.'''
if mask is None:
V = np.array(spline_matrix2d(x, y, px, py))
a = np.array(z.T.flatten())
pz ... | python | def splinefit2d(x, y, z, px, py, mask=None):
'''Make a least squares fit of the spline (px,py,pz) to the surface (x,y,z).
If mask is given, only masked points are used for the regression.'''
if mask is None:
V = np.array(spline_matrix2d(x, y, px, py))
a = np.array(z.T.flatten())
pz ... | Make a least squares fit of the spline (px,py,pz) to the surface (x,y,z).
If mask is given, only masked points are used for the regression. | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/bg_compensate.py#L194-L213 |
CellProfiler/centrosome | centrosome/bg_compensate.py | backgr | def backgr(img, mask = None, mode=MODE_AUTO, thresh=2, splinepoints=5, scale=1,
maxiter=40, convergence = .001):
'''Iterative spline-based background correction.
mode - one of MODE_AUTO, MODE_DARK, MODE_BRIGHT or MODE_GRAY
thresh - thresh is threshold to cut at, in units of sigma.
spli... | python | def backgr(img, mask = None, mode=MODE_AUTO, thresh=2, splinepoints=5, scale=1,
maxiter=40, convergence = .001):
'''Iterative spline-based background correction.
mode - one of MODE_AUTO, MODE_DARK, MODE_BRIGHT or MODE_GRAY
thresh - thresh is threshold to cut at, in units of sigma.
spli... | Iterative spline-based background correction.
mode - one of MODE_AUTO, MODE_DARK, MODE_BRIGHT or MODE_GRAY
thresh - thresh is threshold to cut at, in units of sigma.
splinepoints - # of points in spline in each direction
scale - scale the image by this factor (e.g. 2 = operate on 1/2 of the points... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/bg_compensate.py#L246-L356 |
CellProfiler/centrosome | centrosome/bg_compensate.py | bg_compensate | def bg_compensate(img, sigma, splinepoints, scale):
'''Reads file, subtracts background. Returns [compensated image, background].'''
from PIL import Image
import pylab
from matplotlib.image import pil_to_array
from centrosome.filter import canny
import matplotlib
img = Image.open(img)
... | python | def bg_compensate(img, sigma, splinepoints, scale):
'''Reads file, subtracts background. Returns [compensated image, background].'''
from PIL import Image
import pylab
from matplotlib.image import pil_to_array
from centrosome.filter import canny
import matplotlib
img = Image.open(img)
... | Reads file, subtracts background. Returns [compensated image, background]. | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/bg_compensate.py#L358-L414 |
CellProfiler/centrosome | centrosome/mode.py | mode | def mode(a):
'''Compute the mode of an array
a: an array
returns a vector of values which are the most frequent (more than one
if there is a tie).
'''
a = np.asanyarray(a)
if a.size == 0:
return np.zeros(0, a.dtype)
aa = a.flatten()
aa.sort()
indices = np.hstack... | python | def mode(a):
'''Compute the mode of an array
a: an array
returns a vector of values which are the most frequent (more than one
if there is a tie).
'''
a = np.asanyarray(a)
if a.size == 0:
return np.zeros(0, a.dtype)
aa = a.flatten()
aa.sort()
indices = np.hstack... | Compute the mode of an array
a: an array
returns a vector of values which are the most frequent (more than one
if there is a tie). | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/mode.py#L4-L20 |
CellProfiler/centrosome | centrosome/otsu.py | otsu | def otsu(data, min_threshold=None, max_threshold=None,bins=256):
"""Compute a threshold using Otsu's method
data - an array of intensity values between zero and one
min_threshold - only consider thresholds above this minimum value
max_threshold - only consider thresholds below this maxi... | python | def otsu(data, min_threshold=None, max_threshold=None,bins=256):
"""Compute a threshold using Otsu's method
data - an array of intensity values between zero and one
min_threshold - only consider thresholds above this minimum value
max_threshold - only consider thresholds below this maxi... | Compute a threshold using Otsu's method
data - an array of intensity values between zero and one
min_threshold - only consider thresholds above this minimum value
max_threshold - only consider thresholds below this maximum value
bins - we bin the data into this many equally-sp... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/otsu.py#L5-L59 |
CellProfiler/centrosome | centrosome/otsu.py | entropy | def entropy(data, bins=256):
"""Compute a threshold using Ray's entropy measurement
data - an array of intensity values between zero and one
bins - we bin the data into this many equally-spaced bins, then pick
the bin index that optimizes the metric
"""
... | python | def entropy(data, bins=256):
"""Compute a threshold using Ray's entropy measurement
data - an array of intensity values between zero and one
bins - we bin the data into this many equally-spaced bins, then pick
the bin index that optimizes the metric
"""
... | Compute a threshold using Ray's entropy measurement
data - an array of intensity values between zero and one
bins - we bin the data into this many equally-spaced bins, then pick
the bin index that optimizes the metric | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/otsu.py#L61-L108 |
CellProfiler/centrosome | centrosome/otsu.py | otsu3 | def otsu3(data, min_threshold=None, max_threshold=None,bins=128):
"""Compute a threshold using a 3-category Otsu-like method
data - an array of intensity values between zero and one
min_threshold - only consider thresholds above this minimum value
max_threshold - only consider thres... | python | def otsu3(data, min_threshold=None, max_threshold=None,bins=128):
"""Compute a threshold using a 3-category Otsu-like method
data - an array of intensity values between zero and one
min_threshold - only consider thresholds above this minimum value
max_threshold - only consider thres... | Compute a threshold using a 3-category Otsu-like method
data - an array of intensity values between zero and one
min_threshold - only consider thresholds above this minimum value
max_threshold - only consider thresholds below this maximum value
bins - we bin the data into this... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/otsu.py#L110-L158 |
CellProfiler/centrosome | centrosome/otsu.py | entropy_score | def entropy_score(var,bins, w=None, decimate=True):
'''Compute entropy scores, given a variance and # of bins
'''
if w is None:
n = len(var)
w = np.arange(0,n,n//bins) / float(n)
if decimate:
n = len(var)
var = var[0:n:n//bins]
score = w * np.log(var * w * np.sqr... | python | def entropy_score(var,bins, w=None, decimate=True):
'''Compute entropy scores, given a variance and # of bins
'''
if w is None:
n = len(var)
w = np.arange(0,n,n//bins) / float(n)
if decimate:
n = len(var)
var = var[0:n:n//bins]
score = w * np.log(var * w * np.sqr... | Compute entropy scores, given a variance and # of bins | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/otsu.py#L205-L217 |
CellProfiler/centrosome | centrosome/otsu.py | running_variance | def running_variance(x):
'''Given a vector x, compute the variance for x[0:i]
Thank you http://www.johndcook.com/standard_deviation.html
S[i] = S[i-1]+(x[i]-mean[i-1])*(x[i]-mean[i])
var(i) = S[i] / (i-1)
'''
n = len(x)
# The mean of x[0:i]
m = x.cumsum() / np.arange(1,n+1)
# x[... | python | def running_variance(x):
'''Given a vector x, compute the variance for x[0:i]
Thank you http://www.johndcook.com/standard_deviation.html
S[i] = S[i-1]+(x[i]-mean[i-1])*(x[i]-mean[i])
var(i) = S[i] / (i-1)
'''
n = len(x)
# The mean of x[0:i]
m = x.cumsum() / np.arange(1,n+1)
# x[... | Given a vector x, compute the variance for x[0:i]
Thank you http://www.johndcook.com/standard_deviation.html
S[i] = S[i-1]+(x[i]-mean[i-1])*(x[i]-mean[i])
var(i) = S[i] / (i-1) | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/otsu.py#L236-L254 |
CellProfiler/centrosome | centrosome/outline.py | outline | def outline(labels):
"""Given a label matrix, return a matrix of the outlines of the labeled objects
If a pixel is not zero and has at least one neighbor with a different
value, then it is part of the outline.
"""
output = numpy.zeros(labels.shape, labels.dtype)
lr_different = labels[1... | python | def outline(labels):
"""Given a label matrix, return a matrix of the outlines of the labeled objects
If a pixel is not zero and has at least one neighbor with a different
value, then it is part of the outline.
"""
output = numpy.zeros(labels.shape, labels.dtype)
lr_different = labels[1... | Given a label matrix, return a matrix of the outlines of the labeled objects
If a pixel is not zero and has at least one neighbor with a different
value, then it is part of the outline. | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/outline.py#L4-L34 |
CellProfiler/centrosome | centrosome/neighmovetrack.py | euclidean_dist | def euclidean_dist(point1, point2):
"""Compute the Euclidean distance between two points.
Parameters
----------
point1, point2 : 2-tuples of float
The input points.
Returns
-------
d : float
The distance between the input points.
Examples
--------
>>> point1 = ... | python | def euclidean_dist(point1, point2):
"""Compute the Euclidean distance between two points.
Parameters
----------
point1, point2 : 2-tuples of float
The input points.
Returns
-------
d : float
The distance between the input points.
Examples
--------
>>> point1 = ... | Compute the Euclidean distance between two points.
Parameters
----------
point1, point2 : 2-tuples of float
The input points.
Returns
-------
d : float
The distance between the input points.
Examples
--------
>>> point1 = (1.0, 2.0)
>>> point2 = (4.0, 6.0) # (... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/neighmovetrack.py#L14-L36 |
CellProfiler/centrosome | centrosome/neighmovetrack.py | CellFeatures.from_labels | def from_labels(labels):
"""
Creates list of cell features based on label image (1-oo pixel values)
@return: list of cell features in the same order as labels
"""
labels = labels.astype(int)
areas = scipy.ndimage.measurements.sum(labels != 0, labels, list(range(1, numpy... | python | def from_labels(labels):
"""
Creates list of cell features based on label image (1-oo pixel values)
@return: list of cell features in the same order as labels
"""
labels = labels.astype(int)
areas = scipy.ndimage.measurements.sum(labels != 0, labels, list(range(1, numpy... | Creates list of cell features based on label image (1-oo pixel values)
@return: list of cell features in the same order as labels | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/neighmovetrack.py#L105-L126 |
CellProfiler/centrosome | centrosome/neighmovetrack.py | Trace.from_detections_assignment | def from_detections_assignment(detections_1, detections_2, assignments):
"""
Creates traces out of given assignment and cell data.
"""
traces = []
for d1n, d2n in six.iteritems(assignments):
# check if the match is between existing cells
if d1n < len(dete... | python | def from_detections_assignment(detections_1, detections_2, assignments):
"""
Creates traces out of given assignment and cell data.
"""
traces = []
for d1n, d2n in six.iteritems(assignments):
# check if the match is between existing cells
if d1n < len(dete... | Creates traces out of given assignment and cell data. | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/neighmovetrack.py#L171-L182 |
CellProfiler/centrosome | centrosome/neighmovetrack.py | NeighbourMovementTracking.run_tracking | def run_tracking(self, label_image_1, label_image_2):
"""
Tracks cells between input label images.
@returns: injective function from old objects to new objects (pairs of [old, new]). Number are compatible with labels.
"""
self.scale = self.parameters_tracking["avgCellDiameter"] ... | python | def run_tracking(self, label_image_1, label_image_2):
"""
Tracks cells between input label images.
@returns: injective function from old objects to new objects (pairs of [old, new]). Number are compatible with labels.
"""
self.scale = self.parameters_tracking["avgCellDiameter"] ... | Tracks cells between input label images.
@returns: injective function from old objects to new objects (pairs of [old, new]). Number are compatible with labels. | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/neighmovetrack.py#L198-L218 |
CellProfiler/centrosome | centrosome/neighmovetrack.py | NeighbourMovementTracking.is_cell_big | def is_cell_big(self, cell_detection):
"""
Check if the cell is considered big.
@param CellFeature cell_detection:
@return:
"""
return cell_detection.area > self.parameters_tracking["big_size"] * self.scale * self.scale | python | def is_cell_big(self, cell_detection):
"""
Check if the cell is considered big.
@param CellFeature cell_detection:
@return:
"""
return cell_detection.area > self.parameters_tracking["big_size"] * self.scale * self.scale | Check if the cell is considered big.
@param CellFeature cell_detection:
@return: | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/neighmovetrack.py#L220-L228 |
CellProfiler/centrosome | centrosome/neighmovetrack.py | NeighbourMovementTracking.find_closest_neighbours | def find_closest_neighbours(cell, all_cells, k, max_dist):
"""
Find k closest neighbours of the given cell.
:param CellFeatures cell: cell of interest
:param all_cells: cell to consider as neighbours
:param int k: number of neighbours to be returned
:param int max_dist: m... | python | def find_closest_neighbours(cell, all_cells, k, max_dist):
"""
Find k closest neighbours of the given cell.
:param CellFeatures cell: cell of interest
:param all_cells: cell to consider as neighbours
:param int k: number of neighbours to be returned
:param int max_dist: m... | Find k closest neighbours of the given cell.
:param CellFeatures cell: cell of interest
:param all_cells: cell to consider as neighbours
:param int k: number of neighbours to be returned
:param int max_dist: maximal distance in pixels to consider neighbours
:return: k closest nei... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/neighmovetrack.py#L252-L265 |
CellProfiler/centrosome | centrosome/neighmovetrack.py | NeighbourMovementTracking.calculate_basic_cost | def calculate_basic_cost(self, d1, d2):
"""
Calculates assignment cost between two cells.
"""
distance = euclidean_dist(d1.center, d2.center) / self.scale
area_change = 1 - min(d1.area, d2.area) / max(d1.area, d2.area)
return distance + self.parameters_cost_initial["are... | python | def calculate_basic_cost(self, d1, d2):
"""
Calculates assignment cost between two cells.
"""
distance = euclidean_dist(d1.center, d2.center) / self.scale
area_change = 1 - min(d1.area, d2.area) / max(d1.area, d2.area)
return distance + self.parameters_cost_initial["are... | Calculates assignment cost between two cells. | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/neighmovetrack.py#L267-L275 |
CellProfiler/centrosome | centrosome/neighmovetrack.py | NeighbourMovementTracking.calculate_localised_cost | def calculate_localised_cost(self, d1, d2, neighbours, motions):
"""
Calculates assignment cost between two cells taking into account the movement of cells neighbours.
:param CellFeatures d1: detection in first frame
:param CellFeatures d2: detection in second frame
"""
... | python | def calculate_localised_cost(self, d1, d2, neighbours, motions):
"""
Calculates assignment cost between two cells taking into account the movement of cells neighbours.
:param CellFeatures d1: detection in first frame
:param CellFeatures d2: detection in second frame
"""
... | Calculates assignment cost between two cells taking into account the movement of cells neighbours.
:param CellFeatures d1: detection in first frame
:param CellFeatures d2: detection in second frame | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/neighmovetrack.py#L277-L296 |
CellProfiler/centrosome | centrosome/neighmovetrack.py | NeighbourMovementTracking.calculate_costs | def calculate_costs(self, detections_1, detections_2, calculate_match_cost, params):
"""
Calculates assignment costs between detections and 'empty' spaces. The smaller cost the better.
@param detections_1: cell list of size n in previous frame
@param detections_2: cell list of size m in... | python | def calculate_costs(self, detections_1, detections_2, calculate_match_cost, params):
"""
Calculates assignment costs between detections and 'empty' spaces. The smaller cost the better.
@param detections_1: cell list of size n in previous frame
@param detections_2: cell list of size m in... | Calculates assignment costs between detections and 'empty' spaces. The smaller cost the better.
@param detections_1: cell list of size n in previous frame
@param detections_2: cell list of size m in current frame
@return: cost matrix (n+m)x(n+m) extended by cost of matching cells with emptines... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/neighmovetrack.py#L298-L341 |
CellProfiler/centrosome | centrosome/neighmovetrack.py | NeighbourMovementTracking.solve_assignement | def solve_assignement(self, costs):
"""
Solves assignment problem using Hungarian implementation by Brian M. Clapper.
@param costs: square cost matrix
@return: assignment function
@rtype: int->int
"""
if costs is None or len(costs) == 0:
return dict... | python | def solve_assignement(self, costs):
"""
Solves assignment problem using Hungarian implementation by Brian M. Clapper.
@param costs: square cost matrix
@return: assignment function
@rtype: int->int
"""
if costs is None or len(costs) == 0:
return dict... | Solves assignment problem using Hungarian implementation by Brian M. Clapper.
@param costs: square cost matrix
@return: assignment function
@rtype: int->int | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/neighmovetrack.py#L363-L386 |
CellProfiler/centrosome | centrosome/smooth.py | smooth_with_noise | def smooth_with_noise(image, bits):
"""Smooth the image with a per-pixel random multiplier
image - the image to perturb
bits - the noise is this many bits below the pixel value
The noise is random with normal distribution, so the individual pixels
get either multiplied or divided by a norm... | python | def smooth_with_noise(image, bits):
"""Smooth the image with a per-pixel random multiplier
image - the image to perturb
bits - the noise is this many bits below the pixel value
The noise is random with normal distribution, so the individual pixels
get either multiplied or divided by a norm... | Smooth the image with a per-pixel random multiplier
image - the image to perturb
bits - the noise is this many bits below the pixel value
The noise is random with normal distribution, so the individual pixels
get either multiplied or divided by a normally distributed # of bits | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/smooth.py#L6-L25 |
CellProfiler/centrosome | centrosome/smooth.py | smooth_with_function_and_mask | def smooth_with_function_and_mask(image, function, mask):
"""Smooth an image with a linear function, ignoring the contribution of masked pixels
image - image to smooth
function - a function that takes an image and returns a smoothed image
mask - mask with 1's for significant pixels, 0 for masked p... | python | def smooth_with_function_and_mask(image, function, mask):
"""Smooth an image with a linear function, ignoring the contribution of masked pixels
image - image to smooth
function - a function that takes an image and returns a smoothed image
mask - mask with 1's for significant pixels, 0 for masked p... | Smooth an image with a linear function, ignoring the contribution of masked pixels
image - image to smooth
function - a function that takes an image and returns a smoothed image
mask - mask with 1's for significant pixels, 0 for masked pixels
This function calculates the fractional contributi... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/smooth.py#L27-L47 |
CellProfiler/centrosome | centrosome/smooth.py | circular_gaussian_kernel | def circular_gaussian_kernel(sd,radius):
"""Create a 2-d Gaussian convolution kernel
sd - standard deviation of the gaussian in pixels
radius - build a circular kernel that convolves all points in the circle
bounded by this radius
"""
i,j = np.mgrid[-radius:radius+1,-radius:ra... | python | def circular_gaussian_kernel(sd,radius):
"""Create a 2-d Gaussian convolution kernel
sd - standard deviation of the gaussian in pixels
radius - build a circular kernel that convolves all points in the circle
bounded by this radius
"""
i,j = np.mgrid[-radius:radius+1,-radius:ra... | Create a 2-d Gaussian convolution kernel
sd - standard deviation of the gaussian in pixels
radius - build a circular kernel that convolves all points in the circle
bounded by this radius | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/smooth.py#L49-L68 |
CellProfiler/centrosome | centrosome/smooth.py | fit_polynomial | def fit_polynomial(pixel_data, mask, clip=True):
'''Return an "image" which is a polynomial fit to the pixel data
Fit the image to the polynomial Ax**2+By**2+Cxy+Dx+Ey+F
pixel_data - a two-dimensional numpy array to be fitted
mask - a mask of pixels whose intensities should be considered ... | python | def fit_polynomial(pixel_data, mask, clip=True):
'''Return an "image" which is a polynomial fit to the pixel data
Fit the image to the polynomial Ax**2+By**2+Cxy+Dx+Ey+F
pixel_data - a two-dimensional numpy array to be fitted
mask - a mask of pixels whose intensities should be considered ... | Return an "image" which is a polynomial fit to the pixel data
Fit the image to the polynomial Ax**2+By**2+Cxy+Dx+Ey+F
pixel_data - a two-dimensional numpy array to be fitted
mask - a mask of pixels whose intensities should be considered in the
least squares fit
clip... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/smooth.py#L70-L99 |
CellProfiler/centrosome | centrosome/threshold.py | get_threshold | def get_threshold(threshold_method, threshold_modifier, image,
mask=None, labels = None,
threshold_range_min = None, threshold_range_max = None,
threshold_correction_factor = 1.0,
adaptive_window_size = 10, **kwargs):
"""Compute a threshold fo... | python | def get_threshold(threshold_method, threshold_modifier, image,
mask=None, labels = None,
threshold_range_min = None, threshold_range_max = None,
threshold_correction_factor = 1.0,
adaptive_window_size = 10, **kwargs):
"""Compute a threshold fo... | Compute a threshold for an image
threshold_method - one of the TM_ methods above
threshold_modifier - TM_GLOBAL to calculate one threshold over entire image
TM_ADAPTIVE to calculate a per-pixel threshold
TM_PER_OBJECT to calculate a different threshold for
... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/threshold.py#L64-L153 |
CellProfiler/centrosome | centrosome/threshold.py | get_global_threshold | def get_global_threshold(threshold_method, image, mask = None, **kwargs):
"""Compute a single threshold over the whole image"""
if mask is not None and not np.any(mask):
return 1
if threshold_method == TM_OTSU:
fn = get_otsu_threshold
elif threshold_method == TM_MOG:
fn = ge... | python | def get_global_threshold(threshold_method, image, mask = None, **kwargs):
"""Compute a single threshold over the whole image"""
if mask is not None and not np.any(mask):
return 1
if threshold_method == TM_OTSU:
fn = get_otsu_threshold
elif threshold_method == TM_MOG:
fn = ge... | Compute a single threshold over the whole image | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/threshold.py#L155-L178 |
CellProfiler/centrosome | centrosome/threshold.py | get_adaptive_threshold | def get_adaptive_threshold(threshold_method, image, threshold,
mask = None,
adaptive_window_size = 10,
**kwargs):
"""Given a global threshold, compute a threshold per pixel
Break the image into blocks, computing the thres... | python | def get_adaptive_threshold(threshold_method, image, threshold,
mask = None,
adaptive_window_size = 10,
**kwargs):
"""Given a global threshold, compute a threshold per pixel
Break the image into blocks, computing the thres... | Given a global threshold, compute a threshold per pixel
Break the image into blocks, computing the threshold per block.
Afterwards, constrain the block threshold to .7 T < t < 1.5 T.
Block sizes must be at least 50x50. Images > 500 x 500 get 10x10
blocks. | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/threshold.py#L180-L247 |
CellProfiler/centrosome | centrosome/threshold.py | get_per_object_threshold | def get_per_object_threshold(method, image, threshold, mask=None, labels=None,
threshold_range_min = None,
threshold_range_max = None,
**kwargs):
"""Return a matrix giving threshold per pixel calculated per-object
image ... | python | def get_per_object_threshold(method, image, threshold, mask=None, labels=None,
threshold_range_min = None,
threshold_range_max = None,
**kwargs):
"""Return a matrix giving threshold per pixel calculated per-object
image ... | Return a matrix giving threshold per pixel calculated per-object
image - image to be thresholded
mask - mask out "don't care" pixels
labels - a label mask indicating object boundaries
threshold - the global threshold | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/threshold.py#L249-L274 |
CellProfiler/centrosome | centrosome/threshold.py | get_mog_threshold | def get_mog_threshold(image, mask=None, object_fraction = 0.2):
"""Compute a background using a mixture of gaussians
This function finds a suitable
threshold for the input image Block. It assumes that the pixels in the
image belong to either a background class or an object class. 'pObject'
is a... | python | def get_mog_threshold(image, mask=None, object_fraction = 0.2):
"""Compute a background using a mixture of gaussians
This function finds a suitable
threshold for the input image Block. It assumes that the pixels in the
image belong to either a background class or an object class. 'pObject'
is a... | Compute a background using a mixture of gaussians
This function finds a suitable
threshold for the input image Block. It assumes that the pixels in the
image belong to either a background class or an object class. 'pObject'
is an initial guess of the prior probability of an object pixel, or
equ... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/threshold.py#L304-L432 |
CellProfiler/centrosome | centrosome/threshold.py | get_background_threshold | def get_background_threshold(image, mask = None):
"""Get threshold based on the mode of the image
The threshold is calculated by calculating the mode and multiplying by
2 (an arbitrary empirical factor). The user will presumably adjust the
multiplication factor as needed."""
cropped_image = np.array... | python | def get_background_threshold(image, mask = None):
"""Get threshold based on the mode of the image
The threshold is calculated by calculating the mode and multiplying by
2 (an arbitrary empirical factor). The user will presumably adjust the
multiplication factor as needed."""
cropped_image = np.array... | Get threshold based on the mode of the image
The threshold is calculated by calculating the mode and multiplying by
2 (an arbitrary empirical factor). The user will presumably adjust the
multiplication factor as needed. | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/threshold.py#L436-L468 |
CellProfiler/centrosome | centrosome/threshold.py | get_robust_background_threshold | def get_robust_background_threshold(image,
mask = None,
lower_outlier_fraction = 0.05,
upper_outlier_fraction = 0.05,
deviations_above_average = 2.0,
... | python | def get_robust_background_threshold(image,
mask = None,
lower_outlier_fraction = 0.05,
upper_outlier_fraction = 0.05,
deviations_above_average = 2.0,
... | Calculate threshold based on mean & standard deviation
The threshold is calculated by trimming the top and bottom 5% of
pixels off the image, then calculating the mean and standard deviation
of the remaining image. The threshold is then set at 2 (empirical
value) standard deviations above th... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/threshold.py#L472-L515 |
CellProfiler/centrosome | centrosome/threshold.py | mad | def mad(a):
'''Calculate the median absolute deviation of a sample
a - a numpy array-like collection of values
returns the median of the deviation of a from its median.
'''
a = np.asfarray(a).flatten()
return np.median(np.abs(a - np.median(a))) | python | def mad(a):
'''Calculate the median absolute deviation of a sample
a - a numpy array-like collection of values
returns the median of the deviation of a from its median.
'''
a = np.asfarray(a).flatten()
return np.median(np.abs(a - np.median(a))) | Calculate the median absolute deviation of a sample
a - a numpy array-like collection of values
returns the median of the deviation of a from its median. | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/threshold.py#L520-L528 |
CellProfiler/centrosome | centrosome/threshold.py | binned_mode | def binned_mode(a):
'''Calculate a binned mode of a sample
a - array of values
This routine bins the sample into np.sqrt(len(a)) bins. This is a
number that is a compromise between fineness of measurement and
the stochastic nature of counting which roughly scales as the
square root of ... | python | def binned_mode(a):
'''Calculate a binned mode of a sample
a - array of values
This routine bins the sample into np.sqrt(len(a)) bins. This is a
number that is a compromise between fineness of measurement and
the stochastic nature of counting which roughly scales as the
square root of ... | Calculate a binned mode of a sample
a - array of values
This routine bins the sample into np.sqrt(len(a)) bins. This is a
number that is a compromise between fineness of measurement and
the stochastic nature of counting which roughly scales as the
square root of the sample size. | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/threshold.py#L530-L546 |
CellProfiler/centrosome | centrosome/threshold.py | get_ridler_calvard_threshold | def get_ridler_calvard_threshold(image, mask = None):
"""Find a threshold using the method of Ridler and Calvard
The reference for this method is:
"Picture Thresholding Using an Iterative Selection Method"
by T. Ridler and S. Calvard, in IEEE Transactions on Systems, Man and
Cybernetics, vol. ... | python | def get_ridler_calvard_threshold(image, mask = None):
"""Find a threshold using the method of Ridler and Calvard
The reference for this method is:
"Picture Thresholding Using an Iterative Selection Method"
by T. Ridler and S. Calvard, in IEEE Transactions on Systems, Man and
Cybernetics, vol. ... | Find a threshold using the method of Ridler and Calvard
The reference for this method is:
"Picture Thresholding Using an Iterative Selection Method"
by T. Ridler and S. Calvard, in IEEE Transactions on Systems, Man and
Cybernetics, vol. 8, no. 8, August 1978. | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/threshold.py#L548-L582 |
CellProfiler/centrosome | centrosome/threshold.py | get_kapur_threshold | def get_kapur_threshold(image, mask=None):
"""The Kapur, Sahoo, & Wong method of thresholding, adapted to log-space."""
cropped_image = np.array(image.flat) if mask is None else image[mask]
if np.product(cropped_image.shape)<3:
return 0
if np.min(cropped_image) == np.max(cropped_image):
... | python | def get_kapur_threshold(image, mask=None):
"""The Kapur, Sahoo, & Wong method of thresholding, adapted to log-space."""
cropped_image = np.array(image.flat) if mask is None else image[mask]
if np.product(cropped_image.shape)<3:
return 0
if np.min(cropped_image) == np.max(cropped_image):
... | The Kapur, Sahoo, & Wong method of thresholding, adapted to log-space. | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/threshold.py#L587-L625 |
CellProfiler/centrosome | centrosome/threshold.py | get_maximum_correlation_threshold | def get_maximum_correlation_threshold(image, mask = None, bins = 256):
'''Return the maximum correlation threshold of the image
image - image to be thresholded
mask - mask of relevant pixels
bins - # of value bins to use
This is an implementation of the maximum correlation thresh... | python | def get_maximum_correlation_threshold(image, mask = None, bins = 256):
'''Return the maximum correlation threshold of the image
image - image to be thresholded
mask - mask of relevant pixels
bins - # of value bins to use
This is an implementation of the maximum correlation thresh... | Return the maximum correlation threshold of the image
image - image to be thresholded
mask - mask of relevant pixels
bins - # of value bins to use
This is an implementation of the maximum correlation threshold as
described in Padmanabhan, "A novel algorithm for optimal image thre... | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/threshold.py#L629-L686 |
CellProfiler/centrosome | centrosome/threshold.py | weighted_variance | def weighted_variance(image, mask, binary_image):
"""Compute the log-transformed variance of foreground and background
image - intensity image used for thresholding
mask - mask of ignored pixels
binary_image - binary image marking foreground and background
"""
if not np.any(mask):... | python | def weighted_variance(image, mask, binary_image):
"""Compute the log-transformed variance of foreground and background
image - intensity image used for thresholding
mask - mask of ignored pixels
binary_image - binary image marking foreground and background
"""
if not np.any(mask):... | Compute the log-transformed variance of foreground and background
image - intensity image used for thresholding
mask - mask of ignored pixels
binary_image - binary image marking foreground and background | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/threshold.py#L691-L718 |
CellProfiler/centrosome | centrosome/threshold.py | sum_of_entropies | def sum_of_entropies(image, mask, binary_image):
"""Bin the foreground and background pixels and compute the entropy
of the distribution of points among the bins
"""
mask=mask.copy()
mask[np.isnan(image)] = False
if not np.any(mask):
return 0
#
# Clamp the dynamic range of the f... | python | def sum_of_entropies(image, mask, binary_image):
"""Bin the foreground and background pixels and compute the entropy
of the distribution of points among the bins
"""
mask=mask.copy()
mask[np.isnan(image)] = False
if not np.any(mask):
return 0
#
# Clamp the dynamic range of the f... | Bin the foreground and background pixels and compute the entropy
of the distribution of points among the bins | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/threshold.py#L720-L782 |
CellProfiler/centrosome | centrosome/threshold.py | log_transform | def log_transform(image):
'''Renormalize image intensities to log space
Returns a tuple of transformed image and a dictionary to be passed into
inverse_log_transform. The minimum and maximum from the dictionary
can be applied to an image by the inverse_log_transform to
convert it back to its f... | python | def log_transform(image):
'''Renormalize image intensities to log space
Returns a tuple of transformed image and a dictionary to be passed into
inverse_log_transform. The minimum and maximum from the dictionary
can be applied to an image by the inverse_log_transform to
convert it back to its f... | Renormalize image intensities to log space
Returns a tuple of transformed image and a dictionary to be passed into
inverse_log_transform. The minimum and maximum from the dictionary
can be applied to an image by the inverse_log_transform to
convert it back to its former intensity values. | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/threshold.py#L784-L804 |
CellProfiler/centrosome | centrosome/threshold.py | numpy_histogram | def numpy_histogram(a, bins=10, range=None, normed=False, weights=None):
'''A version of numpy.histogram that accounts for numpy's version'''
args = inspect.getargs(np.histogram.__code__)[0]
if args[-1] == "new":
return np.histogram(a, bins, range, normed, weights, new=True)
return np.histogram(... | python | def numpy_histogram(a, bins=10, range=None, normed=False, weights=None):
'''A version of numpy.histogram that accounts for numpy's version'''
args = inspect.getargs(np.histogram.__code__)[0]
if args[-1] == "new":
return np.histogram(a, bins, range, normed, weights, new=True)
return np.histogram(... | A version of numpy.histogram that accounts for numpy's version | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/threshold.py#L814-L819 |
CellProfiler/centrosome | centrosome/rankorder.py | rank_order | def rank_order(image, nbins=None):
"""Return an image of the same shape where each pixel has the
rank-order value of the corresponding pixel in the image.
The returned image's elements are of type np.uint32 which
simplifies processing in C code.
"""
flat_image = image.ravel()
sort_order = fl... | python | def rank_order(image, nbins=None):
"""Return an image of the same shape where each pixel has the
rank-order value of the corresponding pixel in the image.
The returned image's elements are of type np.uint32 which
simplifies processing in C code.
"""
flat_image = image.ravel()
sort_order = fl... | Return an image of the same shape where each pixel has the
rank-order value of the corresponding pixel in the image.
The returned image's elements are of type np.uint32 which
simplifies processing in C code. | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/rankorder.py#L4-L61 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.