Paste in Fitting > Y-expr

Suggestions for improvements to the NEURON Forum.
Post Reply
Danko Georgiev
Posts: 7
Joined: Fri Oct 15, 2010 10:41 am
Location: Kanazawa University, Japan

Paste in Fitting > Y-expr

Post by Danko Georgiev » 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.

ted
Site Admin
Posts: 5091
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Paste in Fitting > Y-expr

Post by ted » 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".

Danko Georgiev
Posts: 7
Joined: Fri Oct 15, 2010 10:41 am
Location: Kanazawa University, Japan

Re: Paste in Fitting > Y-expr

Post by Danko Georgiev » 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.

ted
Site Admin
Posts: 5091
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Paste in Fitting > Y-expr

Post by ted » 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.

Post Reply