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

Synaptic connections #6

Open
mstimberg opened this issue Jul 29, 2016 · 0 comments
Open

Synaptic connections #6

mstimberg opened this issue Jul 29, 2016 · 0 comments

Comments

@mstimberg
Copy link
Member

As we discussed, the next big feature to implement are synaptic connections. To start, deal with explicit synapses given with synapses.connect(i=..., j=...). To do this, you'll have to implement LEMSDevice.synapses_connect which will be called instead of the original Synapses.connect function (it takes the same arguments as Synapses.connect, but note that it starts like this:

def synapses_connect(self, synapses, <arguments of Synapses.connect>)

i.e. you have "two self arguments", self corresponds to the LEMSDevice and synapses is the Synapses object.

When connecting synapses works in this way, the next step is to support synaptic connections defined by expressions/patterns (probabilistic connections, one-to-one connections, etc.). As discussed with Padraig, this is not something that we can do in the generated LEMS/NeuroML code, but instead Brian will generate the connections and then you'll include the generated connections in the XML file in the same way as if the user had called Synapses.connect(i=..., j=...) directly. IMO, the best way to implement it would be to have LEMSDevice.synapses_connect first call the original Synapses.connect with the given arguments and then pass the generated values for i and j to NeuroML. In the beginning, only support a single call to connect for each Synapses object (i.e. raise a NotImplementedError for a second call). Alternatively (actually that might be even easier and naturally supports multiple connect calls): do not overwrite Synapses.connect at all, simply check Synapses.i and Synapses.j for all Synapses objects in the network and create the corresponding synapses.

However, all of this will not work with the current design of LEMSDevice because the expressions for generating synapses refer to variables that are not actually stored anywhere. E.g. you could define spatial connectivity with something like this:

group = NeuronGroup(100, '''dv/dt = ... : volt
                     x : meter
                     y : meter''', threshold='v>v_th')
group.x = '(x % 10) * 50*um'
group.y = '(x / 10) * 50*um'
synapses = Synapses(group, group, ...)
synapses.connect('sqrt((x_pre - x_post)**2 + (y_pre - y_post)**2) < 100*umeter')

With the current approach, we'd generate <OnStart> assignments for the x and y values of group, but when we run Brian2's standard Synapses.connect function, it cannot actually refer to them.

The solution is, I think, to actually have LEMSDevice act like the standard runtime device except for the run. This means that it will actually assign and store values for x and y and it can create the synapses. Doing this should be straightforward:

  • Have LEMSDevice inherit from RuntimeDevice
  • Delete all the dummy functions that do nothing (e.g. LEMSDevice.add_array, LEMSDevice.get_value) -- their functionality will be inherited from RuntimeDevice
  • Also delete the DummyCodeObject and LEMSDevice.code_object
  • For the overwritten functions like variableview_set_with_expression_conditional, call the original implementation in addition to what LEMSDevice is doing currently. (Note that you cannot call variableview.set_with_expression_conditional, because this would call the overwritten function again. You have to take the quite ugly workaround of calling VariableView.original_function.set_with_expression_conditional(variableview, ...) ).

This way, everything up to the run call (including most importantly the synapse creation) will work just as in a normal run, but then the run will not be executed but instead we'll write out the XML file.

This was referenced Jul 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant