griottes package
graphmaker
Tools for graph generation
graph_generation_func
- griottes.graphmaker.graph_generation_func.generate_geometric_graph(user_entry, descriptors: list = [], distance: float = 60, image_is_2D=False, min_area=0, analyze_fluo_channels=False, radius=30, mask_channel=None)
Creates a geometric graph. This function creates a geometric graph from an image or a dataframe object. :param user_entry: contains the information on the cells. :type user_entry: pandas.DataFrame or numpy.ndarray :param descriptors: contains the cell information included in the
network nodes.
- Parameters:
distance (float, optional) – the maximum distance between two nodes.
image_is_2D (bool, optional) – if True, the image is analyzed as a 2D image. The default is False.
min_area (int, optional) – the minimum area of a cell. The default is 0.
analyze_fluo_channels (bool, optional) – if True, the fluorescence channels are analyzed. The default is False.
radius (int, optional) – Radius of the sphere within the which the fluorescence is analyzed. Irrelevant for the ‘basic’ method. The default is 30.
mask_channel (int, optional) – The channel containing the cell masks The default is None.
- Returns:
The graph representation of the input.
- Return type:
nx.Graph
- griottes.graphmaker.graph_generation_func.generate_contact_graph(labels_array: ndarray, dataframe_with_descriptors: Optional[DataFrame] = None, mask_channel=None, min_area=0, analyze_fluo_channels=True, image_is_2D=True, fluo_channel_analysis_method='basic', descriptors=[], radius=30, **kwargs)
Creates a contact graph. This function creates a contact graph from an image. The contact graph is a graph where each node represents a region and each edge represents a contact between two adjascent regions. :param labels_array: contains the information on the cells. :type labels_array: numpy.ndarray :param dataframe_with_descriptors: Labels, coordinates and, you know, whatever you want to be included in the graph :type dataframe_with_descriptors: pandas.DataFrame :param descriptors: contains the cell information included in the
network nodes.
- Parameters:
image_is_2D (bool, optional) – if True, the image is analyzed as a 2D image. The default is False.
min_area (int, optional) – the minimum area of a cell. The default is 0.
analyze_fluo_channels (bool, optional) – if True, the fluorescence channels are analyzed. The default is True.
radius (int, optional) – Radius of the sphere within the which the fluorescence is analyzed. Irrelevant for the ‘basic’ method. The default is 30.
mask_channel (int, optional) – The channel containing the cell masks The default is None.
- Returns:
The graph representation of the input.
- Return type:
nx.Graph
- griottes.graphmaker.graph_generation_func.generate_delaunay_graph(user_entry, descriptors: list = [], image_is_2D=False, min_area=0, analyze_fluo_channels=False, fluo_channel_analysis_method='basic', radius=30, distance=30, mask_channel=None)
Creates a Delaunay graph. This function creates a Delaunay graph from an image or a dataframe object. :param user_entry: contains the information on the cells. :type user_entry: pandas.DataFrame or numpy.ndarray :param descriptors: contains the cell information included in the
network nodes.
- Parameters:
distance (float, optional) – the maximum distance between two nodes.
fluo_channel_analysis_method (str, optional) – the method used to analyze the fluorescence channels. ‘basic’ measures the fluorescence properties within the cell mask, ‘local_sphere’ within a sphere of radius ‘radius’ and ‘local_voronoi’ within the Voronoi tesselation of the cell.
radius (float, optional) – radius of the sphere within the which the fluorescence is analyzed. Irrelevant for the ‘basic’ fluorescence analysis method.
image_is_2D (bool, optional) – if True, the image is analyzed as a 2D image. The default is False.
min_area (int, optional) – the minimum area of a cell. The default is 0.
analyze_fluo_channels (bool, optional) – if True, the fluorescence channels are analyzed. The default is False.
mask_channel (int, optional) – The channel containing the cell masks The default is None.
- Returns:
The graph representation of the input.
- Return type:
nx.Graph
- griottes.graphmaker.graph_generation_func.trim_graph_voronoi(G, distance, image_is_2D)
Remove slinks above the distance length. Serves to remove unrealistic edges from the graph. :param G: The graph representation of the input image/table. :type G: nx.Graph :param distance: The maximum distance between two nodes. :type distance: float :param image_is_2D: If True, the image is 2D. :type image_is_2D: bool
- Returns:
The graph representation of the input.
- Return type:
nx.Graph
- griottes.graphmaker.graph_generation_func.get_region_contacts_2D(mask_image)
From the masked image create a dataframe containing the information on all the links between region.
- griottes.graphmaker.graph_generation_func.get_region_contacts_3D(mask_image)
From the masked image create a dataframe containing the information on all the links between region.
make_spheroids
- griottes.graphmaker.make_spheroids.single_spheroid_process(spheroid_frame: DataFrame, descriptors: list = [])
spheroid_frame has the label of each cell as index.
graph_plot
- griottes.graphplotter.graph_plot.network_plot_2D(G, background_image=None, figsize: tuple = (8, 8), alpha_line=0.6, scatterpoint_size=20, legend=False, edge_color='k', line_factor=1, legend_fontsize=18, include_weights=False)
- griottes.graphplotter.graph_plot.network_plot_3D(G, figsize: tuple = (8, 8), alpha_line=0.6, scatterpoint_size=20, legend=False, legend_fontsize=12, theta=0, psi=0, xlim=None, ylim=None, zlim=None)
- griottes.graphplotter.graph_plot.Voronoi_3D(G, angle)
analyse
cell_property_extraction
- griottes.analyse.cell_property_extraction.get_nuclei_properties(image, mask_channel)
Get properties of nuclei in image.
- Parameters:
image (numpy.ndarray) – Image with nuclei masks.
mask_channel (int) – Channel of the mask.
- Return type:
pandas.DataFrame
- griottes.analyse.cell_property_extraction.get_shape_properties(properties, image, mask_channel, min_area, ndim)
Calculate shape properties of the nuclei.
- Parameters:
properties (pandas.DataFrame) – Dataframe containing centroid, area, and label of the nuclei.
image (numpy.ndarray) – Image with nuclei masks.
mask_channel (int) – Channel of the mask.
min_area (int) – Minimum area of the nuclei to include in analysis.
ndim (int) – Number of dimensions in the image (2 or 3).
- Returns:
Dataframe with additional columns for shape properties.
- Return type:
pandas.DataFrame
- griottes.analyse.cell_property_extraction.get_fluo_properties(image, fluo_channel, mask_channel=0)
Get mean fluorescence intensity of each labeled region in a mask.
- Parameters:
image (numpy.ndarray) – Multichannel image containing the fluorescence channel.
fluo_channel (int) – Channel containing the fluorescence signal.
mask_channel (int, optional) – Channel containing the mask. Default is 0.
- Returns:
Dataframe containing the mean fluorescence intensity and label of each region.
- Return type:
pandas.DataFrame
- griottes.analyse.cell_property_extraction.basic_fluo_prop_analysis(properties, image, mask_channel)
Calculate the mean intensity of each fluorescence channel for each nucleus.
- Parameters:
properties (pandas.DataFrame) – DataFrame containing properties of each nucleus.
image (numpy.ndarray) – Image with fluorescence channels.
mask_channel (int) – Channel of the mask.
- Returns:
Updated properties DataFrame with mean fluorescence intensity for each channel.
- Return type:
pandas.DataFrame
- griottes.analyse.cell_property_extraction.sphere_mean_intensity(intensity_image, position, radius, percentile=50)
Calculate the mean intensity and percentile of a sphere within an intensity image.
- Parameters:
intensity_image (numpy.ndarray) – The 3D intensity image.
position (tuple) – The center of the sphere in (z, y, x) format.
radius (float) – The radius of the sphere.
percentile (float, optional) – The percentile to calculate, default is 50.
- Returns:
The mean intensity and percentile.
- Return type:
tuple of float
- griottes.analyse.cell_property_extraction.calculate_sphere_fluo_properties(properties: DataFrame, image: ndarray, fluo_channel: int, radius: int, mask_channel: int, percentile: int) DataFrame
Calculate mean and percentile fluorescence intensity within a sphere around each nucleus.
- Parameters:
properties (pandas.DataFrame) – Properties of the nuclei.
image (numpy.ndarray) – Image with fluorescence channels.
fluo_channel (int) – Channel containing the fluorescence signal.
radius (int) – Radius of the sphere around each nucleus.
mask_channel (int) – Channel of the nuclei mask.
percentile (int) – Percentile of the fluorescence intensity to calculate.
- Returns:
Mean and percentile fluorescence intensity within the sphere around each nucleus.
- Return type:
pandas.DataFrame
- griottes.analyse.cell_property_extraction.sphere_fluo_property_analysis(properties, image, mask_channel, radius, percentile)
Calculate sphere-based fluorescence properties for each label in the mask.
- Parameters:
properties (pandas.DataFrame) – DataFrame with properties of each label in the mask.
image (numpy.ndarray) – 3D image stack.
mask_channel (int) – Index of the channel containing the mask.
radius (int) – Radius of the sphere used to calculate properties.
percentile (int) – Percentile used to calculate the fluorescence intensity.
- Returns:
Updated DataFrame with fluorescence properties for each label.
- Return type:
pandas.DataFrame
- griottes.analyse.cell_property_extraction.in_hull(p, hull)
Test if points in p are in hull
p should be a NxK coordinates of N points in K dimensions hull is either a scipy.spatial.Delaunay object or the MxK array of the coordinates of M points in `K`dimensions for which Delaunay triangulation will be computed
- griottes.analyse.cell_property_extraction.make_spherical_mask(image, point_coordinates, radius)
Create a spherical mask centered at point_coordinates with radius.
- Parameters:
image (numpy.ndarray) – Input image.
point_coordinates (tuple of int) – Coordinates of the center of the sphere in the format (z, x, y).
radius (int) – Radius of the sphere.
- Returns:
A binary mask of the same shape as image, where voxels inside the sphere are set to 1 and voxels outside the sphere are set to 0.
- Return type:
numpy.ndarray
- griottes.analyse.cell_property_extraction.make_voronoi_mask(properties, image, mask_channel, radius)
Create a Voronoi diagram of the nuclei centroids and use it to generate a binary mask.
- Parameters:
properties (pandas.DataFrame) – DataFrame with properties of the nuclei.
image (numpy.ndarray) – Image with nuclei masks.
mask_channel (int) – Channel of the mask.
radius (float) – Radius of the spherical mask used to generate the Voronoi diagram.
- Returns:
Binary mask with the same shape as the input image, where each pixel is assigned to the nearest nucleus based on the Voronoi diagram.
- Return type:
numpy.ndarray
- griottes.analyse.cell_property_extraction.get_fluo_properties_voronoi(properties, image, fluo_channel, label_matrix, percentile)
Get fluorescence properties for each cell in a Voronoi diagram.
- Parameters:
properties (pandas.DataFrame) – DataFrame containing cell properties.
image (numpy.ndarray) – Input image.
fluo_channel (int) – Index of the fluorescence channel.
label_matrix (numpy.ndarray) – Label matrix of the Voronoi diagram.
percentile (int) – Percentile to calculate for fluorescence intensity.
- Returns:
DataFrame containing fluorescence properties for each cell.
- Return type:
pandas.DataFrame
- griottes.analyse.cell_property_extraction.voronoi_fluo_property_analysis(properties, image, mask_channel, radius, return_voronoi_mask=False, percentile=50)
Estimate the fluorescence properties of Voronoi cells.
Calculate the Voronoi mask for each cell, then use the mask to estimate the fluorescence intensities inside the mask.
- Parameters:
properties (pandas.DataFrame) – DataFrame with nuclear properties, including centroid coordinates.
image (numpy.ndarray) – 3D image stack with fluorescence channels.
mask_channel (int) – Index of the nuclear mask channel.
radius (int) – Radius of the spherical mask used for Voronoi quantification.
return_voronoi_mask (bool, optional) – Whether to return the labeled Voronoi tesselation as a binary mask. Default is False.
percentile (int, optional) – Percentile used for fluorescence intensity quantification. Default is 50.
- Returns:
DataFrame with fluorescence properties for each Voronoi cell, and optionally the labeled Voronoi tesselation as a binary mask.
- Return type:
pandas.DataFrame or tuple of (pandas.DataFrame, numpy.ndarray)
- Raises:
ValueError – If the Voronoi diagram cannot be computed.
- griottes.analyse.cell_property_extraction.get_cell_properties(image, mask_channel=0, analyze_fluo_channels=False, fluo_channel_analysis_method='basic', cell_geometry_properties=False, labeled_voronoi_tesselation=False, radius=5, min_area=50, percentile=95, ndim=3)
Calculate the cell properties for a given image.
- Parameters:
image (numpy array) – The image to be analyzed.
mask_channel (int) – The channel to be used as a mask.
analyze_fluo_channels (bool) – If True, the fluorescence channels will be analyzed.
fluo_channel_analysis_method (str) – The method to be used to analyze the fluorescence channels. Either basic, local_voronoi, or local_sphere.
cell_geometry_properties (bool) – If True, the cell geometry properties will be calculated.
labeled_voronoi_tesselation (bool) – If True, the voronoi tesselation will be generated and returned as an array.
radius (int) – Maximum radius within which the cell properties are measured.
min_area (int) – Minimum area of a cell to be considered.
percentile (int) – Percentile of the intensity distribution to be used for the percentile intensity calculation.
- Return type:
pandas.DataFrame
voronoi_cell_property_analysis
- griottes.analyse.voronoi_cell_property_analysis.in_hull(p, hull)
Test if points in p are in hull
p should be a NxK coordinates of N points in K dimensions hull is either a scipy.spatial.Delaunay object or the MxK array of the coordinates of M points in `K`dimensions for which Delaunay triangulation will be computed