Skip to content

Commit

Permalink
Allow examples/neurons.py to run successfully when neuromorpho is down (
Browse files Browse the repository at this point in the history
#366)

* Added try-except in examples/neurons.py to prevent test failure when neuromorpho is down

* Fix for screenshot test

* Reverted reset_cam dynamic setting, add new screenshots to data folder

* Added silhouette to the TH in validation screenshots

* Generate screenshots with the same settings as the ones set by tests/__init__.py

* Generate screenshots using the test method

* Reset settings at the end of examples/settings.py script
  • Loading branch information
IgorTatarnikov committed Jun 7, 2024
1 parent cfebff2 commit f1e3785
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
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.

0 comments on commit f1e3785

Please sign in to comment.