Exemplo n.º 1
0
from timagetk.plugins.registration import z_stack_registration, apply_z_stack_trsf
# root_dir = '/projects/SamMaps/SuperResolution/LSM Airyscan/'
root_dir = '/data/Meristems/Carlos/SuperResolution/'

base_fname = 'SAM1-gfp-pi-stack-LSM800-Airyscan Processing-standard_{}.tif'
ref_channel = 'PI_SR'
float_channels = ['PIN_SR', 'PI_conf', 'PIN_conf']
image = imread(root_dir + base_fname.format(ref_channel))

reg_method = 'rigid'
reg_stack, z_stack_trsf = z_stack_registration(image, method=reg_method, get_trsf=True)

# - Have a look at the z-stack registration results on PI channel:
from timagetk.visu.mplt import grayscale_imshow
mid_y = int(image.get_y_dim()/2.)
grayscale_imshow([image.get_y_slice(mid_y), reg_stack.get_y_slice(mid_y)], title="Z-stack {} registration - y-slice {}/{}".format(reg_method, mid_y, image.get_y_dim()), subplot_titles=['Original', 'Registered'], range=[0, 10000])

grayscale_imshow([image, reg_stack], title="Z-stack {} registration - Contour projection".format(reg_method), subplot_titles=['Original', 'Registered'], range=[0, 10000])

from timagetk.visu.mplt import stack_browser
stack_browser(reg_stack, title="{} registered z-stack".format(reg_method))

from timagetk.visu.mplt import stack_browser_RGBA
stack_browser_RGBA([image, reg_stack], channel_names=['Original', 'Registered'], colors=['red', 'green'], title="Z-stack {} registration".format(reg_method))

imsave(root_dir + base_fname.format(ref_channel+"_z-stack_reg"), reg_stack)

# - Apply this registration to the other channels:
for float_channel in float_channels:
    image = imread(root_dir + base_fname.format(float_channel))
    reg_image = apply_z_stack_trsf(image, z_stack_trsf)
Exemplo n.º 2
0
raw_img = imread("/data/GabriellaMosca/EM_C_140/EM_C_140- C=0.tif")
h_min = 2
sigma = 1.5

# raw_img = imread("/data/GabriellaMosca/EM_C_214/EM_C_214 C=0.tif")

print "\n - Performing z-slices adaptative histogram equalisation on the intensity image to segment..."
eq_img1 = z_slice_equalize_adapthist(raw_img)
print "\n - Performing z-slices histogram contrast stretching on the intensity image to segment..."
eq_img2 = z_slice_contrast_stretch(raw_img)

from timagetk.visu.mplt import grayscale_imshow
grayscale_imshow([
    raw_img.get_z_slice(85),
    eq_img1.get_z_slice(85),
    eq_img2.get_z_slice(85)
],
                 img_title=['Original', "AHE", 'CS'])

img2seg = eq_img2

print "\n - Automatic seed detection...".format(h_min)
print " -- Gaussian smoothing with std_dev={}...".format(sigma)
smooth_img = linear_filtering(img2seg,
                              sigma=sigma,
                              method='gaussian_smoothing')
grayscale_imshow([
    raw_img.get_z_slice(85),
    eq_img2.get_z_slice(85),
    smooth_img.get_z_slice(85)
],
Exemplo n.º 3
0
# iso_image = z_slice_contrast_stretch(iso_image, pc_min=1.5)
smooth_image = linear_filtering(iso_image,
                                method="gaussian_smoothing",
                                sigma=1.,
                                real=True)

asf_image = morphology(iso_image,
                       method="oc_alternate_sequential_filter",
                       max_radius=1)

xsh, ysh, zsh = iso_image.shape
mid_x, mid_y, mid_z = int(xsh / 2.), int(ysh / 2.), int(zsh / 2.)

from timagetk.visu.mplt import grayscale_imshow
from timagetk.visu.stack import stack_browser
grayscale_imshow([iso_image, smooth_image, asf_image], slice_id=mid_z)

stack_browser(asf_image)

selected_hmin = profile_hmin(smooth_image,
                             x=mid_x,
                             z=mid_z,
                             plane='x',
                             zone=mid_z)
selected_hmin = profile_hmin(asf_image,
                             x=mid_x,
                             z=mid_z,
                             plane='x',
                             zone=mid_z)

from timagetk.plugins import h_transform
Exemplo n.º 4
0
init_trsf = BalTrsf()
init_trsf.read('/data/GabriellaMosca/T140_214.trsf')

trsf_def, img_def = registration(float_img,
                                 ref_img,
                                 method='deformable',
                                 init_trsf=init_trsf)
imsave("/data/GabriellaMosca/EM_C_214/EM_C_214-masked_deformable.tif", img_def)

from timagetk.visu.mplt import grayscale_imshow
img2plot = [float_img, ref_img, img_rig, ref_img]
img_titles = ["t0", "t1", "Registered t0 on t1", "t1"]
grayscale_imshow(img2plot,
                 "Effect of rigid registration",
                 img_titles,
                 vmin=0,
                 vmax=255,
                 max_per_line=2)

img2plot = [
    float_img.get_z_slice(40),
    ref_img.get_z_slice(40),
    img_rig.get_z_slice(40),
    ref_img.get_z_slice(40)
]
img_titles = ["t0", "t1", "Registered t0 on t1", "t1"]
grayscale_imshow(img2plot,
                 "Effect of rigid registration",
                 img_titles,
                 vmin=0,
                 vmax=255,
Exemplo n.º 5
0
control = 'most'

base_fname, ext = splitext(fname)
image = imread(base_dir + fname)
image.voxelsize

iso_image = isometric_resampling(image, method='min', option='cspline')
iso_image.shape

st_img1 = global_contrast_stretch(iso_image)
st_img2 = z_slice_equalize_adapthist(iso_image)

from timagetk.visu.mplt import grayscale_imshow
grayscale_imshow([iso_image, st_img1, st_img2],
                 100,
                 title=[
                     "Original", "global_contrast_stretch",
                     "z_slice_equalize_adapthist"
                 ])

seed_detect_img = morphology(st_img2, "erosion", radius=1)

seed_detect_img = morphology(seed_detect_img,
                             "coc_alternate_sequential_filter",
                             max_radius=1,
                             iterations=2)
seed_detect_img = linear_filtering(seed_detect_img,
                                   method="gaussian_smoothing",
                                   sigma=1.,
                                   real=True)

xsh, ysh, zsh = iso_image.shape
Exemplo n.º 6
0
    '20190430_multiangle_45.tif', '20190430_multiangle_90.tif',
    '20190430_multiangle_135.tif', '20190430_multiangle_180.tif',
    '20190430_multiangle_-45.tif', '20190430_multiangle_-90.tif',
    '20190430_multiangle_-135.tif'
]

proj_list = []
for fname in filenames:
    img = imread(root_dir + "/" + fname)
    print "{}: shape={}, voxelsize={}".format(img.filename, img.shape,
                                              img.voxelsize)
    proj_list.append(projection(img, method='contour'))

grayscale_imshow(proj_list,
                 range='auto',
                 title='20190430_M_lti6b-gfp',
                 subplot_titles=filenames,
                 figname=root_dir + "/" + "contour_projections.png")

# filenames = ['20190430_multiangle_top.tif', '20190430_multiangle_45.tif']
# list_img = [imread(root_dir+"/"+im) for im in filenames]

# res_trsf, res_imgs = fusion_on_first(list_img, registration_method='rigid')

# from timagetk.plugins.cropping import max_percentile_profiles
# max_percentile_profiles(top_im, n_jobs=1)
#
#
# from timagetk.plugins.cropping import threshold_max_percentile_widget
# crop = threshold_max_percentile_widget(top_im, n_jobs=1)
#
Exemplo n.º 7
0
xs, ys = int(sh[0] / 2.), int(sh[1] / 3.)

img_list = [im, stretch, smooth, smooth_str, str_smooth]
img_title = [
    'Original', "Stretched", "Gaussian_smoothing", "Smooth + Stretching",
    "Stretching + Smooth"
]
image_n_hist([img.get_array()[xs, ys:ys * 2, :] for img in img_list],
             title="x_slice{}".format(xs),
             img_title=img_title,
             aspect_ratio=im.extent[0] / im.extent[1])

img_list = [im, eq, smooth, smooth_eq, eq_smooth]
img_title = [
    'Original', "Equalize", "Gaussian_smoothing", "Smooth + Equalize",
    "Equalize + Smooth"
]
image_n_hist([img.get_array()[xs, ys:ys * 2, :] for img in img_list],
             title="x_slice{}".format(xs),
             img_title=img_title,
             aspect_ratio=im.extent[0] / im.extent[1])

image_n_hist(smooth_str.get_array()[xs, :, :],
             figname=join(base_dir, "smooth-str-x_slice{}.png".format(xs)))
image_n_hist(str_smooth.get_array()[xs, :, :],
             figname=join(base_dir, "str-smooth-x_slice{}.png".format(xs)))

from timagetk.visu.mplt import grayscale_imshow

grayscale_imshow([im, iso_im, st_im])