How to return an objref for a point process in a new class

The basics of how to develop, test, and use models.
Post Reply
Bill Connelly
Posts: 86
Joined: Thu May 22, 2008 11:54 pm
Location: Australian National University

How to return an objref for a point process in a new class

Post by Bill Connelly »

Because I need to create synapses of the fly, I have tried making a synapse class. In order to return the reference to the synapse point process, I have made a seperate function in the synapse class that returns it:

Code: Select all

begintemplate cell
public soma, connect2target....
proc init() {
...
}
  obfunc connect2target() { localobj nc //$o1 target point process, optional $o2 returned NetCon
    soma nc = new NetCon(&v(1), $o1)
    nc.threshold = 0
    if (numarg() == 2) { $o2 = nc } // for backward compatibility
    return nc
  }
endtemplate cell

begintemplate autapse
  public callAutapse
  objref tempsyn

  proc init() {
    objref tempsyn
    $o1.soma tempsyn = new ExpSyn(0.5)
    tempsyn.e = -75
    tempsyn.tau = 6
  }
  
  obfunc callAutapse() {
    return tempsyn
  }
endtemplate autapse

objref cl
cl = new List()
for i = 0, ncells-1 {
  cl.append(new cell())
}

objref autlist, autsyn
autlist = new List()
autsyn = new List()



proc MakeAutapses() { localobj asyn, a, aindex
  for n = 0, ncells-1 {
    a = new autapse(cl.o(n))
    aindex = a.callAutapse()    
    autlist.append(aindex)
    asyn = cl.o(n).connect2target(aindex)
    asyn.weight = 0.02
    asyn.delay = 2
    autsyn.append(asyn)
  }
}
Do you feel that using a seperate function (callAutapse) to return the objref for the newly created autaptic synapse is a reasonable move? (if init was allowed to be a obfunc I wouldn't have this problem). If not, how would you do it?
ted
Site Admin
Posts: 5819
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: How to return an objref for a point process in a new class

Post by ted »

If there is to be more than one such synaptic mechanism, I'd probably
1. declare
public synlist
objref synlist
at the top of the template
2. each time a new synaptic mechanism is created, append it to synlist

If there's only going to be one synaptic mechanism per cell, I'd declare
public syn
objref syn
at the top of the template, and use syn as the objref for the newly created synaptic mechanism.
Post Reply