nest / nest-simulator

The NEST simulator
http://www.nest-simulator.org
GNU General Public License v2.0
532 stars 361 forks source link

Support for vectors in RecordablesMap #1898

Closed pnbabu closed 3 years ago

pnbabu commented 3 years ago

Is your feature request related to a problem? Please describe. In NESTML, the variables defined in the state block of the neuron model are used to record using the NEST's multimeter. To achieve this, the generated NEST code has insert_() statements to the RecordablesMap.

insert_("V_m", &iaf_psc_delta::get_V_m);

We are now working to support vectors in NESTML that stores an array of values say, an array of membrane potentials, that we could later record from. The current insert_ function in the RecordablesMap class doesn't support to record from a vector.

Describe the solution you'd like The RecordablesMap could be extended to support recording from vectors as well.

For example,

insert_("g_ex", &iaf_psc_delta::get_g_ex);

where get_g_ex returns a vector.

heplesser commented 3 years ago

@pnbabu Could you explain in more detail what that vector should contain? In most neuron models, g_ex is a scalar which multimeter will request once per sampling time step. Therefore, get_g_ex() is expected to return a scalar. In which way do you want to extend this from scalar to vector?

pnbabu commented 3 years ago

@heplesser The example provided in the issue happened to be iaf_psc_delta. The name was misleading and the requirement was not specific to that. This is a requirement for supporting multiple compartmental models for NESTML. In order to achieve this, we would need to store the values of variables from all the compartments. These values could be stored in vectors. For example, a vector with membrane potentials from all the compartments. The neuron model of NESTML, in this case, would look something like this:

neuron vector_neuron:
  state:
      ten integer = 10
      refr_spikes mV = 0 mV
      V_m [ten] mV = 15mV
  end
end

The above code declares a neuron model by name vector_neuron that has two state variables, refr_spikes, which is a variable of type double and V_m, a vector of 10 double values, all initialized to 15mV. This would then be converted to the corresponding NEST code where callbacks are added to the RecordablesMap to record the values using a multimeter.

[...]

insert_("refr_spikes", &vector_neuron::get_refr_spikes);

insert_("V_m", &vector_neuron::get_V_m);

[...]

The second insert_ in the above code gives an error as the RecordablesMap does not expect a callback that returns a vector. It would be great to have the RecordablesMap extended to support callbacks for vectors as well.

heplesser commented 3 years ago

Will be handled by NESTML, closing.