simple integrate and fire neuron network

Moderator: wwlytton

Post Reply
tsang

simple integrate and fire neuron network

Post by tsang »

Hi, I am trying to build "very simple" integrate and fire model, say just build two or three cells, and then connect them together. Hopefully can produce spikes on the graph. I tried two files with code.

However, my code seems don't work at all. Can you please help me with it? The command window says some syntax error on NetCon part, last line. I just really don't know what I should do. Please help me. Thanks a lot.

Here is the 1st file of code.

Code: Select all

load_file("nrngui.hoc")


print "-{ create cells }-"

begintemplate simpleIAFcell




  public soma1, soma2, soma3
  public IAF
  public x, y, z, x1, y1, z1, x2, y2, z2
  public addConnection

  objref IAF

  create soma1

  proc init() {
     x = $1
     y = $2 
     z = $3

     soma1 {
       // set lattice position of the cell
       pt3dclear()
       pt3dadd(x, y, z, 5)
       pt3dadd(x+5, y, z, 5)

       // insert IntFire1 point process
       IAF = new IntFire1(0.5)
       IAF.tau = 10
       IAF.refrac = 5
     }
  }

  proc addConnection() {
     soma1 {
       pt3dadd(x+5, y, z, 1)
       pt3dadd($1+5, $2, $3, 1)
     }
  }

//=======================================================================

  create soma2

  proc init() {
     x1 = $4
     y1 = $5 
     z1 = $6

     soma2 {
       // set lattice position of the cell
       pt3dclear()
       pt3dadd(x1, y1, z1, 10)
       pt3dadd(x1+2, y1, z1, 10)

       // insert IntFire1 point process
       IAF = new IntFire1(0.5)
       IAF.tau = 10
       IAF.refrac = 5
     }
  }

  proc addConnection() {
     soma2 {
       pt3dadd(x1+2, y1, z1, 1)
       pt3dadd($4+2, $5, $7, 1)
     }
  }

//========================================================================

  create soma3

  proc init() {
     x2 = $7
     y2 = $8 
     z2 = $9

     soma3 {
       // set lattice position of the cell
       pt3dclear()
       pt3dadd(x2, y2, z2, 8)
       pt3dadd(x2+10, y2, z2, 8)

       // insert IntFire1 point process
       IAF = new IntFire1(0.5)
       IAF.tau = 10
       IAF.refrac = 5
     }
  }

  proc addConnection() {
     soma3 {
       pt3dadd(x2+8, y2, z2, 1)
       pt3dadd($7+8, $8, $9, 1)
     }
  }


//Connect somas together

  objref prob
  prob = new Random()

  aprob = prob.uniform(0,1)
   

  objref CellConnections

    CellConnections = new NetCon(soma1, soma2, 10, 1, 0.3)

endtemplate simpleIAFcell


The second file of code I tried to even simpler, but again, nothing works. Can you please kindly tell me what I did wrong? I kind of pretend the soma is still cylinder, like is HH model, but I put IntFire1 on the somas, maybe that's really silly way. Sorry I'm still relatively new to NEURON.

Here is 2nd file of code.

Code: Select all

load_file("nrngui.hoc")


objref IAF

create soma1, soma2, soma3


    soma1 {
       nseg = 1
       diam = 100
       L = 100
       Ra = 123.0

       // insert IntFire1 point process
       IAF = new IntFire1(0.5)
       IAF.tau = 10
       IAF.refrac = 5
    }
    
     soma2 {
        nseg = 1
        diam = 50
        L = 100
        Ra = 123.0

        // insert IntFire1 point process
        IAF = new IntFire1(0.5)
        IAF.tau = 10
        IAF.refrac = 5
     }

     soma3 {
        nseg = 1
        diam = 80
        L = 100
        Ra = 123.0

        // insert IntFire1 point process
        IAF = new IntFire1(0.5)
        IAF.tau = 10
        IAF.refrac = 5
     }


// network connection

  objref CellConnections    

    CellConnections = new NetCon(soma1, soma2, 10, 1, 0.5)
ted
Site Admin
Posts: 6300
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: simple integrate and fire neuron network

Post by ted »

The first thing to do is to learn more about NEURON. If you have a copy of the NEURON Book, read at least chapters 5, 6, and 10. If you don't have the book, read
http://www.neuron.yale.edu/ftp/ted/book ... xedref.pdf
http://www.neuron.yale.edu/ftp/ted/book ... xedref.pdf
http://www.neuron.yale.edu/ftp/ted/book ... xedref.pdf
You don't have to read _everything_ in these chapters, especially chapters 5 and 6, but at the very least you need to know the difference between artificial spiking cells and biophysical model cells. This means you need to know about sections, distributed mechanisms (density mechanisms) and point processes, how NEURON deals with spike-triggered synaptic transmission, the ExpSyn (and Exp2Syn) synaptic mechanisms, and the various "IntFire" artificial spiking cell classes.

Then decide whether you want to make a network that uses artificial spiking cells (very easy because you won't have to learn much more) or whether you'd rather make a network that uses "biophysical model cells"--integrate and fire cells that are implemented with sections (slightly more difficult because you will need to know just a bit more). If you decide to make a network that uses artificial spiking cells, you can do everything with the Network Builder. To learn how, work through the Network Builder tutorials at http://www.neuron.yale.edu/neuron/docs

If you want to make a network of integrate and fire cells that are implemented with sections, you can still do everything with the Network Builder. First, get the NEURON code from ModelDB entry 83319, expand the zip file, and get the spikeout.mod file from the coba subdirectory. You should insert that mechanism into your single compartment model cell that you construct with the Network Builder.

If you want to do everything by writing code, ignoring the Network Builder, and you don't know much about NEURON, it's best to start with code that works, not try to write your own stuff from scratch. The coba subdirectory of the NEURON code from ModelDB entry 83319 contains code (including a template, which is in cobacell.hoc) that defines an integrate and fire cell class that is implemented with a single compartment model cell class that uses a section. The cuba subdirectory contains code (including a template, which is in cubacell.hoc) that defines an integrate and fire cell class that is implemented with an artificial spiking cell. All you'd have to do is create a couple of instances of these cell classes and connect them. And, of course, you'd have to provide some kind of stimulus to your network to make at least one of the cells fire one or more spikes--you could do that with one or two NetStims. For example, something like this should work to make a simple net that uses "biophysical model cells":

Code: Select all

load_file("nrngui.hoc")
load_file("cobacell.hoc") // now the CobaCell class has been defined

///// create cell instances
objref cells
cells = new List()
proc create_cells() { local i
  for i=0,$1-1 cells.append(new CobaCell())
}

///// connect the instances
objref nclist
nclist = new List()
// $1 is index of presynaptic cell
// $2 is index of postsynaptic cell
// $3 is index of synapse on target cell
proc connect_cells() { localobj nc
  nc = cells.o($1).connect2target(cells.o($2).synlist.o($3))
  nclist.append(nc)
}
// make first cell excite 2nd cell
// and 2nd cell inhibit first cell
connect_cells(0, 1, 0)
connect_cells(1, 0, 1)
// don't forget to specify the weights and delays of the NetCons in nclist!

///// create a source of afferent spikes that will drive the network
objref ns, afferent
ns = new NetStim()
  // don't forget to specify properties of NetStim()!
afferent = new NetCon(ns, cells.o(0).synlist.o(0))
  // don't forget to specify properties of this NetCon!

///// capture spike times and plot them
// left as an exercise to the reader
// --see examples of raster plot code in the NEURON Forum
tsang

Re: simple integrate and fire neuron network

Post by tsang »

Hi Ted,

Thanks a lot for your detailed explanation. I think I'm getting the idea. Thank you.

I just have some trouble make mod.file work. How do I load it? I can open it with wordpad and see the code, but how come I can't load and make it work? Could you please help me? I have read the Chapter 9 on NEURON Book, but still, it doesn't say how to load the file.

For example, when I try to load init.hoc file, it produces error message says SpikeOut is not a template.

Thank you for your help.



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

Re: simple integrate and fire neuron network

Post by ted »

On the FAQ page http://www.neuron.yale.edu/neuron/faq/general-questions look for the item
How do I compile mod files?
The second edition of the NEURON Book will contain this information.
tsang

Re: simple integrate and fire neuron network

Post by tsang »

Hi Ted,

Thanks again for your kind help.

I now built up the folder just like the form for CubaCell from that ModelDB. I used the code from NEURON book about IntFire1 rather than InrFire3.

Here is the code for my "if1.mod" file, according to NEURON book.

Code: Select all

    NEURON {
	ARTIFICIAL_CELL IntFire1
	RANGE tau, m, refrac
}

PARAMETER { 
  tau = 10 (ms)
  refrac = 5 (ms)
}

ASSIGNED {
  m
  t0 (ms)
  refractory (ms)
}

INITIAL {
  m = 0
  t0 = 0
  refractory = 0
}

NET_RECEIVE (w) {
  if (refractory == 0) {
    m = m*exp(-(t - t0)/tau)
    m = m + w
    t0 = t
    if (m > 1) {
       net_event(t)
       refractory = 1
       net_send(refrac, refractory)
    }
  } else if (flag == 1) {
     : self-event arrived, so terminate refractory period
    refractory = 0
    m = 0
    t0 = t
  } : else ignore the external event  
}

FUNCTION M() {
  if (refractory == 0) {
    M = m*exp(-(t - t0)/tau)
  } else if (refractory == 1) {
    if (t-t0 < 0.5) {
      M = 2
    } else {
      M = -1
    }
  }
}
Also, I used IntFire1 cell property to built up the cell file named art_cell.hoc, code as below:

Code: Select all

obfunc newcell() {localobj cell
        cell =  new IntFire1()
        cell.tau = 10
        cell.refrac = 5
        return cell
}
Then I built similar structure like CubaCell folder, init.hoc, intrinsic.hoc, etc. Also built up model with mknrndll, but when I run with NEURON, nothing comes out, I got a message on main window says: loading membrane mechanism from nrnmech.dll, Additional mechanisms from files if1.mod. The user defined name, IntFire1, already exists. NEURON exists abnormally, press return to quit.



Could you please help me what the problem is? Thanks a lot.
ted
Site Admin
Posts: 6300
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: simple integrate and fire neuron network

Post by ted »

NEURON has a built-in artificial spiking cell mechanism called IntFire1. Why aren't you using that? It does everything that the example from the NEURON Book does, and it has the advantage of being kept up to date, whereas the example in the NEURON Book hasn't been updated in 7 years. And you can use it without having to compile any NMODL code.
Post Reply