using MRF for fitting two outputs at same time

Using the Multiple Run Fitter, praxis, etc..

using MRF for fitting two outputs at same time

Postby shyam_u2 » Tue Apr 16, 2013 12:11 pm

I am trying to fit my model current with experimental traces for two different stimulation protocol. Say I have protocol 1 which produces output A and protocol 2 produces output B. I want to fit output A and B to their corresponding experimental data at the same time ie., I want to find parameters x,y and z of the model that best fits both output A and B to their corresponding experimental data. I know I can use Multiple run fitter to fit a single model output but I am not sure how to use MRF in this case. I am using MRF for the first time so any help is greatly appreciated.

Thank you in advance.
shyam_u2
 
Posts: 73
Joined: Sun Feb 20, 2011 8:15 pm

Re: using MRF for fitting two outputs at same time

Postby ted » Sat Apr 20, 2013 5:55 pm

Imagine the simplest case, in which two protocols differ by the value assigned to a single parameter. A real example would be

protocol 1: cell is subjected to a subthreshold stimulus delivered to the soma by an IClamp (0.1 nA x 0.1 ms starting at 1 ms)

protocol 2: cell is subjected to a suprathreshold stimulus delivered by the same IClamp (2 nA x 0.1 ms starting at 1 ms)

One would start by using a Multiple Run Fitter (MRF hereafter) to set up an MRF Generator that implements the first protocol. This MRF Generator would be configured to do a RegionFitness. The one additional step in configuring this MRF Generator is to specify a Protocol Constant. Let's say the IClamp was created by these hoc statements
Code: Select all
objref stim
soma stim = new IClamp(0.5)
stim.del = 1
stim.dur = 0.1
Then in the MRF Generator one would click on
Fitness / Protocol Constant
This pops up a variable name browser that has a text field in which one enters
stim.amp
and then clicks on its Accept button.

Now close this MRF Generator and display it again so that the new component in its graphical interface is properly rendered: a button labeled
stim.amp
next to which there is a numerical field and a "spinner" (paired up & down arrows). Enter 0.1 and click on the MRF Generator's "Error Value" button, and compare the response of the unoptomized model with the experimentally measured response.

You're halfway done.

The next step is to clone this MRF generator, rename the clone, display the clone, paste the appropriate experimental data into it from the clipboard, adjust regions if necessary, assign the desired value to the protocol constant (2 nA, in this case), and click on its Error Value button to check results.

Finally make sure that the MRF "uses" both MRF Generators, and click on its Error Value button to see the total error.

There is an additional practical consideration: different protocols are likely to generate different errors. If these differ by orders of magnitude, guess which protocol is going to have the strongest influence on the final results? If several MRF Generators are "used" It may be necessary to scale the error reported by one or more of them. Do this by clicking on the affected MRF Generator's "Regions" button and selecting "Weight panel." Change its total weight from 1 to a value that, when multiplied by the error reported by this MRF Generator, brings the product close to the value reported by the other "used" MRF Generators.

"OK, that's enough about 'Protocol Constant.' What about the 'Protocol Statement' option?"

Sometimes protocols differ in ways that can't be conveniently summarized by a single numerical value. In some cases you can get along by just adding two or more Protocol Constants, but in others it is necessary to call a procedure that does something more complex. Click on the MRF Generator's
Fitness / Protocol Statement
and enter the statement that needs to be executed in order to set up the protocol for this Generator.
ted
Site Admin
 
Posts: 5040
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine

Re: Best practices for MRF fit on multiple configurations

Postby gsb » Wed Aug 16, 2017 1:36 pm

I'm also using the MRF to fit simulation data from multiple generators. In one case, the instrumentation changes, and I'd like to fit the (hopefully constant) passive properties of the cell that was recorded. I'm also using a reconstruction of the cell's morphology (hopefully also constant and held as such). I have a voltage-clamp step response to fit while recording at one site, as well as responses from two sites to fit after establishing whole-cell recording at the second site. For the latter, the sites alternate between voltage-clamp and current-clamp configurations.

So far, I've been able to optimize fits by making a generator for each recording site, with each configuration implemented on an independent copy of the cell topology/morphology. For example, in pseudocode:
Code: Select all
//Establish the 1st copy of the cell, add the 1st SEClamp at recording site 1, vector.play() the command to SEClamp1, create a generator for clamp current of SEClamp1 (using region fitness)
//Establish the 2nd copy of the cell, add the 2nd SEClamp at recording site 1, vector.play() the command to SEClamp2, create a generator for clamp current of SEClamp2 (using region fitness)
//For this second copy of the cell, add an IClamp at recording site 2, create a generator for its voltage response (using region fitness)
//Create proxies for the biophysical parameters of cells 1 and 2, set those equal at the start of the custom init()
//Run the MRF to fit the biophysical parameters as for a single generator...

Is there a more elegant approach to fitting data from multiple 'configurations' (for lack of a better general term)? My current approach would clearly run into issues with differences in simulation sample rate or duration between configurations.

Based on the earlier posts here, I imagine it might be possible use 'Protocol Statement' to appropriately overwrite the PointProcesses and update their play() vectors before each generator run. This approach seems like it could be more flexible and concise, though I'm not sure the approach would be faster computationally. That seems like it would depend on whether instantiating (or at a minimum re-assigning) objects is fast relative to the run-time of the more parallel simulation.

A point in the direction of documentation on 'Protocol Statement' would be very helpful. I don't see it listed on http://neuron.yale.edu/neuron/static/do ... ulfit.html, and it would be great to avoid diving into the source code. It sounds like whatever statements are in 'Protocol Statement' are execute before the generator run, then are they reset afterwards as for 'Protocol Constant'? Could one also change run parameters like dt? Are there limitations to the changes that can be made with 'Protocol Statement'?

Any advice would be appreciated.
gsb
 
Posts: 3
Joined: Thu Jul 13, 2017 3:54 pm

Re: using MRF for fitting two outputs at same time

Postby ted » Wed Aug 16, 2017 5:33 pm

See if this item in ModelDB gives you some ideas:
https://senselab.med.yale.edu/ModelDB/showmodel.cshtml?model=3342
ted
Site Admin
 
Posts: 5040
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine

Re: using MRF for fitting two outputs at same time

Postby gsb » Thu Aug 17, 2017 2:34 pm

Thank you for the reference, Ted. I hadn't realized that their fitting setup would also be available on ModelDB. (In case anyone else might be looking for examples of MRF setup, its in the model's cell2 folder. Despite the readme file, it took me a moment to realize.)

It was definitely worth the look. For example, I hadn't realized that one generator can encompass multiple fit variables.

However, I'm still not sure about the best way to handle multiple experimental configurations with their own MRF generators. In my case, the configurations differ primarily in the presence, absence, or type of "instrumentation" (i.e., SEClamp or IClamp) at recording sites. The mitral cell model generators only appear to differ in initial conditions (v_init, e_pas) and the stimulus, and those are updated before each run while other model specifications are always constant (or perhaps I've missed something there).

To fit parameters involved in multiple configurations, it still seems one either needs to A) make duplicates of the cell with different instrumentation or B) use a 'Protocol Statement' to change the configuration. I'm leaning towards (A) right now, though I still have the concerns I mentioned before. Thinking about it a little more, (B) seems complicated by the fact that the 'Protocol Statement' would actually change the nature of the fit variables, perhaps in a way that would cause issues. For example, I'm not sure what would happen if the MRF was made to fit the voltage of an IClamp that is deleted and later reinstantiated.

On the more practical side of things, my approach to (A) has been to make two separate instances (copies/clones) of the cell and then instrument them differently, e.g., one copy's topology/morphology is specified as:
Code: Select all
create soma0
soma0 {
  pt3dclear()
  pt3dadd(0,0,0,1)
  pt3dadd(1,1,1,3)
    //and so on...
}
create axon0
axon0 {
  pt3dclear()
  pt3dadd(0,0,0,0.5)
  pt3dadd(1,1,1,1)
    //and so on...
}
connect axon0(0), soma0(1)
define_shape()

A second instance's morphology/topology is specified as:
Code: Select all
create soma1
soma1 {
  pt3dclear()
  pt3dadd(0,0,0,1)
  pt3dadd(1,1,1,3)
    //and so on...
}
create axon1
axon1 {
  pt3dclear()
  pt3dadd(0,0,0,0.5)
  pt3dadd(1,1,1,1)
    //and so on...
}
connect axon1(0), soma1(1)
define_shape()


Is there a way that I could better handle such duplicate instances? For creating them, I suppose I could make a list that holds the original set of sections (or perhaps it would have to be SectionRef objects), then write a procedure that iterates through the list, runs n3d(), x3d(), etc. and then runs the corresponding code to create the same sections under a different name.

The SectionRef class looks useful in this regard, but I was hoping for it to contain a duplicate() procedure. I guess what I'm really looking for is a CellRef class (that also has a duplicate procedure).
gsb
 
Posts: 3
Joined: Thu Jul 13, 2017 3:54 pm

Re: using MRF for fitting two outputs at same time

Postby ted » Thu Aug 17, 2017 2:47 pm

Protocols that differ with regard to whether a cell is current clamped or voltage clamped are easy to implement. Just attach all the clamps that will be needed for any of the protocols. Then achieve "absence of a voltage clamp" making the SEClamp's series resistance extremely large, say 1e9 or more megohms. Similarly, "absence of a current clamp" is also easily achieved--either reduce the current clamp's amp parameter to 0, or increase its delay parameter to 1e9.
ted
Site Admin
 
Posts: 5040
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine

Re: using MRF for fitting two outputs at same time

Postby gsb » Thu Aug 17, 2017 3:11 pm

Thanks, Ted. That is certainly a convenient method for cases with simple point processes like IClamp/SEClamp.

Let's say I also had a segment that implemented pipette capacitance, in between the cell and the IClamp. Would it be reasonable to set the internal resisitivity of this segment to 1e9 -- or perhaps set its diameter to 1e-9 -- to disconnect the pipette, in analogy to your proposal for the voltage clamp?

This seems good to me in theory, but potentially a bit wasteful of computation time in practice, since the disconnected segment (or SEClamp, IClamp, etc. for that matter) is presumably still "involved" in the simulation.
gsb
 
Posts: 3
Joined: Thu Jul 13, 2017 3:54 pm


Return to Optimization

Who is online

Users browsing this forum: No registered users and 1 guest