How to use vedo - 10 common examples

To help you get started, we’ve selected a few vedo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github BrancoLab / BrainRender / tests / test_mouse.py View on Github external
if (
        not isinstance(data, np.ndarray)
        or not isinstance(data2, np.ndarray)
        or not isinstance(data3, np.ndarray)
    ):
        raise ValueError
    if not np.array_equal(data, data3):
        raise ValueError

    gene_actor = geapi.griddata_to_volume(
        data, min_quantile=90, cmap="inferno"
    )
    gene_actor2 = geapi.griddata_to_volume(data2, min_value=0.2)

    if not isinstance(gene_actor, Mesh) or not isinstance(gene_actor2, Mesh):
        raise ValueError
github BrancoLab / BrainRender / tests / test_scene.py View on Github external
def test_scene_creation_notebook():
    settings.notebookBackend = "k3d"
    Scene()
    settings.notebookBackend = None
github BrancoLab / BrainRender / tests / test_scene.py View on Github external
def test_scene_creation_notebook():
    settings.notebookBackend = "k3d"
    Scene()
    settings.notebookBackend = None
github BrancoLab / BrainRender / tests / test_scene.py View on Github external
# Text to add
    s = "BRAINRENDER"

    # Specify a color for each letter
    colors = makePalette(len(s), "salmon", "powderblue")

    x = 0  # use to specify the position of each letter
    # Add letters one at the time to color them individually
    for n, letter in enumerate("BRAINRENDER"):
        if "I" == letter or "N" == letter and n < 5:  # make the spacing right
            x += 0.6
        else:
            x += 1

        # Add letter and silhouette to the scne
        act = Text(
            letter, depth=0.5, c=colors[n], pos=(x, 0, 0), justify="centered"
        )
        sil = act.silhouette().lw(3).color("k")
        scene.add_actor(act, sil)

    scene.render(interactive=False)
    scene.close()
github BrancoLab / BrainRender / brainrender / atlases / custom_atlases / insects_brains_db.py View on Github external
def download_and_write_mesh(self, acronym, obj_path):
        print(f"Downloading mesh data for {acronym}")
        path = self.structures.loc[
            self.structures.acronym == acronym
        ].obj_path.values[0]
        url = f"{self._url_paths['data']}/{path}"

        # download and write .obj
        mesh_data = request(url).content.decode("utf-8").split("\n")
        with open(obj_path, "w") as f:
            for md in mesh_data:
                f.write(f"{md}\n")
            f.close()

        # return the vtk actor
        return load(obj_path)
github BrancoLab / BrainRender / brainrender / atlases / celegans.py View on Github external
"Create root method not supported yet, sorry"
        )

        print(f"Creating root mesh for atlas {self.atlas_name}")
        temp_scene = Scene(
            atlas=Celegans,
            add_root=False,
            display_inset=False,
            atlas_kwargs=dict(data_folder=self.data_folder),
        )

        temp_scene.add_neurons(self.neurons_names)
        temp_scene.render(interactive=False)
        temp_scene.close()

        root = merge(*temp_scene.actors["neurons"]).clean().cap()
        # root = mesh2Volume(root, spacing=(0.02, 0.02, 0.02)).isosurface()

        points = Points(root.points()).smoothMLS2D(f=0.8).clean(tol=0.005)

        root = recoSurface(points, dims=100, radius=0.2)

        # Save
        write(root, rootpath)

        del temp_scene
        return root
github BrancoLab / BrainRender / brainrender / atlases / custom_atlases / insects_brains_db.py View on Github external
def make_root_mesh(self):
        if self.structures is None:
            return

        obj_path = os.path.join(self.meshes_folder, "root.vtk")
        if os.path.isfile(obj_path):
            return

        # Get the mesh for each brain region to create root
        meshes = [
            self._get_structure_mesh(reg) for reg in self.region_acronyms
        ]
        root = merge(meshes)
        write(root, obj_path)
github BrancoLab / BrainRender / brainrender / atlases / mouse.py View on Github external
# Deal with neuron as dictionary of actor
            elif isinstance(neuron, dict):
                neuron_actors["soma"] = neuron.pop("soma", None)
                neuron_actors["axon"] = neuron.pop("axon", None)

                # Get dendrites actors
                if (
                    "apical_dendrites" in neuron.keys()
                    or "basal_dendrites" in neuron.keys()
                ):
                    if "apical_dendrites" not in neuron.keys():
                        neuron_actors["dendrites"] = neuron["basal_dendrites"]
                    elif "basal_dendrites" not in neuron.keys():
                        neuron_actors["dendrites"] = neuron["apical_dendrites"]
                    else:
                        neuron_actors["dendrites"] = merge(
                            neuron["apical_dendrites"],
                            neuron["basal_dendrites"],
                        )
                else:
                    neuron_actors["dendrites"] = neuron.pop("dendrites", None)

            # Deal with neuron as instance of Neuron from morphapi
            elif isinstance(neuron, Neuron):
                neuron_actors, _ = get_neuron_actors_with_morphapi(
                    neuron=neuron,
                    neurite_radius=neurite_radius,
                    use_cache=use_cache,
                )
            # Deal with other inputs
            else:
                raise ValueError(
github BrancoLab / BrainRender / brainrender / morphology / utils.py View on Github external
soma_radius = SOMA_RADIUS

    actors = neuron.create_mesh(
        neurite_radius=neurite_radius,
        use_cache=use_cache,
        soma_radius=soma_radius,
    )
    if actors is None:
        raise ValueError(f"Failed to get neuron actors. {swcfile} - {neuron}")
    else:
        neurites, whole_neuron = actors

    actors = dict(
        soma=neurites["soma"],
        axon=neurites["axon"],
        dendrites=merge(
            neurites["basal_dendrites"], neurites["apical_dendrites"]
        ),
    )

    return actors, whole_neuron
github BrancoLab / BrainRender / brainrender / atlases / aba.py View on Github external
# Deal with neuron as dictionary of actor
            elif isinstance(neuron, dict):
                neuron_actors["soma"] = neuron.pop("soma", None)
                neuron_actors["axon"] = neuron.pop("axon", None)

                # Get dendrites actors
                if (
                    "apical_dendrites" in neuron.keys()
                    or "basal_dendrites" in neuron.keys()
                ):
                    if "apical_dendrites" not in neuron.keys():
                        neuron_actors["dendrites"] = neuron["basal_dendrites"]
                    elif "basal_dendrites" not in neuron.keys():
                        neuron_actors["dendrites"] = neuron["apical_dendrites"]
                    else:
                        neuron_actors["dendrites"] = merge(
                            neuron["apical_dendrites"],
                            neuron["basal_dendrites"],
                        )
                else:
                    neuron_actors["dendrites"] = neuron.pop("dendrites", None)

            # Deal with neuron as instance of Neuron from morphapi
            elif isinstance(neuron, Neuron):
                neuron_actors, _ = get_neuron_actors_with_morphapi(
                    neuron=neuron,
                    neurite_radius=neurite_radius,
                    use_cache=use_cache,
                )
            # Deal with other inputs
            else:
                raise ValueError(

vedo

A python module for scientific analysis and visualization of 3D objects and point clouds based on VTK and Numpy.

MIT
Latest version published 6 months ago

Package Health Score

71 / 100
Full package analysis

Similar packages