# -------------------------------------------------- # FRAP CURVE ANALYSIS from bleach spots # -------------------------------------------------- print("### Image analysis: FRAP curve calculation ...") # create control spots mask ctrl_nucleoli = ~nucleoli_pd.index.isin(log_pd['nucleoli'].tolist()) ctrl_x = nucleoli_pd[ctrl_nucleoli]['x'].astype(int).tolist() ctrl_y = nucleoli_pd[ctrl_nucleoli]['y'].astype(int).tolist() ctrl_spots = ana.analysis_mask(ctrl_x, ctrl_y, pix, num_dilation) num_ctrl_spots = obj.object_count(ctrl_spots) pointer_pd['num_ctrl_spots'] = [num_ctrl_spots] * len(pointer_pd) # get raw intensities for bleach spots and control spots pointer_pd['raw_int'] = ana.get_intensity(bleach_spots, pixels_tseries) ctrl_spots_int_tseries = ana.get_intensity(ctrl_spots, pixels_tseries) ctrl_pd = pd.DataFrame({ 'ctrl_spots': np.arange(0, num_ctrl_spots, 1), 'raw_int': ctrl_spots_int_tseries }) print("### Image analysis: background correction ...") # background intensity measurement bg_int_tseries = ana.get_bg_int(pixels_tseries) pointer_pd['bg_int'] = [bg_int_tseries] * len(pointer_pd) # background intensity fitting bg_fit = mat.fitting_linear(np.arange(0, len(bg_int_tseries), 1), bg_int_tseries) pointer_pd = dat.add_columns(
# FRAP CURVE ANALYSIS from bleach spots # -------------------------------------------------- print("### Image analysis: FRAP curve calculation ...") # create control spots mask ctrl_organelle = ~organelle_pd.index.isin( log_pd['%s' % analyze_organelle].tolist()) ctrl_x = organelle_pd[ctrl_organelle]['x'].astype(int).tolist() ctrl_y = organelle_pd[ctrl_organelle]['y'].astype(int).tolist() ctrl_spots, ctrl_pd = ble.get_spots(ctrl_y, ctrl_x, pix, num_dilation) ctrl_pd.columns = ['x', 'y', 'ctrl_spots'] num_ctrl_spots = obj.object_count(ctrl_spots) pointer_pd['num_ctrl_spots'] = [num_ctrl_spots] * len(pointer_pd) # get raw intensities for bleach spots and control spots pointer_pd['raw_int'] = ana.get_intensity( label(bleach_spots, connectivity=1), pixels_tseries) ctrl_pd['raw_int'] = ana.get_intensity( label(ctrl_spots, connectivity=1), pixels_tseries) ctrl_pd['pos'] = [pos] * num_ctrl_spots # link ctrl spots with corresponding organelle ctrl_pd['%s' % analyze_organelle] = obj.points_in_objects( label_organelle, ctrl_pd['x'], ctrl_pd['y']) print("### Image analysis: background correction ...") # background intensity measurement bg_int_tseries = ana.get_bg_int(pixels_tseries) pointer_pd['bg_int'] = [bg_int_tseries] * len(pointer_pd) # background intensity fitting bg_fit = mat.fitting_linear(np.arange(0, len(bg_int_tseries), 1),
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) # calculate nuclear background intensity # calculate nuclear without nucleoli region label_nuclear_bg = label_nuclear.copy() label_nuclear_bg[organelle_before_filter == 1] = 0 # get label_nuclear_bg_pd label_nuclear_bg_pd = pd.DataFrame( regionprops_table(label_nuclear_bg, properties=['label'])) label_nuclear_bg_pd['mean_intensity'] = ana.get_intensity( label_nuclear_bg, pixels_tseries) # assign nuclear background intensity to corresponding nuclear nuclear_pd = dat.copy_based_on_index(nuclear_pd, label_nuclear_bg_pd, 'nuclear', 'label', ['nuclear_bg_int'], ['mean_intensity']) # assign nuclear background intensity to corresponding nucleoli organelle_pd = dat.copy_based_on_index(organelle_pd, nuclear_pd, 'nuclear', 'nuclear', ['nuclear_bg_int'], ['nuclear_bg_int']) data_log['num_nucleoli_in_nuclei'] = [ len(organelle_pd[organelle_pd['nuclear'] != 0]) ] print("Found %d out of %d nucleoli within nuclei." % (data_log['num_nucleoli_in_nuclei'][0], obj.object_count(organelle)))