Esempio n. 1
0
def add_channel_regitration(czi_base_fname,
                            nomenclature_file,
                            ch_name,
                            trsf_type,
                            temp_reg,
                            image_dirname,
                            colormap='invert_grey'):
    """
    Add the registered image to tissuelab world.
    """
    for n, (t_ref, t_float) in enumerate(temp_reg):
        # -- Get the reference CZI file names:
        ref_czi_fname = czi_base_fname.format(t_ref)
        # -- Get the reference INR file names:
        ref_path_suffix, ref_img_fname = get_nomenclature_channel_fname(
            ref_czi_fname, nomenclature_file, ch_name)

        if n == 0:
            print "Reading last time-point (t{}) image filename: {}".format(
                t_ref, ref_img_fname)
            ref_im = imread(image_dirname + ref_path_suffix + ref_img_fname)
            if ch_name.find('raw') != -1:
                ref_im = z_slice_equalize_adapthist(ref_im)
            world.add(ref_im, ref_img_fname, colormap='Reds')

        # -- Get the float CZI file names:
        float_czi_fname = czi_base_fname.format(t_float)
        # -- Get the float INR file names:
        float_path_suffix, float_img_fname = get_nomenclature_channel_fname(
            float_czi_fname, nomenclature_file, ch_name)
        # --- Get RESULT rigid transformation image filename:
        res_path_suffix = float_path_suffix + trsf_type + "_registrations/"
        res_img_fname = get_res_img_fname(float_img_fname, t_ref, t_float,
                                          trsf_type)

        # -- Read RESULT image file:
        res_im = imread(image_dirname + res_path_suffix + res_img_fname)
        print "Reading result floating (t{}) image filename: {}".format(
            t_float, res_img_fname)
        world.add(res_im, res_img_fname, colormap='Greens')
    return "Done."
Esempio n. 2
0
                                                  std_dev=1.0,
                                                  method='gaussian_smoothing')
                        # -- Remove the NUCLEI signal from the MEMBRANE signal image:
                        print " --> Substracting NUCLEI signal from the MEMBRANE signal image..."
                        zero_mask = np.greater(nuc_im.get_array(),
                                               img.get_array())
                        img = img - nuc_im
                        img[zero_mask] = 0
                        # world.add(nuc_im, 'nuc_im', colormap='invert_grey')
                        # world.add(img, 'img'+suffix, colormap='invert_grey')
                        print "Done!"
                        del nuc_im, zero_mask
                    # -- Performs intensity rescaling for membrane image:
                    if rescaling == 'AdaptHistEq':
                        print " --> Adaptative Histogram Equalization..."
                        img = z_slice_equalize_adapthist(img)
                    if rescaling == 'ContrastStretch':
                        print " --> Contrast Stretching..."
                        img = z_slice_contrast_stretch(img)
                    if std_dev != 0:
                        print " --> 'gaussian_smoothing' with std_dev={}...".format(
                            std_dev)
                        img = linear_filtering(img,
                                               'gaussian_smoothing',
                                               std_dev=std_dev)

                    # - Performs seed detection:
                    print " --> Closing-Opening Alternate Sequencial Filter..."
                    asf_img = morphology(
                        img,
                        max_radius=morpho_radius,
Esempio n. 3
0
fname = '/qDII-CLV3-PIN1-PI-E35-LD-SAM4-T0_CH2_iso.inr'
img = imread(dirname + fname)
x_sh, y_sh, z_sh = img.shape

z_slice = 107
# Display slice and histograms:
slice_n_hist(img[:,:,z_slice], 'Original image', 'z-slice {}/{}'.format(z_slice, z_sh))

# Display orthogonal view of ORIGINAL image:
slice_view(img, x_sh/2, y_sh/2, z_sh/2, 'original_image', dirname + fname[:-4] + ".png")


# Display and save orthogonal view of EQUALIZE ADAPTHIST image for various clip_limit:

for clip_limit in [0.005,0.007,0.01,0.02,0.05,0.1]:
    im_eq = z_slice_equalize_adapthist(img,clip_limit=float(clip_limit))
    x_sh, y_sh, z_sh = im_eq.shape
    title = "Equalize adapthist (z-slice): clip limit = {}".format(clip_limit)
    filename = fname[:-4]+"_z_equalize_adapthist-clip_limit_{}.png".format(clip_limit)
    slice_view(im_eq, x_sh/2, y_sh/2, z_sh/2, title, dirname + filename)

# Display and save orthogonal view of EQUALIZE ADAPTHIST image for nbins=2**16:
n_bins=2**16
clip_limit=0.005
im_eq = z_slice_equalize_adapthist(img,clip_limit=clip_limit,n_bins=n_bins)
x_sh, y_sh, z_sh = im_eq.shape
title = "Equalize adapthist (z-slice):clip limit = {}".format(clip_limit)
filename = fname[:-4]+"_z_equalize_adapthist_clip_limit_{}.png".format(clip_limit)
slice_view(im_eq, x_sh/2, y_sh/2, z_sh/2, title, dirname + filename)

slice_n_hist(im_eq[:,:,z_slice], "Equalize adapthist (z-slice):clip limit = {}.format(clip_limit), 'z-slice {}/{}'.format(z_slice, z_sh))
Esempio n. 4
0
    if clearing_ch_name:
        path_suffix, substract_img_fname = get_nomenclature_channel_fname(raw_czi_fname, nom_file, clearing_ch_name)
        print "\n - Loading image to substract: {}".format(substract_img_fname)
        substract_img = imread(image_dirname + path_suffix + substract_img_fname)
        # substract the 'CLV3' signal from the 'PI' since it might have leaked:
        print "\n - Performing images substraction..."
        tmp_im = img2seg - substract_img
        tmp_im[img2seg <= substract_img] = 0
        img2seg = SpatialImage(tmp_im, voxelsize=vxs, origin=ori)
        del tmp_im
    # -- Display the image to segment:
    # world.add(img2seg,'{}_channel'.format(ref_ch_name), colormap='invert_grey', voxelsize=microscope_orientation*vxs)
    # world['{}_channel'.format(ref_ch_name)]['intensity_range'] = (-1, 2**16)
    # -- Adaptative histogram equalization of the image to segment:
    print "\n - Performing adaptative histogram equalization of the image to segment..."
    img2seg = z_slice_equalize_adapthist(img2seg)
    # -- Performs isometric resampling of the image to segment:
    print "\n - Performing isometric resampling of the image to segment..."
    img2seg = isometric_resampling(img2seg)
    iso_vxs = np.array(img2seg.voxelsize)
    iso_shape = img2seg.shape
    # -- Display the isometric version of the "equalized" image to segment:
    # world.add(img2seg,'{}_channel_equalized_isometric'.format(ref_ch_name), colormap='invert_grey', voxelsize=microscope_orientation*iso_vxs)
    # world['{}_channel_equalized_isometric'.format(ref_ch_name)]['intensity_range'] = (-1, 2**16)

    # - Create a seed image from the list of NUCLEI barycenters:
    print "\n - Creating a seed image from the list of NUCLEI barycenters..."
    # -- Read CSV file containing barycenter positions:
    nom_names = get_nomenclature_name(nom_file)
    signal_file = image_dirname + nom_names[raw_czi_fname] + '/' + nom_names[raw_czi_fname] + "_signal_data.csv"
    signal_data = pd.read_csv(signal_file, sep=',')