-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
400 additions
and
502 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This open source software code was developed in part or in whole in the Human Brain Project, | ||
funded from the European Union’s Horizon 2020 Framework Programme for Research and Innovation | ||
under the Specific Grant Agreement No. 785907 (Human Brain Project SGA2). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import sciunit | ||
|
||
class ProducesWaveFronts(sciunit.Capability): | ||
""" | ||
Wave fronts can either be the transitions from down to up states in the | ||
case of 'Slow Waves', or the peak of a wave cylce (phase = pi/2) in the | ||
case of oscillatory waves. | ||
The wavefronts are to be represented as a list of neo.SpikeTrain objects. | ||
Each SpikeTrain has to have the following annotations: | ||
"coordinates" : tuple, (x, y) | ||
"grid_size" : tuple, (dim_x, dim_y) | ||
"electrode_distance": Quantity, d * quantities.mm | ||
""" | ||
def produce_wavefronts(self, **kwargs): | ||
self.unimplemented() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import sciunit.models.backends as su_backends | ||
import inspect | ||
|
||
try: | ||
from .storage import storage | ||
except ImportError: | ||
storage_backend = None | ||
print('Could not load storage backend') | ||
|
||
available_backends = {x.replace('Backend', ''): cls for x, cls | ||
in locals().items() | ||
if inspect.isclass(cls) and | ||
issubclass(cls, su_backends.Backend)} | ||
su_backends.register_backends(locals()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
from sciunit.models.backends import Backend | ||
import os | ||
|
||
class storage(Backend): | ||
name = 'storage' | ||
|
||
def init_backend(self, *args, **kwargs): | ||
"""Initialize the backend.""" | ||
self.model.attrs = {} | ||
|
||
self.use_memory_cache = kwargs.get('use_memory_cache', True) | ||
if self.use_memory_cache: | ||
self.init_memory_cache() | ||
self.use_disk_cache = kwargs.get('use_disk_cache', False) | ||
if self.use_disk_cache: | ||
self.init_disk_cache() | ||
self.load_model() | ||
self.model.unpicklable += ['_backend'] | ||
|
||
def _backend_run(self): | ||
if not os.path.exists(self.model.file_path): | ||
raise NotImplementedError('The model class must specify a \ | ||
file_path from which the simulation results can be loaded.') | ||
return self.model.load() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import sciunit | ||
from .backends import available_backends | ||
|
||
class loaded_data(sciunit.Model): | ||
""" | ||
Abstract model class which initializes self.params. | ||
Child classes need to define a load() function and a file_path. | ||
""" | ||
@property | ||
def file_path(self): | ||
raise NotImplementedError | ||
|
||
def __init__(self, name=None, backend='storage', **params): | ||
""" | ||
Parameters | ||
---------- | ||
name : string | ||
Name of model instance | ||
**params : | ||
class attributes to be stored in self.params | ||
""" | ||
if params is None: | ||
params = {} | ||
if hasattr(self, 'params'): | ||
self.params.update(params) | ||
else: | ||
self.params = params | ||
super(loaded_data, self).__init__(name=name, **self.params) | ||
if backend is not None: | ||
self.set_backend(backend) | ||
|
||
def load(self, file_path=None, **kwargs): | ||
""" | ||
To be called in the produce_xy() function, | ||
associated with the capability class ProducesXY. | ||
""" | ||
raise NotImplementedError | ||
|
||
def get_backend(self): | ||
"""Return the simulation backend.""" | ||
return self._backend | ||
|
||
def set_backend(self, backend): | ||
"""Set the simulation backend.""" | ||
if isinstance(backend, str): | ||
name = backend | ||
args = [] | ||
kwargs = {} | ||
elif isinstance(backend, (tuple, list)): | ||
name = '' | ||
args = [] | ||
kwargs = {} | ||
for i in range(len(backend)): | ||
if i == 0: | ||
name = backend[i] | ||
else: | ||
if isinstance(backend[i], dict): | ||
kwargs.update(backend[i]) | ||
else: | ||
args += backend[i] | ||
else: | ||
raise TypeError("Backend must be string, tuple, or list") | ||
if name in available_backends: | ||
self.backend = name | ||
self._backend = available_backends[name]() | ||
elif name is None: | ||
# The base class should not be called. | ||
raise Exception(("A backend (e.g. 'jNeuroML' or 'NEURON') " | ||
"must be selected")) | ||
else: | ||
raise Exception("Backend %s not found in backends.py" | ||
% name) | ||
self._backend.model = self | ||
self._backend.init_backend(*args, **kwargs) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.