spots_in_yeasts.spotsInYeasts module
- class spots_in_yeasts.spotsInYeasts.YeastsPartitionGraph(o_graph, cell_to_nuclei, nucleus_to_cells, labeled_yeasts, labeled_nuclei)[source]
- Bases: - object- Class implementing the Hopcroft-Karp algorithm to create a maximal dual-matching. - make_nuclei_lut(cell_to_nuclei, cells_lut)[source]
- Makes a dictionary to transform the indices of nuclei. It is used to make the nuclei indices match their owner cell’s index. - Parameters
- cell_to_nuclei – Structure giving for a cell the index of its nucleus. 
- cells_lut – LUT used to make mother and daughter cells match each other’s label. 
 
- Returns
- A LUT to transform the nuclei indices. 
 
 
- spots_in_yeasts.spotsInYeasts.adjacency_graph(labeled_cells, check_undirected=False)[source]
- Creates the adjacency graph of the segmented cells. Two cells are called “adjacent” if their labels are touching one another in 8-connectivity. - Parameters
- labeled_cells – The labeled image representing segmented cells. 
- check_undirected – Activate the cheking of the graph essential properties (only for debug purposes). 
 
- Returns
- A dictionary representing the cells as a graph, indexed by cells’ labels. For each label, gives: its location and its neighbors 
 
- spots_in_yeasts.spotsInYeasts.assign_nucleus(labeled_cells, labeled_nuclei, covering_threshold, graph=None)[source]
- First step of the nuclei segmentation. It starts by finding all the cells having “their own nucleus” (== a cell overlaped by a nucleus) - Parameters
- labeled_cells – The image containing the labeled cells. 
- labeled_nuclei – The image containing the labeled nuclei. 
- covering_threshold – Percentage of a cell that must be covered by nuclei for this cell to be considered dead. 
- graph – Adjacency graph of the labeled cells. 
 
- Returns
- The labeled cells from which we removed invalid individuals. 
- The labeled nuclei 
- The adjacency graph from which we removed dead individuals. 
- A structure mapping cells indices to nuclei indices. 
- A structure mapping nuclei indices to cells indices. 
 
 
- spots_in_yeasts.spotsInYeasts.associate_spots_yeasts(labeled_cells, labeled_spots, fluo_spots, area_threshold_down, area_threshold_up, solidity_threshold, extent_threshold, classification=None)[source]
- Associates each spot with the label it belongs to. A safety check is performed to make sure no spot falls in the background. - Parameters
- labeled_cells – A single-channeled image with dtype=uint16 containing the segmented transmission image. 
- labeled_spots – A labelised image representing spots 
- fluo_spots – The original fluo image containing spots. 
 
- Returns
- A dictionary in which keys are the labels of each cell. Each key points to a list of dictionary. Each element of the list corresponds to a spot. An image representing labels in the fluo channel (a label per spot) is also returned. 
 
- spots_in_yeasts.spotsInYeasts.create_random_lut()[source]
- Creates a random LUT of 256 slots to display labeled images with colors far apart from each other. Black is reserved for the background. - Returns
- A cmap object that can be used with the imshow() function. ex: imshow(image, cmap=create_random_lut()) 
- Return type
- LinearSegmentedColormap 
 
- spots_in_yeasts.spotsInYeasts.create_reference_to(labeled_cells, labeled_spots, spots_list, name, control_dir_path, source_path, projection_cells, projection_spots, indices, labeled_nuclei, nuclei_fluo, spots_colors)[source]
- Creates a folder containing everything a user needs to see in order to check whether the process ended correctly and produced a correct segmentation. 
- spots_in_yeasts.spotsInYeasts.distance_spot_nuclei(labeled_cells, labeled_nuclei, labeled_spots)[source]
- Assign a class to every spot depending on its location according to the nucleus of the cell it is in. It can be ‘nuclear’, ‘cytoplasmic’ or ‘peripheral’. - Parameters
- labeled_cells – The image containing labeled cells. 
- labeled_nuclei – The image containing labeled nuclei. 
- labeled_spots – The image containing labeled spots. 
 
- Returns
- A dictionary giving for each spot label (int), its category (str). 
 
- spots_in_yeasts.spotsInYeasts.fill_holes(image)[source]
- A hole is a background area surrounded by a unique label and from which we can’t reach the image’s border. No in-place editing. - Parameters
- image – A labeled image on black background 
- Returns
- The same image as input but without holes in labels. 
 
- spots_in_yeasts.spotsInYeasts.find_focused_slice(stack, around=2)[source]
- Determines which slice has the best focus and selects a range of slices around it. The process is based on the variance recorded for each slice. Displays a warning if the number of slices is insufficient. A safety check is performed to ensure that the returned indices are within the range of the stack’s size. - Parameters
- stack – (image stack) The stack in which we search the focused area. 
- around – (int) Number of slices to select around the most in-focus one. 
 
- Returns
- A tuple centered around the most in-focus slice. If we call ‘F’ the index of that slice, then the tuple is: (F-around, F+around). 
- Return type
- (int, int) 
 
- spots_in_yeasts.spotsInYeasts.is_undirected(graph)[source]
- Checks whether a graph is undirected or not. 
- spots_in_yeasts.spotsInYeasts.nuclei_from_fluo(stack_fluo_nuclei)[source]
- Produces a segmentation of nuclei based on the nuclei marking (either a single slice or a stack). - Parameters
- marking. (An image or a stack representing the nuclei) – 
 - Results:
- The MIP of the provided image and a labeled version of nuclei. 
 
- spots_in_yeasts.spotsInYeasts.place_markers(shp, m_list)[source]
- Places pixels with an incremental intensity (from 1) at each position contained in the list. - Returns
- A mask with black background and one pixel at each intensity from 1 to len(m_list). 
- Parameters
- shp – A 2D tuple representing the shape of the mask to be created. 
- m_list – A list of tuples representing 2D coordinates. 
 
 
- spots_in_yeasts.spotsInYeasts.prepare_directory(path)[source]
- Prepares a directory to receive the control images for the batch mode. 
- spots_in_yeasts.spotsInYeasts.remove_excessive_coverage(labeled_cells, labeled_nuclei, covering_threshold)[source]
- Removing cells in which the nucleus occupies too much surface (dead cell). - Parameters
- labeled_cells – The image containing the labeled cells. 
- labeled_nuclei – The image containing the labeled nuclei. 
- covering_threshold – Percentage of a cell that must be covered by nuclei for this cell to be considered dead. 
 
- Returns
- Two sets containing the indices of discarded nuclei and the indices of discarded cells. 
 
- spots_in_yeasts.spotsInYeasts.remove_labels(image, labels)[source]
- Macro-function removing some labels from an image. The modification is made in-place. - Parameters
- image – A labeled image. 
- labels – A set of indices that we want to remove from image. 
 
 
- spots_in_yeasts.spotsInYeasts.segment_nuclei(labeled_yeasts, stack_fluo_nuclei, threshold_coverage)[source]
- Launches the procedure to segment nuclei from the dedicated fluo channel, and merge mother cells with their daughter if the division process is still ongoing. - Parameters
- labeled_yeasts – Image containing the labeled yeast cells. 
- stack_fluo_nuclei – Image containing the stained nuclei. 
- threshold_coverage – Percentage (in [0.0, 1.0]) of a cell that must be covered by a nucleus to be considered dead. 
 
- Returns
- The maximal projection of the stained nuclei channel. 
- The labeled yeasts from which we removed the dead cells. 
- The image containing the labeled nuclei. 
 
 
- spots_in_yeasts.spotsInYeasts.segment_spots(stack, labeled_cells, death_threshold, sigma=3.0, peak_d=5, threshold_rel=0.7)[source]
- Parameters
- stack – A numpy array representing the fluo channel 
- Returns
- A dictionary containing several pieces of information about spots.
- original: The input image after maximal projection 
- contrasted: A version of the channel stretched on the whole histogram. 
- mask: A labeled image containing an index per detected spot. 
- locations: A list of 2D coordinates representing each spot. 
 
 
 
- spots_in_yeasts.spotsInYeasts.segment_transmission(stack, gpu=True, slices_around=2)[source]
- Takes the path of an image that contains some yeasts in transmission. - Parameters
- stack – A numpy array representing the transmission channel 
- Returns
- A uint16 image containing labels. Each label corresponds to an instance of yeast cell. 
 
- spots_in_yeasts.spotsInYeasts.segment_yeasts_cells(transmission, gpu=True)[source]
- Takes the transmission channel (brightfield) of yeast cells and segments it (instances segmentation). - Parameters
- transmission (image) – Single channeled image, in brightfield, representing yeasts 
- Returns
- (image) An image containing labels (one value == one individual). 
 
- spots_in_yeasts.spotsInYeasts.write_labels_image(image, font_scale)[source]
- Creates an image on which the indices of labels are literally written in the center of each label. - Parameters
- image – A labeled image. 
- fonst_scale – Size of the font to write digits. 
 
- Returns
- A binary mask representing the literal index of each label.