nest / nestml

A domain specific language for neuron and synapse models in spiking neural network simulation
GNU General Public License v2.0
45 stars 46 forks source link

Sender_id information available in the update block #1022

Closed rbonometto closed 2 months ago

rbonometto commented 3 months ago

Hello everyone, I am currently working on a SNN implementation of a closed-loop control system to simulate the role of cerebellum in motor control. I am trying to develop in NESTML a model of a neuron to perform state estimation as explained in https://direct.mit.edu/neco/article/34/9/1893/112384/Bayesian-Integration-in-a-Spiking-Neural-System. To do so, I would need to use in the update block the information of which neuron has sent a specific spike (sender_id in NEST); however, I haven't found a way to do so. As a workaround, I tried to define a different port for each neuron through vectorized ports, to then establish one to one connections but the problem still persists as vectorized ports don't seem to support indexing through variables, neither in the definition in the state block: fbk_spikes[N_fbk] <- spike nor to access their content in the update block: fbk_buffer[index] = fbk_spikes[i]. In this last case, the generated code in the cpp file is: S_.fbk_buffer[index] = (0.001 * B_.spike_inputs_grid_sum_[FBK_SPIKES_0 - MIN_SPIKE_RECEPTOR]);} whatever the value of i, which raises a 'make all' error.

clinssen commented 3 months ago

Hi, thanks for writing in! I think defining vector input ports are the way to go here. @pnbabu: could you look into what the issue is with addressing using a variable? This should work and it might be just a small fix.

pnbabu commented 3 months ago

@rbonometto Hi, could you please share a simple reproducible version of your model so that I can see locally what's going wrong?

rbonometto commented 3 months ago

@pnbabu sure! This is what I wrote so far: state_neuron.zip

pnbabu commented 3 months ago

@rbonometto The issue with vector input ports is fixed in this PR: https://github.com/nest/nestml/pull/1042 Thank you for pointing it out! Could you please pull these changes and check if they work for you?

Note that with these changes, the vector input ports are indexed starting from 0. So please change your models accordingly. Please don't hesitate to reach out if you have further questions.

pnbabu commented 2 months ago

Fixed by #1042