# Custom initialization

## Physical System

## Model

### Ball-Stick approximation to cell

## Simulation

The aim of this exercise is to learn how to perform one of the most common types of custom initializaton: initializing to steady state.

We start by making a ball & stick model in which the natural resting potential of the somatic sphere and dendritic cylinder are different. No matter what v_init you choose, default initializaton to a uniform membrane potential results in simulations that show an initial drift of v as the cell settles toward a stable state.

After demonstrating this initial drift, we will implement and test a method for initializing to steady state that leaves membrane potential nonuniform in space but constant in time.

### Getting started

In this exercise you will be creating several files, so you need to be in a working directory for which you have file "write" permission. Start NEURON with course/init as the working directory.

### Making the representation

Use the CellBuilder to make a simple ball and stick model that has these properties:

Section | Anatomy | Compartmentalization | Biophysics
soma | length 20 microns diameter 20 microns | d_lambda = 0.1 | Ra = 160 ohm cm, Cm = 1 uf/cm2 Hodgkin-Huxley channels
dend | length 1000 microns diameter 5 microns | d_lambda = 0.1 | Ra = 160 ohm cm, Cm = 1 uf/cm2 passive with Rm = 10,000 ohm cm2

Turn Continuous Create ON and save your CellBuilder to a session file.

### Using the Representation

Bring up a RunControl and a voltage axis graph.
Set Tstop to 40 ms and run a simulation.
Use View = plot to see the time course of somatic membrane potential more clearly.

Add dend.v(1) to the graph (use Plot what?), then run another simulation.
Use Move Text and View = plot as needed to get a better picture.

Add a space plot and use its Set View to change the y axis range to -70 -65.
Run another simulation and watch how drastically v changes from the initial condition.

Save everything to a session file called all.ses (use File / save session) and exit NEURON.

## Exercise: initializing to steady state

In the course/ballstk directory, make an initss.hoc file with the contents

    	// load the GUI tools
    	load_file("nrngui.hoc")
    	// the model and user interface
    	load_file("all.ses")
    	// custom steady state init
    	load_file("ssprocinit.hoc")

Also make a file called ssprocinit.hoc that contains these lines :

    proc init() { local dtsav, temp
      finitialize( v_init)
      t = -1e10
      dtsav = dt
      dt = 1e9
      // if cvode is on, turn it off to do large fixed step
      temp = cvode.active()
      if (temp!=0) { cvode.active(0) }
      while (t<-1e9) { fadvance() }
      // restore cvode if necessary
      if (temp!=0) { cvode.active(1) }
      dt = dtsav
      t = 0
      if (cvode.active()) {
        cvode.re_init()
      } else {
        fcurrent()
      }
      frecord_init()
    }

Now use NEURON to execute initss.hoc.
Click on Init & Run and see what happens.

## "Special credit" exercise

Another common initialization is for the initialized model to satisfy a particular criterion. Create an initialization that will ensure that resting potential throughout the cell equals v_init.

NEURON hands-on course
Copyright © 2003 by N.T. Carnevale and M.L. Hines, all rights reserved.