Stimulus depending on the brain activity itself #144
Answered
by
caglorithm
NathanGodey
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Hey Nathan,
thanks for reaching out! It’s really nice to hear about people using our library for their own projects.
Let me get to your question:
I think your approach is the way to go! Unfortunately, the `input_vars` feature is not very useful as of now, but that doesn’t matter. You can simply set the appropriate parameter of the ALN that is specifically there to control the external input, namely these guys (found in `models/aln/loadDefaultParams.py`):
``` python
# external neuronal firing rate input
params.ext_exc_rate = 0.0 # kHz external excitatory rate drive
params.ext_inh_rate = 0.0 # kHz external inhibiroty rate drive
# externaln input currents, same as mue_ext_mean but can be time-dependent!
params.ext_exc_current = 0.0 # external excitatory input current [mV/ms], C*[]V/s=[]nA
params.ext_inh_current = 0.0 # external inhibiroty input current [mV/ms]
```
I’d probably suggest going for `params.ext_exc_current`.
I’d do something like this (I’m writing in pseudocode so it’s faster):
```python
model = ALNModel()
model.params.dt = 0.1
model.params.duration = 100
# run the model once so you can compute the stimulus
model.run(chunkwise=True, chunksize=1000, append=True, continue_run=True)
for _ in range(n_chunks):
# compute your stimulus base on the model output
your_stimulus = compute_your_stimulus(model.output)
# set the stimulus
model.params[‘ext_exc_current’] = your_stimulus
model.run(chunkwise=True, chunksize=1000, append=True, continue_run=True)
```
Important thing here are the arguments of model.run():
* `chunkwise=True, chunksize=1000` is clear I hope
* `append=True`, will append the output of the next chunk to the model’s outputs
* `continue_run=True`, will use the last state vector of the model as a starting point
I’d be happy to learn more about what you’ve achieved with neurolib, in case you want to share!
Best
Caglar
Edit: I forgot to add that the loop, as I wrote it, only works the way you want it, if you also set the duration (measured in ms) to be the same as the chunksize (measured in time steps):
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
NathanGodey
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello! Thanks for the great work in this repository.
I am trying to build a neurofeedback model using the ALN model as an EEG generator (for a school project).
This means that I need to use an input stimulus that depends on the EEG signal sampled on the last few hundreds of milliseconds. I think I have figured out two ways to achieve this :
Do you have any recommendation, or is there an easier way to do this ?
Best and thank you in advance
Beta Was this translation helpful? Give feedback.
All reactions