Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow examples/neurons.py to run successfully when neuromorpho is down #366

Merged
merged 7 commits into from
Jun 7, 2024
21 changes: 12 additions & 9 deletions examples/neurons.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pathlib import Path
from importlib.resources import files

import requests.exceptions
from morphapi.api.mouselight import MouseLightAPI
from myterial import orange
from rich import print
Expand All @@ -19,14 +19,17 @@
scene.add(Neuron(neuron_file))

# Download neurons data with morphapi
mlapi = MouseLightAPI()
neurons_metadata = mlapi.fetch_neurons_metadata(
filterby="soma", filter_regions=["MOs"]
)

to_add = [neurons_metadata[47], neurons_metadata[51]]
neurons = mlapi.download_neurons(to_add)
neurons = scene.add(*make_neurons(*neurons, neurite_radius=12))
try:
mlapi = MouseLightAPI()
neurons_metadata = mlapi.fetch_neurons_metadata(
filterby="soma", filter_regions=["MOs"]
)

to_add = [neurons_metadata[47], neurons_metadata[51]]
neurons = mlapi.download_neurons(to_add)
neurons = scene.add(*make_neurons(*neurons, neurite_radius=12))
except ConnectionError or requests.exceptions.ReadTimeout as e:
print("Failed to download neurons data from neuromorpho.org.")

# Render!
scene.render()
3 changes: 3 additions & 0 deletions examples/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@
brainrender.settings.SHADER_STYLE = shader
scene = Scene(title=shader)
scene.render()

brainrender.settings.BACKGROUND_COLOR = "white" # reset background color
brainrender.settings.SHOW_AXES = True # reset axes display
Binary file modified tests/data/screenshot.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/data/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading