Hi, your suggestions are giving me useful ideas to test but I am still thoroughly confused on this issue.
Below (1) is the relevant code that was exported out of the cellbuild tool after I imported a .swc, and then exported to cell builder made subsets and saved as .hoc
Based on this code, I have redesigned a template further below (2) that also includes subsets and biophysics, then further below again I made a procedure (3) which tries to change the biophysics of sections in already instantiated cells. None of the approaches work.
(Note in the template below I have not designed the biophysics to be realistic I only inserted different mechanisms for each subsection so that they where distinuishable for debugging subsets and biophysics togethor).
Code: Select all
//(1)
proc subsets() { local i
objref all, somatic, axonal, basal, apical
all = new SectionList()
soma all.append()
/* for i=0, 44 dend[i] all.append()
for i=0, 321 axon[i] all.append()
for i=0, 16 apic[i] all.append() */
somatic = new SectionList()
soma somatic.append()
axonal = new SectionList()
// for i=0, 321 axon[i] axonal.append()
basal = new SectionList()
// for i=0, 44 dend[i] basal.append()
apical = new SectionList()
// for i=0, 16 apic[i] apical.append()
}
proc biophys() {
forsec somatic {
insert Nasoma
insert somacar
}
forsec axonal {
insert Kaxon
}
forsec basal {
insert nmda
}
forsec apical {
insert pas
g_pas = 0.001
e_pas = -70
insert Nadend
}
}
access soma
Below I used the general idea from above and tried to make some subsets that might be generalisable in the cell template below.
I think what you are saying is. Since the morphology and cell template are separated, you can make an abstract subsets in the template and no indexs are required to be known, since the morphology doesn't exist at this point.
And then when the morphology is imported at about the same point the cell is instantiated, the sections from the morphology can be made to belong to abstract subsets from the cell template.
I wonder why the line: execute("forall delete_section()",cell) at (2) is necessary since no sections have been made yet?
Code: Select all
obfunc mkcell() { localobj import, morph, cell
cell = new Cell()
morph = new Import3d_SWC_read()
morph.input($s1)
import = new Import3d_GUI(morph, 0)
execute("forall delete_section()", cell) //(2)
import.instantiate(cell)
return cell
}
objref cell1, cell2, CELLSgr[45], CELLSp[73], CELLSbask[55], CELLSgl[1], CELLSch[3], shape
/* Granule cell
Turner
Rat
Hippocampus */
CELLSgr[0]=mkcell("n220.CNG.swc")
//////////////////////
Code: Select all
//The code above is instantiating a template like the following:
//(2)
begintemplate Cell
public soma, axon, apic, nclist, dend, syn
create soma[1], axon[1], dend[1], apic[1]
objectvar f, nclist
public all, somatic, axonal, apical, dends, basal
objref all, somatic, axonal, apical, dends, basal
proc biophys() {
forall { insert hha2}
somatic {
insert Ih
}
axonal {
insert Kaxon
}
dends{
insert IA
}
basalar {
insert Nadend
}
apical {
insert hha2
}
}
geom_nseg() {
forsec somatic { nseg = 5 }
forsec axonal { nseg = 5 }
forsec basal { nseg = 5 }
forsec apical { nseg = 5 }
// soma { nseg = 10 }
}
proc subsets() {objref all, somatic, axonal, basalar, apical, dends
all = new SectionList()
somatic = new SectionList()
soma somatic.append()
soma all.append()
axonal = new SectionList()
axon axonal.append()
axon all.append()
dends = new SectionList()
dend dends.append()
apical = new SectionList()
apic apical.append()
apic dends.append()
apic all.append()
basalar = new SectionList()
basal basalar.append()
dend dends.append()
basal all.append()
}
proc init() {
somatic = new SectionList()
axonal = new SectionList()
basalar = new SectionList()
dends = new SectionList()
apical = new SectionList()
nclist = new List()
geom_nseg()
subsets()
biophys()
}
After I have run the batch import script I try the tests:
Code: Select all
oc>Cell[175].apical psection()
oc>Cell[175].dends psection()
both return information not about cell[175] but instead about Cell[0].soma which somehow got all of the mechanisms inserted into
it from all of the subsets above, not just the somatic one which is puzzeling.
An example from a similar file produced:
Code: Select all
oc>Cell[175].axonal psection()
yields:
Cell[0].axon[0] { nseg=100 L=100 Ra=35.4
/*location 0 attached to cell 0*/
/* First segment only */
insert capacitance { cm=1}
insert morphology { diam=500}
insert Kaxon {}
insert Nadend {}
insert IA {}
insert Ih {}
insert hha2 {}
insert hh { gnabar_hh=0.12 gkbar_hh=0.036 gl_hh=0.0003 el_hh=-54.3}
insert na_ion { ena=50}
insert k_ion { ek=-77}
}
I also made a procedure outside the cell template that is supposed to insert mechanisms into already instantiated cell objects however it doesn't really work.
Code: Select all
//(3)
proc dendrites2() {
forsec $o1.dends { insert hh }
forsec $o1.dends { insert Kaxon }
$o1.dends { insert Naaxon }
$o1.dends { insert hNa }
$o1.dends { insert hh }
$o1.dends { insert Ih }
$o1.dends { insert Kdend }
}
//function call to test
for i=170,175 { dendrites2(Cell[i]) }
oc>Cell[170].dends psection()
If I used an approach like this on already instantiated objects I don't understant how I could do it without knowing all of the indexs. As I don't know any statements that are flexible enough to accomodate these changing size section arrays without using indexs.
I have noticed that the statement :
Code: Select all
forall $o1.dends { insert Kaxon }
reliably changes every section listed in psection(), but it is a bit useless to do that since you lose the specifity of subsets which is obviously the whole point.
Also I can't find any .hoc code for the implementation of the topology() function. I thought this would be helpful since it somehow is able to iterate the length of section arrays without exceeding the size and causing an error as a corollary. Am I wrong to assume that topology() would be in the directory:
/usr/local/nrn/share/nrn/lib/hoc/
?
I tried $grep -r 'topology' /usr/local/nrn/share/nrn/lib/hoc/
But I couldn't find anything relevant.
I suspected that the file might be similar:
celbild/celtopol.hoc
?
Thanks so much for anyhelp.
R