Using parameter values read from a file

Using the Multiple Run Fitter, praxis, etc..
Post Reply
denise_arruda
Posts: 3
Joined: Wed Apr 01, 2009 7:33 pm

Using parameter values read from a file

Post by denise_arruda » Sat Apr 04, 2009 3:43 pm

Hi,
I'm trying to do a parameter change in one of my models. I'm doing it in matlab and neuron, first I create the parameters combinations in matlab and for each one, I call the neuron, where run the simulation. But I have observed that some parameters never change in my model done in neuron. I will explain:
The file is read in this way:

objref fobj

fobj = new File()
fobj.ropen("newparam.dat")

a = fobj.scanvar()
b = fobj.scanvar()
c = fobj.scanvar()
d = fobj.scanvar()
e = fobj.scanvar()
f = fobj.scanvar()

ok, this is working, but the new variables (a, b, c, d, e, f) aren't seen in the cell model. I have tried different ways of read the file and it's not the problem. What I need is that the parameters of this file are attributed in conductances, like that:

proc biophysics () {
forsec soma {
insert hh
gna_hh = a
gk_hh = b
.
.
.
I don't know if I was clear...
Anyway I'm waiting your answer!
Thank you very much!

Denise Arruda
Computational Neuroscience Laboratory
USP – Ribeirão Preto - Brazil

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

Re: Using parameter values read from a file

Post by ted » Sat Apr 04, 2009 7:34 pm

After you read the variables from the file, you must assign their values to the model parameters. If you plan to do this a lot, it may be convenient to create a proc that does this. Creating such a proc is also good programming style, even if you only do this once, because it makes program development and debugging easier. Example:

Code: Select all

// expects one argument: a string that contains the name of the file 
proc newparams() { localobj fil
  fil = new File()
  fil.ropen($s1)
  gna_hh = fil.scanvar()
  gk_hh = fil.scanvar()
  fil.close()
}

newparams("newparam.dat")

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

Re: Using parameter values read from a file

Post by ted » Sun Apr 05, 2009 9:16 am

One correction:
in NEURON's hh mechanism, gna and gk are not parameters--they are variables that are computed in the course of a simulation. The corresponding parameters are gnabar and gkbar. With this correction, the example becomes

Code: Select all

proc newparams() { localobj fil
  . . .
  gnabar_hh = fil.scanvar()
  gkbar_hh = fil.scanvar()
  . . .
}

denise_arruda
Posts: 3
Joined: Wed Apr 01, 2009 7:33 pm

Re: Using parameter values read from a file

Post by denise_arruda » Sun Apr 05, 2009 9:44 am

Hi Ted;
Your suggestion didn't work. There was a syntax error:
/opt/neuron/x86_64/bin/nrniv: syntax error
in PeriglomCell.hoc near line 96
localobj fil
^
xopen("PeriglomCell.hoc")
execute1("{xopen("PeriglomCell.hoc")}")
load_file("PeriglomCell.hoc")
0
/opt/neuron/x86_64/bin/nrniv: syntax error
in PeriglomCell.hoc near line 97
fil = new File()
^
I created the follwing procudure:

Code: Select all

proc biophysics () {

localobj fil
fil = new File()
fil.ropen($s1)

	forall { 				// insert passive current everywhere
		Ra = 173
		cm = 1.2
		insert pas
		g_pas = 2.3e-4 	// uS, -> 1 Mohm // default
		e_pas = -70		// ???
	}

	forsec pg_allbutaxon {
		insert it2			// T-current; cf. nonuniform distribution in dendrites below			
			cai_it2 = 2.4e-4
			cao_it2 = 2 
			shift_it2 = -1
			gcabar_it2 = fil.scanvar()	
		insert cad			// calcium diffusion everywhere
		        depth_cad = 0.1 
			kt_cad = 0			// no pump
			kd_cad = 1e-4
			taur_cad = 5
			cainf_cad = 2.4e-4	

		insert hpg 			// PG cell h current from Cadetti and Belluzzi
			eh_hpg=0 
			ghbar_hpg = fil.scanvar()
		insert ka
			gkabar_ka = fil.sacanvar()
	}
	forsec pg_spikers {
		insert hh2			// insert fast spikes in pg soma and axon only
			ena = 50
			ek = -100
			vtraub_hh2 = -52
			gnabar_hh2 = fil.scanvar()
			gkbar_hh2 =  fil.scanvar()
	}
fill.close()
}
I called this procedure in the init procedure:

Code: Select all

proc init() {

	topol()

	subsets()

	segments()

	geometry()
	changep()

	biophysics("newparam.dat")

}
within the cell template.
Well, this was one of my attempt. I have tried other ways, like read the parameters in other procedure apart of the biophysics(), or read it in a .hoc file that is loaded in the cell model (PeriglomCell.hoc) end others.
So, if you can help me.... I appreciate!
Thanks
Denise

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

Re: Using parameter values read from a file

Post by ted » Sun Apr 05, 2009 8:57 pm

A very general suggestion: if one has a cell class template that works, it is best to avoid editing it unless one knows exactly what one is doing. It is far too easy to break something. The best way to accomplish parameter changes is to create a model cell instance, then change the parameters of that model cell instance.

My suggestions will be most specific, and most likely to work, if I have a clear understanding of what you are trying to accomplish. At this point I'm just guessing.

Is it correct to guess that you have a template that defines a cell class, and you want to create instances of model cells whose parameters are different from those specified in the template? Do you need just one model cell, or is it your goal to create many model cells at the same time (e.g. for use in a network)? If the latter, do you intend for each model cell to have the same parameters as those of its siblings, or do you want each cell to have its own, possibly unique, set of parameters?

Finally, do your aims truly have anything to do with optimization, or exploration of parameter space, or are you just trying to assign different parameters to a cell than those which were specified by the template?

denise_arruda
Posts: 3
Joined: Wed Apr 01, 2009 7:33 pm

Re: Using parameter values read from a file

Post by denise_arruda » Mon Apr 06, 2009 8:44 am

I'm sorry to I'm not being clear, my english is terrible...But I will tray again:
My aim is to do a exploration of parameter space. To do that I want that the conductances (variables of my cell model) receive different values because I intend to find the better set of this values that reproduce a known behavior.
I'm not creating many cells, it's just one. It's a model of periglomerular cell of the Olfactory Bulb.
The parameters set is created in the matlab, so the neuron is called to run the simulation with this parameters set.
In the neuron I read the parameters set from the file "newparam.dat".
I want that the conductances receive this parameters.
What is happening is the followin:
Matlab - parameters set - neuron - init.hoc (read the parameters) - periglomCell.hoc (variables don't receive the new parameters)
I have tried to do procedures in init.hoc or in periglomCell.hoc, or other .hoc file to read the parameters and be loaded in the init.hoc and others attempt that I have told you.
I use to do my models in matlab or C, but I want to learn Neuron. I'm learning alone, of course there is the Neuron support, anyway I have had same difficulties, therefore I have many doubts and this forum has helped me very much.
Thanks
Denise

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

Re: Using parameter values read from a file

Post by ted » Mon Apr 06, 2009 10:53 am

There is nothing wrong with your english. The problem lies in the fact that answering your question is not simply a matter of pointing you to correct hoc syntax. Finding the "right" answer requires knowledge of what you are working with, and what you are trying to achieve. Now that I have this information, I can tell you how to proceed.

Do not tinker with the template. Instead, create an instance of the cell class. Then use hoc to change whatever parameters you want to change. If a parameter pertains to a subset of sections, iterate over the members of that subset. Example:

Code: Select all

objref cell
cell = new Cell()

// change individual parameters for individual sections
cell.soma gnabar_hh = 0.1
cell.dend[1] e_pas = -65

// change a parameter for all sections in a subset
forsec cell.dendritic g_pas = 1e-4
"How can I tell if there are subsets?"
(This answer assumes that the template was generated with the CellBuilder, or written by someone who adheres closely to the programming style used by the CellBuilder when it exports a class definition.)
Look for a proc subsets(), which will start with something like this:

Code: Select all

proc subsets() { local i
  objref all, dendritic, full_hh
The names that appear after objref are the names of subsets.

There is almost always an all subset.

If your model cell has subsets, you should examine the template to discover whether it used any

Code: Select all

forsec subsetname . . .
statements to assign values to any of the model parameters that you want to change. If the answer is yes, then you should decide whether your new parameter values must also be assigned by iterating over subsets. The answer depends entirely on what you are trying to do.

If the new parameter values are to be read from a file, it is best to create a proc that opens the file, reads each value and assigns it to the appropriate parameters of the model cell, and then closes the file.

Post Reply