updating fsin.n for different frequencies
Posted: Thu Jul 05, 2018 8:51 am
Hello all,
I'm using fsin.mod to provide sinusoidal extracellular stimulation to an axon. I have set up my code so that I can choose what frequency I would like to stimulate the axon at within the GUI, and I would also like the duration of the stimulation to remain the same for all frequencies and therefore need the number of cycles (fsin.n) to scale with the change in frequency (i.e. fsin.n = fsin.f*duration). However when I change the frequency in the GUI the number of cycles does not change, and therefore the duration of the stimulation decreases with increasing frequency.
Here is my code for setting up fsin:
And here is my code for the GUI:
I understand that this is because I need to update the value for fsin.f in the calculation of fsin.n, and that currently it is just using 5000Hz (the default value) and so the number of cycles is staying constant. Therefore I believe I need to implement some sort of initialisation procedure but I don't know how to go about doing this and would really appreciate some advice.
Many thanks!
Theo
I'm using fsin.mod to provide sinusoidal extracellular stimulation to an axon. I have set up my code so that I can choose what frequency I would like to stimulate the axon at within the GUI, and I would also like the duration of the stimulation to remain the same for all frequencies and therefore need the number of cycles (fsin.n) to scale with the change in frequency (i.e. fsin.n = fsin.f*duration). However when I change the frequency in the GUI the number of cycles does not change, and therefore the duration of the stimulation decreases with increasing frequency.
Here is my code for setting up fsin:
Code: Select all
dur = 30 //ms
objref fsin
fsin = new Fsin(0.5) //sine wave generator
fsin.f = 5000 //Hz
fsin.amp = 20 //mA
fsin.del = 10 //ms
fsin.n = fsin.f*dur*0.001
setpointer fsin.x, is_xtra
Code: Select all
xpanel("AC Stim Settings",0)
xlabel("AC Stim Settings")
xvalue("AC amplitude (mA)","fsin.amp",1)
xvalue("AC frequency (Hz)","fsin.f",1)
xvalue("AC delay (ms)","fsin.del",1)
xvalue("AC duration (ms)","dur",1)
xvalue("AC no. of cycles", "fsin.n", 1)
Many thanks!
Theo