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
56 stars 52 forks source link

User defined simulation tstart #379

Open ntolley opened 3 years ago

ntolley commented 3 years ago

This was brought up by @jasmainak during #348, it would be nice to be able to define a negative tstart for plotting. This is especially relevant for event related potentials, where the peaks are named by clinical electrophysiologists according to when they appear in time relative to a stimulus. So if we have a simulation where a stimulus occurs at a later point in time, it would be aligned to 0 ms.

At a first pass, it seems like one of the easiest workarounds would be to have a tstart attribute of the network, and substract the from the .timesattribute of the various objects that store it during plotting. I believe there is some internal tests/logic built into CellResponse.times for example that may break if we just edit the .times attribute directly.

jasmainak commented 1 year ago

This still looks pretty relevant if someone wants to give it a shot

ntolley commented 1 year ago

I guess where this gets weird is that the length of the simulation will change depending on tstart. Are you thinking of just simulate_dipole(net, ..., tstart=-50.0) or something?

jasmainak commented 1 year ago

yep, that's exactly the API I was imagining ... one would have to be carefully adjust the times when adding the drives as well, not just the cell responses. E.g.,

net.add_evoked_drive(mu=20., ...)  # 20 ms or whatever is the conduction delay 

for an N20 response ...