def compute_cell_volume(self): """ computes cell volume in in real pixel size using the cell mask """ cell_mask = self.get_cell_mask() height_map = self.adjust_height_map() cell_volume = height_map[np.where(cell_mask[:] == 1)].sum() if (len(self.get_multiple_nucleus_centroid())) > 1: return cell_volume / len( self.get_multiple_nucleus_centroid()) * helpers.volume_coeff() else: return cell_volume * helpers.volume_coeff()
def compute_density_per_quadrant(self, mtoc_quad, quadrant_mask, quadrants_num=4) -> np.ndarray: """ compute volumic density per quadrant; return an array of values of density paired with the MTOC presence flag (0/1) """ IF = self.compute_cytoplasmic_intensities() height_map = self.adjust_height_map(cytoplasm=True) density_per_quadrant = np.zeros((quadrants_num, 2)) # mark the MTOC quadrant density_per_quadrant[mtoc_quad - 1, 1] = 1 for quad_num in range(quadrants_num): height = np.sum(height_map[quadrant_mask == quad_num + 1]) quadrant_volume = height * helpers.volume_coeff() density_per_quadrant[quad_num, 0] = np.sum( IF[quadrant_mask == (quad_num + 1)]) / quadrant_volume if density_per_quadrant[:, 1].sum() != 1.0: raise (RuntimeError, "error in the MTOC quadrant detection for image %s" % self._path) return density_per_quadrant
def compute_density_per_quadrant(self, mtoc_quad, quadrant_mask, quadrants_num=4) -> np.ndarray: """ compute volumic density per quadrant; return an array of values of density paired with the MTOC presence flag (0/1) """ volume_coeff = helpers.volume_coeff() height_map = self.adjust_height_map(cytoplasm=True) spots = self.get_cytoplasmic_spots() density_per_quadrant = np.zeros((quadrants_num, 2)) for spot in spots: spot_quad = quadrant_mask[spot[1], spot[0]] if spot_quad == 0: continue density_per_quadrant[spot_quad - 1, 0] += 1 # mark the mtoc quadrant density_per_quadrant[mtoc_quad - 1, 1] = 1 for quad_num in range(quadrants_num): quadrant_volume = np.sum( height_map[quadrant_mask == quad_num + 1]) * volume_coeff density_per_quadrant[quad_num, 0] = density_per_quadrant[quad_num, 0] / quadrant_volume if density_per_quadrant[:, 1].sum() != 1.0: raise (RuntimeError, "error in the MTOC quadrant detection for image %s" % self._path) return density_per_quadrant
def compute_cell_volume(self): """ compute cell volume in real pixel size using the cell mask """ cell_mask = self.get_cell_mask() height_map = self.adjust_height_map() cell_volume = height_map[cell_mask == 1].sum() return cell_volume * helpers.volume_coeff()
def compute_peripheral_cell_volume(self): """ computes cell volume in in real pixel size using the cell mask """ peripheral_fraction_threshold = constants.analysis_config[ 'PERIPHERAL_FRACTION_THRESHOLD'] cell_mask_dist_map = self.get_cell_mask_distance_map() peripheral_binary_mask = (cell_mask_dist_map > 0) & \ (cell_mask_dist_map <= peripheral_fraction_threshold).astype(int) cell_mask = self.get_cell_mask() height_map = self.adjust_height_map() height_map_periph = np.multiply(height_map, peripheral_binary_mask) peripheral_cell_volume = height_map_periph[np.where( cell_mask[:] == 1)].sum() if (len(self.get_multiple_nucleus_centroid())) > 1: return peripheral_cell_volume / len( self.get_multiple_nucleus_centroid()) * helpers.volume_coeff() else: return peripheral_cell_volume * helpers.volume_coeff()
def compute_peripheral_cell_volume(self, peripheral_threshold): """ compute volume in the periphery in real pixel size using the cell mask """ cell_mask_dist_map = self.get_cell_mask_distance_map() peripheral_binary_mask = ( (cell_mask_dist_map > 0) & (cell_mask_dist_map <= peripheral_threshold)).astype(int) height_map = self.adjust_height_map() height_map_periph = np.multiply(height_map, peripheral_binary_mask) peripheral_cell_volume = height_map_periph.sum( ) * helpers.volume_coeff() return peripheral_cell_volume
def compute_cytoplasmic_volume(self): """compute volume of the cytoplasm in in real pixel size using cytoplasm mask and adjusted height map""" cytoplasm_mask = self.get_cytoplasm_mask() height_map = self.adjust_height_map() cytoplasm_volume = height_map[cytoplasm_mask == 1].sum() return cytoplasm_volume * helpers.volume_coeff()
def compute_nucleus_volume(self): """compute nucleus volume in in real pixel size using nucleus mask""" nucleus_mask = self.get_nucleus_mask() height_map = self.adjust_height_map() nucleus_volume = height_map[nucleus_mask == 1].sum() return nucleus_volume * helpers.volume_coeff()