updating fsin.n for different frequencies

Anything that doesn't fit elsewhere.
Post Reply
tjb17

updating fsin.n for different frequencies

Post by tjb17 »

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:

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
And here is my code for the GUI:

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)
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
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: updating fsin.n for different frequencies

Post by ted »

fsin.mod is not built into NEURON. Nobody knows what is in the particular fsin.mod you are using. Where did you find it?
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: updating fsin.n for different frequencies

Post by ted »

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).
fsin.mod isn't going to allow that. It will produce whole cycles, period. I could provide you with a mod file that allows fractional cycles, but have you considered the implications of using such a stimulus? Using an integer number of cycles ensures that no net charge has been delivered to the tissue. Terminate a cycle before it is completely finished and you're going to get results that depend on whether the electrode delivered more positive or negative charge, and just how much net charge there was. For example, the apparent "threshold stimulus" for spike initiation or conduction blockade will depend jointly on frequency and stimulus duration in peculiar ways. Why introduce such confounds into your computational experiments? Charge balance is also important in prosthetics applications because imbalance shortens electrode life and can aggravate tissue reaction.
tjb17

Re: updating fsin.n for different frequencies

Post by tjb17 »

Sorry I think I may have outlined my problem incorrectly. I'm not in fact looking at all frequencies, only a selection all of which would result in a whole integer number of cycles, but a different number of cycles nonetheless. For instance if I was comparing 5kHz and 10kHz both for a stimulation duration of 30ms, then the 5kHz stim would have 150 cycles and the 10kHz stim would have 300 cycles if they were to last for the same amount of time.

My problem is that when I change the frequency in the GUI, say from 5kHz to 10kHz, the number of cycles stays at 150 rather than increasing to 300. This might be a really basic problem to address, but I'm not so experienced with programming in neuron so I appreciate the help.
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: updating fsin.n for different frequencies

Post by ted »

So if you double the frequency, double the number of cycles too. Where's the problem?
Post Reply