Skip to content

Commit

Permalink
All resources used for examples and for testing are now in brainrende…
Browse files Browse the repository at this point in the history
…r/resources, importlib.resources now used to fetch data
  • Loading branch information
IgorTatarnikov committed Nov 28, 2023
1 parent 1c1f524 commit b3fa6eb
Show file tree
Hide file tree
Showing 16 changed files with 48 additions and 167,159 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 5 additions & 1 deletion examples/add_mesh_from_file.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from pathlib import Path
from importlib.resources import files

from myterial import orange
from rich import print
Expand All @@ -14,7 +15,10 @@
scene.add_brain_region("SCm", alpha=0.2)

# Add from file
scene.add("data/CC_134_1_ch1inj.obj", color="tomato")
scene.add(
files("brainrender").joinpath("resources/CC_134_1_ch1inj.obj"),
color="tomato",
)

# Render!
scene.render()
3 changes: 2 additions & 1 deletion examples/neurons.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from pathlib import Path
from importlib.resources import files

from morphapi.api.mouselight import MouseLightAPI
from myterial import orange
Expand All @@ -13,7 +14,7 @@
scene = Scene(title="neurons")

# Add a neuron from file
scene.add(Neuron("data/neuron1.swc"))
scene.add(Neuron(files("brainrender").joinpath("resources/neuron1.swc")))

# Download neurons data with morphapi
mlapi = MouseLightAPI()
Expand Down
10 changes: 5 additions & 5 deletions examples/volumetric_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@
from brainrender import Scene, settings
from brainrender.actors import Volume

settings.SHOW_AXES = False


from pathlib import Path
from importlib.resources import files

from myterial import orange
from rich import print

settings.SHOW_AXES = False

print(f"[{orange}]Running example: {Path(__file__).name}")

scene = Scene(inset=False)

data = np.load("data/volume.npy")
data = np.load(files("brainrender").joinpath("resources/volume.npy"))
print(data.shape)

# make a volume actor and add
actor = Volume(
"data/volume.npy",
data,
voxel_size=200, # size of a voxel's edge in microns
as_surface=False, # if true a surface mesh is rendered instead of a volume
c="Reds", # use matplotlib colormaps to color the volume
Expand Down
Loading

0 comments on commit b3fa6eb

Please sign in to comment.