Page 1 of 1

### Paste in Fitting > Y-expr

Posted: Fri Oct 15, 2010 10:56 am
Dear authors,

I would like to say that NEURON is great once you get used to it. There are nice tutorials online, so I have learned the basics.

Here I would like to request if you could update the Fitting > Parameterized Function > Y-expr so that it can accept text to be pasted from the clipboard.

Briefly, I need to input long math expressions and although I have them properly formatted in txt file, the Y-expr does not allow me to Paste from the clipboard (I use Windows XP OS).

Is there a way to solve this problem?

Regards,

D. G.

### Re: Paste in Fitting > Y-expr

Posted: Sat Oct 16, 2010 1:52 pm
Here's a solution that works now, with any version of NEURON. And it has two advantages over copy & paste: it doesn't limit you to simple "one-liner" functions, and it allows you to easily test your function to make sure it's working properly. Create a new hoc file, and put inside it a single function that takes one argument. The body of the function can be anything you like. Then xopen() your hoc file, and when you configure the MRF, you can just enter the name of the function.

Example: suppose you want to adjust the parameters of a biexponential function so that the function matches an experimentally recorded waveform. You could just click on
Fitness / Expression with \$1
and then type
A*(exp(-k1*\$1) - (exp(-k2*\$1))
into the tool that requests the "Expresssion involving the independent variable, \$1".

But my suggestion would have you do this:
1. Use a text editor to create this function definition:

Code: Select all

``````func biexp() {
return A*(exp(-k1*\$1) - exp(-k2*\$1))
}``````
and save it to a file called myfunc.hoc.
2. At the oc> prompt type xopen("myfunc.hoc"). Now hoc knows a new function called biexp().
3. After clicking on
Fitness / Expression with \$1
just type
biexp(\$1)
into the tool that requests the "Expresssion involving the independent variable, \$1".

### Re: Paste in Fitting > Y-expr

Posted: Thu Oct 21, 2010 8:00 am
Dear Ted,
Thanks for your reply. I will try to define such useful one variable functions myself. Thanks for the code, it is very useful to have such code template.

### Re: Paste in Fitting > Y-expr

Posted: Thu Oct 21, 2010 9:26 am
Thanks for using NEURON, and for asking a question that will also probably benefit many other NEURON users.