def compute_nuclei_area(gene, analysis_repo, gene_label, timepoint):
    dict_nucleus_area = {"Gene": [], "value": []}
    image_set = ImageSet(analysis_repo, [f"{'mrna'}/{gene}/{timepoint}/"])
    [dict_nucleus_area["value"].append(image.compute_nucleus_area()) for image in image_set.get_images()]
    [dict_nucleus_area["Gene"].append(gene_label) for image in image_set.get_images()]
    return pd.DataFrame(dict_nucleus_area)
def compute_transcript_by_cell_area(analysis_repo, gene, timepoints):
    transcript_by_cell_area = {"total_transcript": [], "cell_area": []}
    for timepoint in timepoints:
        image_set = ImageSet(analysis_repo, [f"{'mrna'}/{gene}/{timepoint}/"], force2D=False)
        [transcript_by_cell_area["total_transcript"].append(image.compute_cytoplasmic_total_spots()) for image in image_set.get_images()]
        [transcript_by_cell_area["cell_area"].append(image.compute_cell_area()) for image in image_set.get_images()]
    return pd.DataFrame(transcript_by_cell_area)
示例#3
0
for g in genes:
    [gene, timepoint] = g.split("-")
    image_set = ImageSet(analysis_repo, [f"{'mrna'}/{gene}/{timepoint}/"])
    nuc_dist, nucs_dist, cell_masks, nucs_pos = image_set.compute_cell_mask_between_nucleus_centroids(
    )

    # compute histogram mod
    hx, hy, _ = plt.hist(nuc_dist)
    bin_max = np.where(hx == hx.max())[0]
    hist_mod = hy[bin_max]
    if len(hist_mod) > 1:
        hist_mod = np.mean(hist_mod)

    # compute density by stripe and build spline wave graph
    image_counter = 0
    for im in image_set.get_images():
        nucleus_mask = im.get_nucleus_mask()
        nucleus_centroids = im.get_multiple_nucleus_centroid()
        spots = im.get_spots()
        z_lines = im.get_z_lines_masks()
        cell_masks_im = cell_masks[image_counter]
        nuc_dist_im = nucs_dist[image_counter]
        nuc_pos_im = nucs_pos[image_counter]
        mask_count = 0
        for i in range(len(cell_masks_im)):
            mask = cell_masks_im[i]
            nuc_d = nuc_dist_im[i]
            nuc_pos = nuc_pos_im[i]
            if hist_mod - 250 < nuc_d < hist_mod + 250:
                spots_reduced = helpers.keep_cell_mask_spots(spots, mask)
                spots_reduced = np.array(spots_reduced).reshape(