jonescompneurolab / hnn-core

Simulation and optimization of neural circuits for MEG/EEG source estimates
https://jonescompneurolab.github.io/hnn-core/
BSD 3-Clause "New" or "Revised" License
54 stars 52 forks source link

Change scaling parameter over time #149

Closed kohl-carmen closed 3 years ago

kohl-carmen commented 4 years ago

I'd like to be able to change the scaling parameter within a simulation.

In my particular example, the ERP I'm looking to simulate might be containing (more or less) separate early and late dynamics, with later parts of the waveform recruiting a much larger neural population. To account for that, I'd like to scale different time intervals of the dipole by different factors.

jasmainak commented 4 years ago

The most straightforward way would be to allow an array of the same length as Dipole.times in this function:

https://github.com/jonescompneurolab/hnn-core/blob/7f142513bd7d42e6dfcd660126551d3962fabb07/hnn_core/dipole.py#L104

Now what's not super obvious to me is how you would do the sequence of these operations:

https://github.com/jonescompneurolab/hnn-core/blob/7f142513bd7d42e6dfcd660126551d3962fabb07/hnn_core/neuron.py#L119-L122

I was thinking that you could have run your simulation as is, and then just run dipole.scale(factor) twice: first to undo the scaling that was done and then to apply the scaling you'd like. But the problem now is that there are a bunch of other operations that sandwich the scaling.

I think the best approach would be to add an option postprocess=True/False/None (use what param file says) to simulate_dipole. Then as a user, you would do:

dpls = simulate_dipole(postprocess=False)
dpls = [dpl.scale(fancy_scaling_factor) for dpl in dpls]
jasmainak commented 3 years ago

closed by #183