In a simulation that a colleague and I are working on, we need to implement neurogenesis, and therefore we need to vary the number of neurons in the neuronal population over time. Unfortunately, the variable `N`

in a `NeuronGroup`

is read only. I am aware that I could archive a similar effect in the simulation by setting the number of neurons to the maximal value expected in the simulation, and gradually connecting the neurons using the synapses over time. But is there another way to model this parameter without having to do it over the connectivity? This would be beneficial since we are using stochastic neuronal models.

One of the possible solutions is to run a model for short periods (short compared to neurogenesis) and reorganize and initialize the model before the next run according to neurogenesis rules. Such short runs of a static network are very fast and computationally effective. Still, it needs lots of coding, and next model initialization based on the state of the previous model is a nightmare.

The biggest drawback of this approach is that Brain2 canâ€™t save spikes in the queue that are waiting for the delivery with a given conduction delay (@mstimberg, please correct me if Iâ€™m wrong). As a result, the frequent interruptions of simulation for model reorganization, lose some spikes and can significantly affect model dynamics.

Thatâ€™s an interesting approach, thank you! As you mentioned, it might be very complicated to get the initialization to run error-free each time.

Maybe it would be easier to introduce a â€śswitch parameterâ€ť in the neuron model, something like \frac{dv}{dt}=\Delta\cdot(...) where \Delta is set to zero for all the neurons that are inactive and one for all the neurons that are active.

I will try to implement both approaches and see if any of them work for our use case.

Hi @Willenberg, apologies for the late reply, but @rth already gave you one useful direction (yes, spikes in the queue would be lost if you stop a simulation, build another one from scratch and copy over the state of all the dynamical variables). The best approach depends on a number of factors, like how many/few neurons will be concerned by neurogenesis or cell death, how often such events happen, etc. Probably the easiest would be indeed to have some `"is_alive : boolean"`

parameter in the neuron_model, which you then include as a factor in your models (with a boolean, youâ€™d multiply with `int(is_alive)`

, but you could also directly use a parameter that is 0 or 1 of course). If there are only a few dead (i.e. â€śnot yet aliveâ€ť) cells with respect to the total number of cells, it would be probably the easiest to not actually include this factor in the \frac{dv}{dt} definition, but only in the `threshold`

, for example (to make sure that the cells have no effect on other cells). Let us know how you advance, happy to give more concrete advice if necessary.