Esempio n. 1
0
def analyse_track(
    scene,
    points_file,
    add_surface_to_points=True,
    spline_points=100,
    fit_degree=3,
    spline_smoothing=0.05,
    point_radius=30,
    spline_radius=10,
    verbose=True,
):
    """
    Given a file of points, fit a spline function, and add to a brainrender
     scene.
    :param scene: brainrender scene object
    :param points_file:
    :param bool add_surface_to_points: Add the closest part of the brain
    surface to the list of points
    :param spline_points: How many points define the spline
    :param fit_degree: spline fit degree
    :param spline_smoothing: spline fit smoothing
    :param point_radius: size of the points in the brainrender scene
    :param spline_radius: size of the rendered spline in the brainrender
    scene
    :param bool verbose: Whether to print the progress
    :return:
        scene: brainrender scene with the surface point added.
        spline: vedo spline object
    """
    points = pd.read_hdf(points_file)
    scene.add_cells(
        points,
        color_by_region=True,
        res=12,
        radius=point_radius,
        verbose=False,
    )
    points = np.array(points)

    if add_surface_to_points:
        scene, points = add_surface_point_to_points(scene,
                                                    points,
                                                    point_radius,
                                                    verbose=verbose)

    far_point = np.expand_dims(points[-1], axis=0)
    scene.add_vtkactor(Spheres(far_point, r=point_radius).color("n"))

    spline = (Spline(
        points,
        smooth=spline_smoothing,
        degree=fit_degree,
        res=spline_points,
    ).pointSize(spline_radius).color("n"))

    return scene, spline
Esempio n. 2
0
"""Customizing axes style
(40+ control parameters!)
Title font: """
from vedo import Box, Lines, Points, Spline, show, settings

settings.defaultFont = 'Theemim'

# an invisible box:
world = Box(pos=(2.7, 0, 0), size=(12, 10, 8), alpha=0)

# a dummy spline with its shadow on the xy plane
pts = Points([(-2, -3.2, -1.5), (3, -1.2, -2), (7, 3, 4)], r=12)
spl = Spline(pts,
             res=50).addShadow(z=-4)  # make spline and add its shadow at z=-4
lns = Lines(spl, spl.shadow)  # join spline points with its own shadow

# make a dictionary of axes options
axes_opts = dict(
    xtitle=
    'My variable \Omega^\lowerxi_lm  in units of \mum^3',  # latex-style syntax
    ytitle='This is my highly\ncustomized y-axis',
    ztitle=
    'z in units of Å',  # many unicode chars are supported (type: vedo -r fonts)
    yValuesAndLabels=[(-3.2, 'Mark^a_-3.2'), (-1.2, 'Carmen^b_-1.2'),
                      (3, 'John^c_3')],
    textScale=1.3,  # make all text 30% bigger
    numberOfDivisions=5,  # approximate number of divisions on longest axis
    axesLineWidth=2,
    gridLineWidth=1,
    zxGrid2=True,  # show zx plane on opposite side of the bounding box
    yzGrid2=True,  # show yz plane on opposite side of the bounding box
Esempio n. 3
0
"""Mesh a line contour with quads of variable resolution"""
from vedo import Spline, Grid, show
import numpy as np

shape = Spline(
    [
        [0.0, 0.0],
        [1.0, 0.0],
        [1.1, 4.0],
        [1.0, 1.5],
        [0.2, 5.0],
        [-1., 3.0],
        [0.4, 2.7],
        [-1., 2.4],
    ],
    closed=True,
).color('red4').lineWidth(5)

xcoords = np.arange(-2.0, 2.5, 0.075)
ycoords = np.arange(-0.5, 5.5, 0.075)

xcoords += np.cos(xcoords + 0.6) * 0.75  # make quads shrink and stretch
ycoords += np.sin(ycoords + 0.5) * 0.75  # to refine mesh resolution

grd = Grid(sx=xcoords, sy=ycoords)  # create a gridded plane

msh = shape.tomesh(grid=grd, quads=True)

show(shape, msh, __doc__, axes=1)
Esempio n. 4
0
"""Customizing axes style
(40+ control parameters!)
Title font: """
from vedo import Box, Lines, Points, Spline, show, settings

settings.defaultFont = 'Theemim'

# an invisible box:
world = Box(pos=(2.7, 0, 0), size=(12, 10, 8), alpha=0)

# a dummy spline with its shadow on the xy plane
pts = Points([(-2, -3.2, -1.5), (3, -1.2, -2), (7, 3, 4)], r=12)
spl = Spline(pts, res=50).addShadow(
    plane='z', point=-4)  # make spline and add its shadow at z=-4
lns = Lines(spl, spl.shadow)  # join spline points with its own shadow

# make a dictionary of axes options
axes_opts = dict(
    xtitle=
    'My variable \Omega^\lowerxi_lm  in units of \mum^3',  # latex-style syntax
    ytitle='This is my highly\ncustomized y-axis',
    ztitle=
    'z in units of Å',  # many unicode chars are supported (type: vedo -r fonts)
    yValuesAndLabels=[(-3.2, 'Mark^a_-3.2'), (-1.2, 'Carmen^b_-1.2'),
                      (3, 'John^c_3')],
    textScale=1.3,  # make all text 30% bigger
    numberOfDivisions=5,  # approximate number of divisions on longest axis
    axesLineWidth=2,
    gridLineWidth=1,
    zxGrid2=True,  # show zx plane on opposite side of the bounding box
    yzGrid2=True,  # show yz plane on opposite side of the bounding box