esmraldi.segmentation¶
Module for the segmentation
Module Contents¶
Functions¶
|
Sort a stack image along the z-axis |
Extracts the connected component |
|
|
Extracts the connected component associated |
|
Sort images in ascending order |
|
Region growing in an image stack |
|
Average area of largest CCs on a collection of images. |
|
Chooses label associated with kmeans cluster where |
|
Chooses labels associated with highest average |
|
Detects a circle in an image. |
|
Detects the most frequent circle across several slices |
|
Fills a circle with a given value (default: 0). |
|
Specific function to remove thin structures |
|
Distances between each point and its closest neighbour |
|
Average edge length in a graph. |
|
Spatial chaos measure |
|
Finds images with spatial |
|
Spatial coherence of a binary image, |
|
|
|
Finds images with spatial |
Finds images with spatial |
|
|
|
|
Finds images that have a high variance in their intensities. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- esmraldi.segmentation.max_variance_sort(image_maldi)¶
Sort a stack image along the z-axis according to the maximum intensity variation
- Parameters
- image_maldi: numpy.ndarray
input image
- Returns
- numpy.ndarray
the sorted image stack
- esmraldi.segmentation.properties_largest_area_cc(ccs)¶
Extracts the connected component with the largest area.
- Parameters
- ccs: numpy.ndarray
connected components
- Returns
- RegionProperties
connected component with largest area
- esmraldi.segmentation.properties_median_perimeter(ccs)¶
- esmraldi.segmentation.region_property_to_cc(ccs, regionprop)¶
Extracts the connected component associated with the region.
- Parameters
- ccs: numpy.ndarray
connected components
- regionprop: RegionProperties
desired region
- Returns
- numpy.ndarray
the binary image (mask) of the desired region
- esmraldi.segmentation.sort_size_ascending(images, threshold)¶
Sort images in ascending order of the number of pixels inside greather than a given threshold.
- Parameters
- images: np.ndarray
array of images
- threshold: int
threshold to count pixels
- Returns
- np.ndarray
sorted array of images
- esmraldi.segmentation.region_growing(images, seedList, lower_threshold)¶
Region growing in an image stack with ITK.
All the images in the stack are processed sequentially and the seeds at step n depends on the segmentation by region growing at step n-1.
- Parameters
- images: numpy.ndarray
image stack
- seedList: list
list of 2D points to initialize the region growing
- lower_threshold: int
lower threshold for the region growing
- Returns
- list
seeds as 2d points
- esmraldi.segmentation.average_area(images)¶
Average area of largest CCs on a collection of images.
- Parameters
- images: np.ndarray
collection of images
- Returns
- int
average area of largest CCs
- esmraldi.segmentation.select_class_max_value(image_maldi, y_kmeans, nb_class)¶
Chooses label associated with kmeans cluster where images have highest average intensity.
- Parameters
- image_maldi: np.ndarray
images
- y_kmeans: np.ndarray
labels
- nb_class: int
number of clusters used by kmeans
- Returns
- int
class label
- esmraldi.segmentation.select_class_area(image_maldi, y_kmeans, nb_class)¶
Chooses labels associated with highest average area of largest CCs.
- Parameters
- image_maldi: np.ndarray
images
- y_kmeans: np.ndarray
labels
- nb_class: int
number of clsuters used by kmeans
- Returns
- int
class label
- esmraldi.segmentation.detect_circle(image, threshold, min_radius, max_radius)¶
Detects a circle in an image.
Uses hough transform over several radii.
- Parameters
- image: np.ndarray
image
- threshold: int
threshold for binary image
- min_radius: float
lower bound for radii
- max_radius: float
upper bound for radii
- Returns
- tuple
x,y,r: circle center + radii
- esmraldi.segmentation.detect_tube(image, threshold=150, min_radius=10, max_radius=50)¶
Detects the most frequent circle across several slices (3D volume).
- Parameters
- image: np.ndarray
image
- threshold: int
threshold for binary image
- min_radius: float
lower bound for radii
- max_radius: float
upper bound for radii
- Returns
- tuple
x,y,r: circle center + radii
- esmraldi.segmentation.fill_circle(center_x, center_y, radius, image, color=0)¶
Fills a circle with a given value (default: 0).
- Parameters
- center_x: float
center_x of circle
- center_y: float
center_y of circle
- radius: float
radius of circle
- image: np.ndarray
image where the circle must be filled
- color: int
value to replace
- Returns
- np.ndarray
image with filled circle
- esmraldi.segmentation.binary_closing(image, radius_selem=1)¶
Specific function to remove thin structures in the image.
Performs a morphological closing.
- Parameters
- image: np.ndarray
image
- radius_selem: int
radius in pixel for the structuring element
- Returns
- np.ndarray
morphologically closed image
- esmraldi.segmentation.distances_closest_neighbour(points)¶
Distances between each point and its closest neighbour in a set of points.
- Parameters
- points: np.ndarray
points as (x-y) coordinates
- Returns
- np.ndarray
distances between each point and its closest neighbour
- esmraldi.segmentation.average_distance_graph(image, threshold)¶
Average edge length in a graph.
The graph is constructed by a binarization of an image with a given threshold.
A node in the graph corresponds to a pixel above this threshold.
- Parameters
- image: np.ndarray
the image
- threshold: int
threshold for binary image
- Returns
- float
average edge length in the graph
- esmraldi.segmentation.spatial_chaos(image, quantiles=[])¶
Spatial chaos measure
See: Testing for Presence of Known and Unknown Molecules in Imaging Mass Spectrometry Alexandrov et al. (2013)
- Parameters
- image: np.ndarray
image
- quantiles: list
list of quantile threshold values
- Returns
- list
list of spatial chaos values for each image
- esmraldi.segmentation.find_similar_images_spatial_chaos(img, threshold, quantiles, return_indices=False)¶
Finds images with spatial chaos values greater than a given threshold.
- Parameters
- img: np.ndarray
image
- threshold: int
threshold for spatial chaos values
- quantiles: list
list of quantile threshold values
- Returns
- nd.ndarray
images whose spatial chaos values are above threshold
- esmraldi.segmentation.spatial_coherence(image)¶
Spatial coherence of a binary image, that is to say the area of the largest connected component.
- Parameters
- image: np.ndarray
binarized image
- Returns
- float
spatial coherence
- esmraldi.segmentation.median_perimeter(image)¶
- esmraldi.segmentation.find_similar_images_spatial_coherence(image_maldi, factor, quantiles=[], upper=100, fn=spatial_coherence, return_indices=False)¶
Finds images with spatial coherence values greater than a given threshold.
Spatial coherence values are computed for several quantile thresholds. The minimum area over the thresholded images is kept.
- Parameters
- image_maldi: np.ndarray
MALDI image
- factor: int
threshold for spatial coherence values
- quantiles: list
quantile threshold values (list of integers)
- upper: int
quantile upper threshold
- Returns
- np.ndarray
images whose spatial coherence values are above factor
- esmraldi.segmentation.find_similar_images_spatial_coherence_percentage(image_maldi, percentage, quantiles=[], upper=100, fn=spatial_coherence, return_indices=False)¶
Finds images with spatial coherence values greater than a threshold defined as a factor (percentage) multiplied by the maximum spatial coherence value.
Spatial coherence values are computed for several quantile thresholds. The minimum area over the thresholded images is kept.
- Parameters
- image_maldi: np.ndarray
MALDI image
- percentage: float
multiplicative factor for spatial coherence values
- quantiles: list
quantile threshold values (list of integers)
- upper: int
quantile upper threshold
- Returns
- np.ndarray
images whose spatial coherence values are above factor
- esmraldi.segmentation.median_minima(maxima, minima)¶
- esmraldi.segmentation.find_similar_images_variance(image_maldi, factor_variance=0.1, return_indices=False)¶
Finds images that have a high variance in their intensities.
Selects images according to a factor of max variance.
- Parameters
- image_maldi: np.ndarray
input image
- factor_variance: int
factor by which max variance is multiplied to determine a threshold above which images are selected
- Returns
- np.ndarray
array of high variability images
- esmraldi.segmentation.find_associated_distance_transforms(image_maldi, masks, quantiles, add_otsu_thresholds=True)¶
- esmraldi.segmentation.find_similar_image_distance_map_percentile(image_maldi, masks, factor, quantiles=[], add_otsu_thresholds=True, reverse=False, is_mean=False, return_indices=False, return_distances=False)¶
- esmraldi.segmentation.find_similar_image_distance_map_cc(image_maldi, masks, factor, quantiles=[], add_otsu_thresholds=True, return_indices=False, reverse=False)¶
- esmraldi.segmentation.extract_peaks_from_distribution(min_hist, bins, threshold)¶
- esmraldi.segmentation.distance_distribution(image, centroid, bins)¶
- esmraldi.segmentation.generate_random_distributions(image, centroid, quantiles, bins)¶
- esmraldi.segmentation.quantile_distance_distributions(image_maldi, quantiles=[], w=10)¶
- esmraldi.segmentation.find_similar_images_distance_map(image_maldi, mzs, factor, offsample_threshold=0.1, quantiles=[], in_sample=False, return_indices=False, return_thresholds=False, normalize_max=False, size_elem=5)¶
- esmraldi.segmentation.find_similar_images_dispersion_peaks(image_maldi, factor, quantiles=[], in_sample=False, return_indices=False, return_thresholds=False, size_elem=5)¶
- esmraldi.segmentation.find_similar_images_dispersion(image_maldi, factor, quantiles=[], in_sample=False, return_indices=False)¶
- esmraldi.segmentation.determine_on_off_sample(image_maldi, value_array, size_elem=1)¶
- esmraldi.segmentation.heterogeneity_mask(image, region, size=10)¶
- esmraldi.segmentation.mapping_neighbors_average(image, radius)¶
- esmraldi.segmentation.clustering_with_centers(images, centers, is_subtract, metric, mean_spectra_matrix=None, radius=0)¶