Code Monkey home page Code Monkey logo

Comments (6)

russelljjarvis avatar russelljjarvis commented on July 29, 2024

As would facilitate using SpiNNaker to speed up optimization.

from neuronunit.

russelljjarvis avatar russelljjarvis commented on July 29, 2024

PyNN is not a self sufficient backend, it, itself uses BRIAN, NEST or NEURON as a backend.

However this is still a worthwhile pursuit as PyNN provides a very clean and minimal interface to NEURON.

Example of a pyNN NEURON backend as I envisage:

class pyNNNEURON(Backend):
    def init_backend(self, attrs=None):
        from pyNN.utility import get_simulator#, init_logging, normalized_filename                                                                                                                                                                                                         
        import pyNN
        self.sim = pyNN.neuron
        self.neurons = None
        self.model_path = None
        self.related_data = {}
        self.lookup = {}
        self.attrs = {}
    backend = 'pyNN'
    from numpy import arange
    self.sim.setup(timestep=0.01, min_delay=1.0)                                                                                                                                                                                                                    |
    self.neurons = sim.Population(1, sim.Izhikevich(a=0.02, b=0.2, c=-65, d=6, i_offset=[0.014, 0.0, 0.0]))

    def get_membrane_potential(self):
        data = self.neurons.get_data().segments[0]                                                                             
        v = data.filter(name="v")[0]

    def local_run(self):
        self.neurons.record(['v'])  # , 'u'])
        self.neurons.initialize(v=-70.0, u=-14.0)
        self.sim.run(100.0)

    def set_attrs(self, **attrs):
        self.model.attrs.update(attrs)
        assert type(self.model.attrs) is not type(None)
        self.neurons = sim.Population(1, sim.Izhikevich(a=attrs['a'], b=attrs['b'], c=attrs['c'], d=attrs['d'], i_offset=[0.014, 0.0, 0.0]))
        return self

    def inject_square_current(self, current):
        c = current['injected_square_current']
        stop = c['delay']+c['duration']
        amplitude = current[]
        electrode = self.sim.DCSource(start=c['delay'], stop=stop, amplitude=c['amplitude'])
        electrode.inject_into(self.neurons[1])

The main problem is that the backend is not model independent. Models are not implemented in PyNN code rather, models are declared and provided as parameter to the backend. For example in the above code:

sim.Izhikevich(a=attrs['a'], b=attrs['b'], c=attrs['c'], d=attrs['d'], i_offset=[0.014, 0.0, 0.0]))

from neuronunit.

rgerkin avatar rgerkin commented on July 29, 2024

@russelljjarvis
I think this is a good start. In some cases this may be the very easiest way to work with the models, since NEURON commands can be confusing and cryptic, and PyNN may abstract some of this away.

To deal with model independence, we will have to rely on the user providing a lot of the PyNN code themselves. For example, maybe we leave self.neurons empty and if a method tries to access it we raise an Exception that says "You have to set the neurons attribute to a valid PyNN object", so then the user is responsible for things like neurons = sim.Population(1, sim.Izhikevich(a=0.02, b=0.2, c=-65, d=6, i_offset=[0.014, 0.0, 0.0]))

Then in addition to this we can provide helper functions to make some of this easier, e.g. automatically setting a, b, c, etc. from the attrs dictionary.

Surely we cannot anticipate all the uses of PyNE, but if we have an example working with this model (like we have one working with jNeuroML with NEURON) then it will provide a roadmap for others to follow.

Let's leave this for after the 0.2 release.

from neuronunit.

russelljjarvis avatar russelljjarvis commented on July 29, 2024

AOK.

from neuronunit.

rgerkin avatar rgerkin commented on July 29, 2024

See also duplicate issue #168.

from neuronunit.

rgerkin avatar rgerkin commented on July 29, 2024

Closing as duplicate of more specific #168.

from neuronunit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.