print("Found %d nuclei." % data_log['num_nuclei_detected'][0])

        # organelle detection
        organelle_before_filter, organelle = find_organelle(pix,
                                                            thresholding,
                                                            min_size=min_size,
                                                            max_size=max_size)
        label_organelle = label(organelle, connectivity=1)
        data_log['num_%s_detected' %
                 analyze_organelle] = [obj.object_count(organelle)]
        print("Found %d %s." %
              (data_log['num_%s_detected' % analyze_organelle][0],
               analyze_organelle))

        # organelle pd dataset
        organelle_pd = organelle_analysis(pix, organelle,
                                          '%s' % analyze_organelle, pos)

        if analyze_organelle == 'nucleoli':
            # link nucleoli with corresponding nuclear
            round_x = [round(num) for num in organelle_pd['x']]
            round_y = [round(num) for num in organelle_pd['y']]
            organelle_pd['nuclear'] = obj.points_in_objects(
                label_nuclear, round_y, round_x)

            # nuclear pd dataset
            nuclear_pd = nuclear_analysis(label_nuclear, organelle_pd, pos)

            data_log['num_nucleoli_in_nuclei'] = [
                len(organelle_pd[organelle_pd['nuclear'] != 0])
            ]
            print("Found %d out of %d nucleoli within nuclei." %
# nuclear detection
label_nuclear = find_nuclear_nucleoli(pix)
data_log['num_nuclei_detected'] = [np.amax(label_nuclear)]
print("Found %d nuclei." % data_log['num_nuclei_detected'][0])

# nucleoli detection
nucleoli = find_organelle(pix,
                          thresholding,
                          min_size=min_size,
                          max_size=max_size)
label_nucleoli = label(nucleoli, connectivity=1)
data_log['num_nucleoli_detected'] = [obj.object_count(nucleoli)]
print("Found %d nucleoli." % data_log['num_nucleoli_detected'][0])

# nucleoli pd dataset
nucleoli_pd = organelle_analysis(pix, nucleoli, 'nucleoli', pos)
# link nucleoli with corresponding nuclear
round_x = [round(num) for num in nucleoli_pd['x']]
round_y = [round(num) for num in nucleoli_pd['y']]
nucleoli_pd['nuclear'] = obj.points_in_objects(label_nuclear, round_y, round_x)

data_log['num_nucleoli_in_nuclei'] = [
    len(nucleoli_pd[nucleoli_pd['nuclear'] != 0])
]
print("Found %d out of %d nucleoli within nuclei." %
      (data_log['num_nucleoli_in_nuclei'][0], obj.object_count(nucleoli)))

# nuclear pd dataset
nuclear_pd = nuclear_analysis(label_nuclear, nucleoli_pd, pos)

# ----------------------------------
for i in range(max_p + 1):
    temp = store.get_image(cb.t(data_t).c(data_c).z(0).p(i).build())
    temp_pix = np.reshape(temp.get_raw_pixels(),
                          newshape=[temp.get_height(),
                                    temp.get_width()])
    temp_sg = find_organelle(temp_pix,
                             thresholding,
                             min_size=min_size,
                             max_size=max_size)
    row, col = dat.get_grid_pos(i, num_grid)
    row_lst.append(row)
    col_lst.append(col)
    pix_lst.append(temp_pix)
    sg_lst.append(temp_sg)
    if export_pd_pre_stitch == 'Y':
        temp_sg_pd = organelle_analysis(temp_pix, temp_sg, 'sg', i)
        sg_fov_pd = pd.concat([sg_fov_pd, temp_sg_pd], ignore_index=True)

print("### Image analysis: Stitch image ...")
pix_pd = pd.DataFrame({
    'row': row_lst,
    'col': col_lst,
    'pix': pix_lst
})  # dataFrame of t(0).p(0) pixel images
pix = ana.pix_stitch(pix_pd, num_grid, num_grid)  # stitched image

if analyze_boundary not in ['Y', 'N']:
    raise ValueError("analyze_boundary only accepts 'Y' and 'N'. Got %s" %
                     analyze_boundary)
elif analyze_boundary == 'N':
    sg_pix_pd = pd.DataFrame({
Beispiel #4
0
store = mm.data().load_data(data_path, True)
max_t = store.get_max_indices().get_t()
cb = mm.data().get_coords_builder()
cb.t(0).p(0).c(0).z(0)

# ------------------------------
# IMAGE ANALYSIS based on position
# ------------------------------
print("### Image analysis: calculate SG mask/pd ...")
# test image of position
temp = store.get_image(cb.t(data_t).c(data_c).z(0).p(data_p).build())
pix = np.reshape(temp.get_raw_pixels(), newshape=[temp.get_height(), temp.get_width()])

sg = find_organelle(pix, thresholding, min_size=min_size, max_size=max_size, local_param=21)
label_sg = label(sg, connectivity=1)
sg_pd = organelle_analysis(pix, sg, 'sg', 0)

# --------------------------
# COLOR CODED IMAGES
# --------------------------
print("### Calculate color coded circ/ecce/int image ...")
# circ image
cmap1 = 'YlOrRd'
cmap1_napari = dis.num_color_colormap(cmap1, 255)[0]
cmap1_plt = dis.num_color_colormap(cmap1, 255)[1]
sg_circ = obj.obj_display_in_circularity(label_sg)

# ecce image
cmap2 = 'Blues'
cmap2_napari = dis.num_color_colormap(cmap2, 255)[0]
cmap2_plt = dis.num_color_colormap(cmap2, 255)[1]