distance_lst.append(distance_map[log_pd['y'][i]][log_pd['x'][i]])
        log_pd['distance'] = distance_lst

        # generate bleach spot mask and bleach spots dataframe (pointer_pd)
        bleach_spots, pointer_pd = ble.get_bleach_spots(
            log_pd, label_organelle, analyze_organelle, num_dilation)
        data_log['num_bleach_spots'] = [obj.object_count(bleach_spots)]
        print("%d spots passed filters for analysis." %
              data_log['num_bleach_spots'][0])

        # add bleach spots corresponding organelle measurements
        pointer_pd = dat.copy_based_on_index(
            pointer_pd, organelle_pd, '%s' % analyze_organelle,
            '%s' % analyze_organelle, [
                '%s_x' % analyze_organelle,
                '%s_y' % analyze_organelle,
                '%s_size' % analyze_organelle,
                '%s_mean_int' % analyze_organelle,
                '%s_circ' % analyze_organelle
            ], ['x', 'y', 'size', 'raw_int', 'circ'])

        # --------------------------------------------------
        # 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()
# link pointer with corresponding nucleoli
log_pd['nucleoli'] = obj.points_in_objects(label_nucleoli, log_pd['x'],
                                           log_pd['y'])

# generate bleach spot mask and bleach spots dataframe (pointer_pd)
bleach_spots, pointer_pd = ble.get_bleach_spots(log_pd, label_nucleoli,
                                                num_dilation)
data_log['num_bleach_spots'] = [obj.object_count(bleach_spots)]
print("%d spots passed filters for analysis." %
      data_log['num_bleach_spots'][0])

# add bleach spots corresponding nucleoli measurements
pointer_pd = dat.copy_based_on_index(
    pointer_pd, nucleoli_pd, 'nucleoli', 'nucleoli', [
        'nucleoli_x', 'nucleoli_y', 'nucleoli_size', 'nucleoli_mean_int',
        'nucleoli_circ'
    ], ['x', 'y', 'size', 'raw_int', 'circ'])

# --------------------------------------------------
# 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)
# combine value data
data1_value = pd.read_csv(("%ssummary_value.txt" % data1_source),
                          na_values=['.'],
                          sep='\t')
data2_value = pd.read_csv(("%ssummary_value.txt" % data2_source),
                          na_values=['.'],
                          sep='\t')

if copy_mode == 'sample':
    data2_value['sample_matched'] = data2_value['sample']
elif copy_mode == 'table':
    table = pd.read_csv(("%s2screenSampleTable.txt" % save_source),
                        na_values=['.'],
                        sep='\t')
    data2_value = dat.copy_based_on_index(data2_value, table, 'sample',
                                          'screen2', ['sample_matched'],
                                          ['screen1'])

data_value = data1_value.copy()
data_value = dat.copy_based_on_index(
    data_value, data2_value, 'sample', 'sample_matched', [
        'mob1', 'curve_mob1', 't_half1', 'curve_t_half1', 'slope1',
        'curve_slope1', 'size_organelle1', 'raw_int_organelle1',
        'circ_organelle1', 'ecce_organelle1'
    ], [
        'mob', 'curve_mob', 't_half', 'curve_t_half', 'slope', 'curve_slope',
        'size_organelle', 'raw_int_organelle', 'circ_organelle',
        'ecce_organelle'
    ])
data_value = data_value.dropna()
Example #4
0
    # 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)))

# ----------------------------------
# BLEACH SPOTS DETECTION
# ----------------------------------