コード例 #1
0
ファイル: ABM_mIF.py プロジェクト: fred22036/SPQSP_IO_PUBLIC
def draw_y_slice(y_slice):
    dy = np.abs(coords[:, 1] - y_slice)
    in_y_slice = dy < 0.5
    # paint white background
    image.paste((0, 0, 0), [0, 0, image.size[0], image.size[1]])
    # row number for cell in slice
    idx = np.array([i for i, test in enumerate(in_y_slice) if test])
    if len(idx) > 0:
        # 6 fields: [x, y, radius, r, g, b]
        cells = np.zeros((len(idx), 6))
        # convert coordinates to pixels
        coords_pixel_slice = coords[idx, :] * ppv
        # y slices coordinates should be in the order of (z, x)
        cells[:, [0, 1]] = coords_pixel_slice[:, [2, 0]]
        stain_value = np.array([cell_to_stain_id(c) for c in celldata[idx]])
        # radius to pixel
        cells[:, 2] = np.array([r_map[s] for s in stain_value]) * ppm
        c_color = np.array([c_map[s] for s in stain_value])
        cells[:, 3:] = c_color
        # cell: list of cells to draw. [x, y, radius, r, g, b]
        srt_idx = np.argsort(
            stain_value
        )  # sort high priority to the end so that their color on top
        bu.draw_IHC(draw, cells[srt_idx, :])
    rgb = np.array(image)
    rgba = np.pad(
        rgb,
        ((0, 0), (0, 0), (0, 1)), mode='constant', constant_values=255) / 255
    img = be.createImage('ihc', rgba)
    return img
コード例 #2
0
def visualSlice(scene):
    f = scene.frame_current
    f0 = scene.frame_start
    f1 = scene.frame_end
    y_min = 0
    y_max = 39
    y_slice = np.interp(f, [f0, f1], [y_min, y_max])
    values_xz = bu.get_interpolation_from_3D(fn, 1, [0, y_slice, 0],
                                             [39, y_slice, 39], [100, 1, 100])
    values_zx = np.transpose(values_xz)
    rgba = be.mapToColor(values_zx,
                         colormap,
                         xmin=smin,
                         xmax=smax,
                         log=False,
                         maptype='RGBA')
    img = be.createImage('y{}'.format(f), rgba)
    loc = bu.get_interp_loc_from_slice(y_slice, 40, [0, 4])
    vol.update_plane(s1, img, 1, loc)
    wm.set_text('y = {:.2f}'.format(y_slice))
コード例 #3
0
def visualSlice(s1):
    f = sce.frame_current
    f0 = sce.frame_start
    f1 = sce.frame_end
    y_min = 0
    y_max = 39
    y_slice = np.interp(f, [f0, f1], [y_min, y_max])
    values_xz = bu.get_interpolation_from_3D(fn, 1, [0,y_slice,0], 
                                    [39,y_slice,39],[100,1,100])
    values_zx = np.transpose(values_xz)
    rgba = be.mapToColor(values_zx, color_trans, xmin=smin, xmax= smax,log=False, maptype='RGBA')
    img = be.createImage('y{}'.format(f), rgba)
    loc = bu.get_interp_loc_from_slice(y_slice, 40, [0,4])
    new_slide = (f-1)%(f1//(3)) == 0
    #print(loc, f, new_slide)
    if new_slide:
        s1 = vol.add_slice('y', 1, loc,transparent=True, img = img)
    else:
        vol.update_plane(s1, img, 1, loc)
    #vol.update_plane(s1, img, 1, loc)
    wm.set_text('y = {:.2f}'.format(y_slice))
    return s1
コード例 #4
0
init_bin = [.2, 0, .2]
init_cross = [bu.get_interp_loc_from_slice(b, 40, [0,4]) for b in init_bin]

vol = bc.box_slice('vol', sce, objectSize, (1,.3,0,1))
s0 = vol.add_slice('x', 0, init_cross[0])
s1 = vol.add_slice('y', 1, init_cross[1])
s2 = vol.add_slice('z', 2, init_cross[2])
vol.set_divider(init_cross, radius = .02, color = (1,1,1,1))

x_cut = np.interp(init_cross[0], [0,objectSize[0]] , [0, 39])
values_yz = bu.get_interpolation_from_3D(fn, 0, [x_cut,0,0], 
                                    [x_cut,39,39],[1,100,100])
rgba = be.mapToColor(values_yz, colormap, xmin=smin, xmax= smax,
            log=False, maptype='RGBA')
img = be.createImage('x_img', rgba)
vol.update_plane(s0, img, 0, init_cross[0])

z_cut = np.interp(init_cross[2], [0,objectSize[2]] , [0, 39])
values_xy = bu.get_interpolation_from_3D(fn, 2, [0,0,z_cut], 
                                    [39,39,z_cut],[100,100,1])
rgba = be.mapToColor(values_xy, colormap, xmin=smin, xmax= smax,
            log=False, maptype='RGBA')
img = be.createImage('z_img', rgba)
vol.update_plane(s2, img, 2, init_cross[2])

y_cut = np.interp(init_cross[1], [0,objectSize[1]] , [0, 39])
values_xz = bu.get_interpolation_from_3D(fn, 1, [0, y_cut, 0], 
                                    [39,y_cut,39],[100,1,100])
rgba = be.mapToColor(np.transpose(values_xz), colormap, xmin=smin, xmax= smax,
            log=False, maptype='RGBA')