/* Copyright (c) 2015 EPFL-BBP, All rights reserved.
THIS SOFTWARE IS PROVIDED BY THE BLUE BRAIN PROJECT ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE BLUE BRAIN PROJECT
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This work is licensed under a
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
To view a copy of this license, visit
http://creativecommons.org/licenses/by-nc-sa/4.0/legalcode or send a letter to
Creative Commons, 171 Second Street, Suite 300,
San Francisco, California, 94105, USA.
*/
/*
* @file template.hoc
* @brief Main cell template of the simulation
* @author James King, Werner Van Geit @ BBP
* @date 2015
*/
{load_file("morphology.hoc")}
{load_file("biophysics.hoc")}
/** Main cell template */
begintemplate cADpyr229_L23_PC_5ecbf9b163
public init
public soma, dend, apic, axon
public all, somatic, apical, axonal, basal
public nSecSoma, nSecApical, nSecBasal, nSecAxonal, nSecAll, nSecAxonalOrig
public SecSyn, distribute_channels
public morphology
public re_init_rng
public locateSites, getLongestBranch
objref SecSyn, this
objref all, somatic, apical, axonal, basal
strdef tstr
objref rngList, rng
proc init() { local synapses_enabled
// Create sectionlists to contain all the zones in the cell
all = new SectionList()
somatic = new SectionList()
basal = new SectionList()
apical = new SectionList()
axonal = new SectionList()
// Make sure we start from a clean sheet
forall delete_section()
// Load the morphology
load_morphology()
// Set the number of compartments per section (2 per 40 mum)
geom_nseg(40)
// Initialise the biophysics
biophys()
forsec this.all {
if(diam == 0){
diam = 1
printf("Error : Morphology problem with section [%s] 0 diam \n", \
secname())
}
}
}
create soma[1], dend[1], apic[1], axon[1]
/** Iterate over the section and compute how many segments should be allocate
to each.
Arguments:
chunkSize: int, for every chunkSize length at 2 compartments, default 40
*/
proc geom_nseg() { local secIndex, chunkSize
chunkSize = 40
if( numarg() > 0 ) {
chunkSize = $1
}
soma area(.5) // make sure diam reflects 3d points
secIndex=0
forsec all {
nseg = 1 + 2*int(L/chunkSize)
secIndex = secIndex+1
}
}
/** Initialise biophysics */
proc biophys() {localobj bp
// Replace the axon with a stub axon
replace_axon()
// Initialise distance function to soma
access soma
distance()
// Run the biophysics function from the template
bp = new cADpyr229_biophys_1()
bp.biophys(this)
}
/** Load the morphology */
proc load_morphology() {localobj m
m = new morphology_5ecbf9b163()
m.morphology(this)
}
/** Replace the axon built from the original morphology file with a stub axon.
The stub axon will attempt to use diam info from original axon and L=30.
*/
proc replace_axon(){ local nSec, D1, D2, dist, count
// preserve the number of original axonal sections
nSec = 0
forsec axonal{nSec = nSec + 1}
// Try to grab info from original axon
if (nSec == 0) { //No axon section present
D1 = D2 = 1
} else {
access axon[0]
D1 = D2 = diam
if( nSec > 1 ) { //More than one axon section present
access soma distance() //to calculate distance from soma
count = 0
// loop through all axon sections and check for 60um distance
forsec axonal {
count = count + 1
dist = distance(0.5)
// if section is longer than 60um then store diam
// and exit from loop
if( dist > 60 ) {
D2 = diam
break
}
}
}
}
// Delete old axon
forsec axonal{delete_section()}
// And create new one
execute1("create axon[2]\n", this)
// Set dimensions of new axon, and append sections to sectionlists
access axon[0] {
L = 30
diam = D1
nseg = 1 + 2*int(L/40)
all.append()
axonal.append()
}
access axon[1] {
L = 30
diam = D2
nseg = 1 + 2*int(L/40)
all.append()
axonal.append()
}
nSecAxonal = 2
// Connect sections to each other and to soma
soma[0] connect axon[0](0), 1
axon[0] connect axon[1](0), 1
access soma
}
/** (Re)initialise random number generators for stochastic channels
Arguments:
gid: int, global identifier of the cell
*/
proc re_init_rng() {local channelID
objref rng
rngList = new List()
channelID = 0
forsec this.somatic {
for (x, 0) {
// Initialise the random number generator
rng = new Random()
// Set the seeds to a value that depends on the gid of the cell
// and the channelid within the cell
rng.MCellRan4( channelID*10000+100, $1*10000+250+1 )
channelID = channelID + 1
// Set to uniform distribution
rng.uniform(0,1)
// Pass rng to stochastic channel
setdata_StochKv(x)
setRNG_StochKv(rng)
// Store the rngs in a list for persistency
rngList.append(rng)
}
}
forsec this.basal {
for (x, 0) {
rng = new Random()
rng.MCellRan4( channelID*10000+100, $1*10000+250+1 )
channelID = channelID + 1
rng.uniform(0,1)
setdata_StochKv(x)
setRNG_StochKv(rng)
rngList.append(rng)
}
}
forsec this.apical {
for (x, 0) {
rng = new Random()
rng.MCellRan4( channelID*10000+100, $1*10000+250+1 )
channelID = channelID + 1
rng.uniform(0,1)
setdata_StochKv(x)
setRNG_StochKv(rng)
rngList.append(rng)
}
}
}
proc distribute_channels(){ localobj bp
bp = new cADpyr229_biophys_1()
bp.distribute($o1, $s2, $s3)
}
// $s1 section
func getLongestBranch(){local maxL,d localobj distallist,sref
sprint(tstr,"%s distance()",$s1)
execute(tstr,this)
if(0==strcmp($s1,"axon")){
sprint(tstr,"%s[0] distance(1)",$s1)
execute(tstr,this)
}
maxL = 0
d = 0
distallist = new SectionList()
forsec $s1 {
sref = new SectionRef()
if (sref.nchild==0) distallist.append()
}
forsec distallist{
d = distance(1)
if(maxL<d) maxL = d
}
// for the soma case
if (maxL == 0) {
$s1 {
maxL = L
}
}
return maxL
}
obfunc locateSites() {local maxL,site,d0,d1,siteX,i localobj vv,ll
ll = new List()
sprint(tstr,"%s distance()",$s1)
execute(tstr,this)
if(0==strcmp($s1,"axon")){
sprint(tstr,"%s[0] distance(1)",$s1)
execute(tstr,this)
}
maxL = getLongestBranch($s1)
site = $2
i = 0
forsec $s1 {
if (distance(0) < distance(1)) {
d0 = distance(0)
d1 = distance(1)
} else {
d1 = distance(0)
d0 = distance(1)
}
if (site <= d1 && site >= d0) {
siteX = (site-d0)/(d1-d0)
secNum = i
vv = new Vector()
ll.append(vv.append(secNum,siteX))
}
i = i+1
}
return ll
}
endtemplate cADpyr229_L23_PC_5ecbf9b163
/* Copyright (c) 2015 EPFL-BBP, All rights reserved.
THIS SOFTWARE IS PROVIDED BY THE BLUE BRAIN PROJECT ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE BLUE BRAIN PROJECT
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This work is licensed under a
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
To view a copy of this license, visit
http://creativecommons.org/licenses/by-nc-sa/4.0/legalcode or send a letter to
Creative Commons, 171 Second Street, Suite 300,
San Francisco, California, 94105, USA.
*/
/*
* @file template.hoc
* @brief Main cell template of the simulation
* @author James King, Werner Van Geit @ BBP
* @date 2015
*/
{load_file("morphology.hoc")}
{load_file("biophysics.hoc")}
/** Main cell template */
begintemplate cADpyr229_L23_PC_8ef1aa6602
public init
public soma, dend, apic, axon
public all, somatic, apical, axonal, basal
public nSecSoma, nSecApical, nSecBasal, nSecAxonal, nSecAll, nSecAxonalOrig
public SecSyn, distribute_channels
public morphology
public re_init_rng
public locateSites, getLongestBranch
objref SecSyn, this
objref all, somatic, apical, axonal, basal
strdef tstr
objref rngList, rng
proc init() { local synapses_enabled
// Create sectionlists to contain all the zones in the cell
all = new SectionList()
somatic = new SectionList()
basal = new SectionList()
apical = new SectionList()
axonal = new SectionList()
// Make sure we start from a clean sheet
forall delete_section()
// Load the morphology
load_morphology()
// Set the number of compartments per section (2 per 40 mum)
geom_nseg(40)
// Initialise the biophysics
biophys()
forsec this.all {
if(diam == 0){
diam = 1
printf("Error : Morphology problem with section [%s] 0 diam \n", \
secname())
}
}
}
create soma[1], dend[1], apic[1], axon[1]
/** Iterate over the section and compute how many segments should be allocate
to each.
Arguments:
chunkSize: int, for every chunkSize length at 2 compartments, default 40
*/
proc geom_nseg() { local secIndex, chunkSize
chunkSize = 40
if( numarg() > 0 ) {
chunkSize = $1
}
soma area(.5) // make sure diam reflects 3d points
secIndex=0
forsec all {
nseg = 1 + 2*int(L/chunkSize)
secIndex = secIndex+1
}
}
/** Initialise biophysics */
proc biophys() {localobj bp
// Replace the axon with a stub axon
replace_axon()
// Initialise distance function to soma
access soma
distance()
// Run the biophysics function from the template
bp = new cADpyr229_biophys_2()
bp.biophys(this)
}
/** Load the morphology */
proc load_morphology() {localobj m
m = new morphology_8ef1aa6602()
m.morphology(this)
}
/** Replace the axon built from the original morphology file with a stub axon.
The stub axon will attempt to use diam info from original axon and L=30.
*/
proc replace_axon(){ local nSec, D1, D2, dist, count
// preserve the number of original axonal sections
nSec = 0
forsec axonal{nSec = nSec + 1}
// Try to grab info from original axon
if (nSec == 0) { //No axon section present
D1 = D2 = 1
} else {
access axon[0]
D1 = D2 = diam
if( nSec > 1 ) { //More than one axon section present
access soma distance() //to calculate distance from soma
count = 0
// loop through all axon sections and check for 60um distance
forsec axonal {
count = count + 1
dist = distance(0.5)
// if section is longer than 60um then store diam
// and exit from loop
if( dist > 60 ) {
D2 = diam
break
}
}
}
}
// Delete old axon
forsec axonal{delete_section()}
// And create new one
execute1("create axon[2]\n", this)
// Set dimensions of new axon, and append sections to sectionlists
access axon[0] {
L = 30
diam = D1
nseg = 1 + 2*int(L/40)
all.append()
axonal.append()
}
access axon[1] {
L = 30
diam = D2
nseg = 1 + 2*int(L/40)
all.append()
axonal.append()
}
nSecAxonal = 2
// Connect sections to each other and to soma
soma[0] connect axon[0](0), 1
axon[0] connect axon[1](0), 1
access soma
}
/** (Re)initialise random number generators for stochastic channels
Arguments:
gid: int, global identifier of the cell
*/
proc re_init_rng() {local channelID
objref rng
rngList = new List()
channelID = 0
forsec this.somatic {
for (x, 0) {
// Initialise the random number generator
rng = new Random()
// Set the seeds to a value that depends on the gid of the cell
// and the channelid within the cell
rng.MCellRan4( channelID*10000+100, $1*10000+250+1 )
channelID = channelID + 1
// Set to uniform distribution
rng.uniform(0,1)
// Pass rng to stochastic channel
setdata_StochKv(x)
setRNG_StochKv(rng)
// Store the rngs in a list for persistency
rngList.append(rng)
}
}
forsec this.basal {
for (x, 0) {
rng = new Random()
rng.MCellRan4( channelID*10000+100, $1*10000+250+1 )
channelID = channelID + 1
rng.uniform(0,1)
setdata_StochKv(x)
setRNG_StochKv(rng)
rngList.append(rng)
}
}
forsec this.apical {
for (x, 0) {
rng = new Random()
rng.MCellRan4( channelID*10000+100, $1*10000+250+1 )
channelID = channelID + 1
rng.uniform(0,1)
setdata_StochKv(x)
setRNG_StochKv(rng)
rngList.append(rng)
}
}
}
proc distribute_channels(){ localobj bp
bp = new cADpyr229_biophys_2()
bp.distribute($o1, $s2, $s3)
}
// $s1 section
func getLongestBranch(){local maxL,d localobj distallist,sref
sprint(tstr,"%s distance()",$s1)
execute(tstr,this)
if(0==strcmp($s1,"axon")){
sprint(tstr,"%s[0] distance(1)",$s1)
execute(tstr,this)
}
maxL = 0
d = 0
distallist = new SectionList()
forsec $s1 {
sref = new SectionRef()
if (sref.nchild==0) distallist.append()
}
forsec distallist{
d = distance(1)
if(maxL<d) maxL = d
}
// for the soma case
if (maxL == 0) {
$s1 {
maxL = L
}
}
return maxL
}
obfunc locateSites() {local maxL,site,d0,d1,siteX,i localobj vv,ll
ll = new List()
sprint(tstr,"%s distance()",$s1)
execute(tstr,this)
if(0==strcmp($s1,"axon")){
sprint(tstr,"%s[0] distance(1)",$s1)
execute(tstr,this)
}
maxL = getLongestBranch($s1)
site = $2
i = 0
forsec $s1 {
if (distance(0) < distance(1)) {
d0 = distance(0)
d1 = distance(1)
} else {
d1 = distance(0)
d0 = distance(1)
}
if (site <= d1 && site >= d0) {
siteX = (site-d0)/(d1-d0)
secNum = i
vv = new Vector()
ll.append(vv.append(secNum,siteX))
}
i = i+1
}
return ll
}
endtemplate cADpyr229_L23_PC_8ef1aa6602
/* Copyright (c) 2015 EPFL-BBP, All rights reserved.
THIS SOFTWARE IS PROVIDED BY THE BLUE BRAIN PROJECT ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE BLUE BRAIN PROJECT
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This work is licensed under a
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
To view a copy of this license, visit
http://creativecommons.org/licenses/by-nc-sa/4.0/legalcode or send a letter to
Creative Commons, 171 Second Street, Suite 300,
San Francisco, California, 94105, USA.
*/
/*
* @file template.hoc
* @brief Main cell template of the simulation
* @author James King, Werner Van Geit @ BBP
* @date 2015
*/
{load_file("morphology.hoc")}
{load_file("biophysics.hoc")}
/** Main cell template */
begintemplate cADpyr229_L23_PC_863902f300
public init
public soma, dend, apic, axon
public all, somatic, apical, axonal, basal
public nSecSoma, nSecApical, nSecBasal, nSecAxonal, nSecAll, nSecAxonalOrig
public SecSyn, distribute_channels
public morphology
public re_init_rng
public locateSites, getLongestBranch
objref SecSyn, this
objref all, somatic, apical, axonal, basal
strdef tstr
objref rngList, rng
proc init() { local synapses_enabled
// Create sectionlists to contain all the zones in the cell
all = new SectionList()
somatic = new SectionList()
basal = new SectionList()
apical = new SectionList()
axonal = new SectionList()
// Make sure we start from a clean sheet
forall delete_section()
// Load the morphology
load_morphology()
// Set the number of compartments per section (2 per 40 mum)
geom_nseg(40)
// Initialise the biophysics
biophys()
forsec this.all {
if(diam == 0){
diam = 1
printf("Error : Morphology problem with section [%s] 0 diam \n", \
secname())
}
}
}
create soma[1], dend[1], apic[1], axon[1]
/** Iterate over the section and compute how many segments should be allocate
to each.
Arguments:
chunkSize: int, for every chunkSize length at 2 compartments, default 40
*/
proc geom_nseg() { local secIndex, chunkSize
chunkSize = 40
if( numarg() > 0 ) {
chunkSize = $1
}
soma area(.5) // make sure diam reflects 3d points
secIndex=0
forsec all {
nseg = 1 + 2*int(L/chunkSize)
secIndex = secIndex+1
}
}
/** Initialise biophysics */
proc biophys() {localobj bp
// Replace the axon with a stub axon
replace_axon()
// Initialise distance function to soma
access soma
distance()
// Run the biophysics function from the template
bp = new cADpyr229_biophys_3()
bp.biophys(this)
}
/** Load the morphology */
proc load_morphology() {localobj m
m = new morphology_863902f300()
m.morphology(this)
}
/** Replace the axon built from the original morphology file with a stub axon.
The stub axon will attempt to use diam info from original axon and L=30.
*/
proc replace_axon(){ local nSec, D1, D2, dist, count
// preserve the number of original axonal sections
nSec = 0
forsec axonal{nSec = nSec + 1}
// Try to grab info from original axon
if (nSec == 0) { //No axon section present
D1 = D2 = 1
} else {
access axon[0]
D1 = D2 = diam
if( nSec > 1 ) { //More than one axon section present
access soma distance() //to calculate distance from soma
count = 0
// loop through all axon sections and check for 60um distance
forsec axonal {
count = count + 1
dist = distance(0.5)
// if section is longer than 60um then store diam
// and exit from loop
if( dist > 60 ) {
D2 = diam
break
}
}
}
}
// Delete old axon
forsec axonal{delete_section()}
// And create new one
execute1("create axon[2]\n", this)
// Set dimensions of new axon, and append sections to sectionlists
access axon[0] {
L = 30
diam = D1
nseg = 1 + 2*int(L/40)
all.append()
axonal.append()
}
access axon[1] {
L = 30
diam = D2
nseg = 1 + 2*int(L/40)
all.append()
axonal.append()
}
nSecAxonal = 2
// Connect sections to each other and to soma
soma[0] connect axon[0](0), 1
axon[0] connect axon[1](0), 1
access soma
}
/** (Re)initialise random number generators for stochastic channels
Arguments:
gid: int, global identifier of the cell
*/
proc re_init_rng() {local channelID
objref rng
rngList = new List()
channelID = 0
forsec this.somatic {
for (x, 0) {
// Initialise the random number generator
rng = new Random()
// Set the seeds to a value that depends on the gid of the cell
// and the channelid within the cell
rng.MCellRan4( channelID*10000+100, $1*10000+250+1 )
channelID = channelID + 1
// Set to uniform distribution
rng.uniform(0,1)
// Pass rng to stochastic channel
setdata_StochKv(x)
setRNG_StochKv(rng)
// Store the rngs in a list for persistency
rngList.append(rng)
}
}
forsec this.basal {
for (x, 0) {
rng = new Random()
rng.MCellRan4( channelID*10000+100, $1*10000+250+1 )
channelID = channelID + 1
rng.uniform(0,1)
setdata_StochKv(x)
setRNG_StochKv(rng)
rngList.append(rng)
}
}
forsec this.apical {
for (x, 0) {
rng = new Random()
rng.MCellRan4( channelID*10000+100, $1*10000+250+1 )
channelID = channelID + 1
rng.uniform(0,1)
setdata_StochKv(x)
setRNG_StochKv(rng)
rngList.append(rng)
}
}
}
proc distribute_channels(){ localobj bp
bp = new cADpyr229_biophys_3()
bp.distribute($o1, $s2, $s3)
}
// $s1 section
func getLongestBranch(){local maxL,d localobj distallist,sref
sprint(tstr,"%s distance()",$s1)
execute(tstr,this)
if(0==strcmp($s1,"axon")){
sprint(tstr,"%s[0] distance(1)",$s1)
execute(tstr,this)
}
maxL = 0
d = 0
distallist = new SectionList()
forsec $s1 {
sref = new SectionRef()
if (sref.nchild==0) distallist.append()
}
forsec distallist{
d = distance(1)
if(maxL<d) maxL = d
}
// for the soma case
if (maxL == 0) {
$s1 {
maxL = L
}
}
return maxL
}
obfunc locateSites() {local maxL,site,d0,d1,siteX,i localobj vv,ll
ll = new List()
sprint(tstr,"%s distance()",$s1)
execute(tstr,this)
if(0==strcmp($s1,"axon")){
sprint(tstr,"%s[0] distance(1)",$s1)
execute(tstr,this)
}
maxL = getLongestBranch($s1)
site = $2
i = 0
forsec $s1 {
if (distance(0) < distance(1)) {
d0 = distance(0)
d1 = distance(1)
} else {
d1 = distance(0)
d0 = distance(1)
}
if (site <= d1 && site >= d0) {
siteX = (site-d0)/(d1-d0)
secNum = i
vv = new Vector()
ll.append(vv.append(secNum,siteX))
}
i = i+1
}
return ll
}
endtemplate cADpyr229_L23_PC_863902f300
/* Copyright (c) 2015 EPFL-BBP, All rights reserved.
THIS SOFTWARE IS PROVIDED BY THE BLUE BRAIN PROJECT ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE BLUE BRAIN PROJECT
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This work is licensed under a
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
To view a copy of this license, visit
http://creativecommons.org/licenses/by-nc-sa/4.0/legalcode or send a letter to
Creative Commons, 171 Second Street, Suite 300,
San Francisco, California, 94105, USA.
*/
/*
* @file template.hoc
* @brief Main cell template of the simulation
* @author James King, Werner Van Geit @ BBP
* @date 2015
*/
{load_file("morphology.hoc")}
{load_file("biophysics.hoc")}
/** Main cell template */
begintemplate cADpyr229_L23_PC_c292d67a2e
public init
public soma, dend, apic, axon
public all, somatic, apical, axonal, basal
public nSecSoma, nSecApical, nSecBasal, nSecAxonal, nSecAll, nSecAxonalOrig
public SecSyn, distribute_channels
public morphology
public re_init_rng
public locateSites, getLongestBranch
objref SecSyn, this
objref all, somatic, apical, axonal, basal
strdef tstr
objref rngList, rng
proc init() { local synapses_enabled
// Create sectionlists to contain all the zones in the cell
all = new SectionList()
somatic = new SectionList()
basal = new SectionList()
apical = new SectionList()
axonal = new SectionList()
// Make sure we start from a clean sheet
forall delete_section()
// Load the morphology
load_morphology()
// Set the number of compartments per section (2 per 40 mum)
geom_nseg(40)
// Initialise the biophysics
biophys()
forsec this.all {
if(diam == 0){
diam = 1
printf("Error : Morphology problem with section [%s] 0 diam \n", \
secname())
}
}
}
create soma[1], dend[1], apic[1], axon[1]
/** Iterate over the section and compute how many segments should be allocate
to each.
Arguments:
chunkSize: int, for every chunkSize length at 2 compartments, default 40
*/
proc geom_nseg() { local secIndex, chunkSize
chunkSize = 40
if( numarg() > 0 ) {
chunkSize = $1
}
soma area(.5) // make sure diam reflects 3d points
secIndex=0
forsec all {
nseg = 1 + 2*int(L/chunkSize)
secIndex = secIndex+1
}
}
/** Initialise biophysics */
proc biophys() {localobj bp
// Replace the axon with a stub axon
replace_axon()
// Initialise distance function to soma
access soma
distance()
// Run the biophysics function from the template
bp = new cADpyr229_biophys_4()
bp.biophys(this)
}
/** Load the morphology */
proc load_morphology() {localobj m
m = new morphology_c292d67a2e()
m.morphology(this)
}
/** Replace the axon built from the original morphology file with a stub axon.
The stub axon will attempt to use diam info from original axon and L=30.
*/
proc replace_axon(){ local nSec, D1, D2, dist, count
// preserve the number of original axonal sections
nSec = 0
forsec axonal{nSec = nSec + 1}
// Try to grab info from original axon
if (nSec == 0) { //No axon section present
D1 = D2 = 1
} else {
access axon[0]
D1 = D2 = diam
if( nSec > 1 ) { //More than one axon section present
access soma distance() //to calculate distance from soma
count = 0
// loop through all axon sections and check for 60um distance
forsec axonal {
count = count + 1
dist = distance(0.5)
// if section is longer than 60um then store diam
// and exit from loop
if( dist > 60 ) {
D2 = diam
break
}
}
}
}
// Delete old axon
forsec axonal{delete_section()}
// And create new one
execute1("create axon[2]\n", this)
// Set dimensions of new axon, and append sections to sectionlists
access axon[0] {
L = 30
diam = D1
nseg = 1 + 2*int(L/40)
all.append()
axonal.append()
}
access axon[1] {
L = 30
diam = D2
nseg = 1 + 2*int(L/40)
all.append()
axonal.append()
}
nSecAxonal = 2
// Connect sections to each other and to soma
soma[0] connect axon[0](0), 1
axon[0] connect axon[1](0), 1
access soma
}
/** (Re)initialise random number generators for stochastic channels
Arguments:
gid: int, global identifier of the cell
*/
proc re_init_rng() {local channelID
objref rng
rngList = new List()
channelID = 0
forsec this.somatic {
for (x, 0) {
// Initialise the random number generator
rng = new Random()
// Set the seeds to a value that depends on the gid of the cell
// and the channelid within the cell
rng.MCellRan4( channelID*10000+100, $1*10000+250+1 )
channelID = channelID + 1
// Set to uniform distribution
rng.uniform(0,1)
// Pass rng to stochastic channel
setdata_StochKv(x)
setRNG_StochKv(rng)
// Store the rngs in a list for persistency
rngList.append(rng)
}
}
forsec this.basal {
for (x, 0) {
rng = new Random()
rng.MCellRan4( channelID*10000+100, $1*10000+250+1 )
channelID = channelID + 1
rng.uniform(0,1)
setdata_StochKv(x)
setRNG_StochKv(rng)
rngList.append(rng)
}
}
forsec this.apical {
for (x, 0) {
rng = new Random()
rng.MCellRan4( channelID*10000+100, $1*10000+250+1 )
channelID = channelID + 1
rng.uniform(0,1)
setdata_StochKv(x)
setRNG_StochKv(rng)
rngList.append(rng)
}
}
}
proc distribute_channels(){ localobj bp
bp = new cADpyr229_biophys_4()
bp.distribute($o1, $s2, $s3)
}
// $s1 section
func getLongestBranch(){local maxL,d localobj distallist,sref
sprint(tstr,"%s distance()",$s1)
execute(tstr,this)
if(0==strcmp($s1,"axon")){
sprint(tstr,"%s[0] distance(1)",$s1)
execute(tstr,this)
}
maxL = 0
d = 0
distallist = new SectionList()
forsec $s1 {
sref = new SectionRef()
if (sref.nchild==0) distallist.append()
}
forsec distallist{
d = distance(1)
if(maxL<d) maxL = d
}
// for the soma case
if (maxL == 0) {
$s1 {
maxL = L
}
}
return maxL
}
obfunc locateSites() {local maxL,site,d0,d1,siteX,i localobj vv,ll
ll = new List()
sprint(tstr,"%s distance()",$s1)
execute(tstr,this)
if(0==strcmp($s1,"axon")){
sprint(tstr,"%s[0] distance(1)",$s1)
execute(tstr,this)
}
maxL = getLongestBranch($s1)
site = $2
i = 0
forsec $s1 {
if (distance(0) < distance(1)) {
d0 = distance(0)
d1 = distance(1)
} else {
d1 = distance(0)
d0 = distance(1)
}
if (site <= d1 && site >= d0) {
siteX = (site-d0)/(d1-d0)
secNum = i
vv = new Vector()
ll.append(vv.append(secNum,siteX))
}
i = i+1
}
return ll
}
endtemplate cADpyr229_L23_PC_c292d67a2e
/* Copyright (c) 2015 EPFL-BBP, All rights reserved.
THIS SOFTWARE IS PROVIDED BY THE BLUE BRAIN PROJECT ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE BLUE BRAIN PROJECT
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This work is licensed under a
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
To view a copy of this license, visit
http://creativecommons.org/licenses/by-nc-sa/4.0/legalcode or send a letter to
Creative Commons, 171 Second Street, Suite 300,
San Francisco, California, 94105, USA.
*/
/*
* @file template.hoc
* @brief Main cell template of the simulation
* @author James King, Werner Van Geit @ BBP
* @date 2015
*/
{load_file("morphology.hoc")}
{load_file("biophysics.hoc")}
/** Main cell template */
begintemplate cADpyr229_L23_PC_c2e79db05a
public init
public soma, dend, apic, axon
public all, somatic, apical, axonal, basal
public nSecSoma, nSecApical, nSecBasal, nSecAxonal, nSecAll, nSecAxonalOrig
public SecSyn, distribute_channels
public morphology
public re_init_rng
public locateSites, getLongestBranch
objref SecSyn, this
objref all, somatic, apical, axonal, basal
strdef tstr
objref rngList, rng
proc init() { local synapses_enabled
// Create sectionlists to contain all the zones in the cell
all = new SectionList()
somatic = new SectionList()
basal = new SectionList()
apical = new SectionList()
axonal = new SectionList()
// Make sure we start from a clean sheet
forall delete_section()
// Load the morphology
load_morphology()
// Set the number of compartments per section (2 per 40 mum)
geom_nseg(40)
// Initialise the biophysics
biophys()
forsec this.all {
if(diam == 0){
diam = 1
printf("Error : Morphology problem with section [%s] 0 diam \n", \
secname())
}
}
}
create soma[1], dend[1], apic[1], axon[1]
/** Iterate over the section and compute how many segments should be allocate
to each.
Arguments:
chunkSize: int, for every chunkSize length at 2 compartments, default 40
*/
proc geom_nseg() { local secIndex, chunkSize
chunkSize = 40
if( numarg() > 0 ) {
chunkSize = $1
}
soma area(.5) // make sure diam reflects 3d points
secIndex=0
forsec all {
nseg = 1 + 2*int(L/chunkSize)
secIndex = secIndex+1
}
}
/** Initialise biophysics */
proc biophys() {localobj bp
// Replace the axon with a stub axon
replace_axon()
// Initialise distance function to soma
access soma
distance()
// Run the biophysics function from the template
bp = new cADpyr229_biophys_5()
bp.biophys(this)
}
/** Load the morphology */
proc load_morphology() {localobj m
m = new morphology_c2e79db05a()
m.morphology(this)
}
/** Replace the axon built from the original morphology file with a stub axon.
The stub axon will attempt to use diam info from original axon and L=30.
*/
proc replace_axon(){ local nSec, D1, D2, dist, count
// preserve the number of original axonal sections
nSec = 0
forsec axonal{nSec = nSec + 1}
// Try to grab info from original axon
if (nSec == 0) { //No axon section present
D1 = D2 = 1
} else {
access axon[0]
D1 = D2 = diam
if( nSec > 1 ) { //More than one axon section present
access soma distance() //to calculate distance from soma
count = 0
// loop through all axon sections and check for 60um distance
forsec axonal {
count = count + 1
dist = distance(0.5)
// if section is longer than 60um then store diam
// and exit from loop
if( dist > 60 ) {
D2 = diam
break
}
}
}
}
// Delete old axon
forsec axonal{delete_section()}
// And create new one
execute1("create axon[2]\n", this)
// Set dimensions of new axon, and append sections to sectionlists
access axon[0] {
L = 30
diam = D1
nseg = 1 + 2*int(L/40)
all.append()
axonal.append()
}
access axon[1] {
L = 30
diam = D2
nseg = 1 + 2*int(L/40)
all.append()
axonal.append()
}
nSecAxonal = 2
// Connect sections to each other and to soma
soma[0] connect axon[0](0), 1
axon[0] connect axon[1](0), 1
access soma
}
/** (Re)initialise random number generators for stochastic channels
Arguments:
gid: int, global identifier of the cell
*/
proc re_init_rng() {local channelID
objref rng
rngList = new List()
channelID = 0
forsec this.somatic {
for (x, 0) {
// Initialise the random number generator
rng = new Random()
// Set the seeds to a value that depends on the gid of the cell
// and the channelid within the cell
rng.MCellRan4( channelID*10000+100, $1*10000+250+1 )
channelID = channelID + 1
// Set to uniform distribution
rng.uniform(0,1)
// Pass rng to stochastic channel
setdata_StochKv(x)
setRNG_StochKv(rng)
// Store the rngs in a list for persistency
rngList.append(rng)
}
}
forsec this.basal {
for (x, 0) {
rng = new Random()
rng.MCellRan4( channelID*10000+100, $1*10000+250+1 )
channelID = channelID + 1
rng.uniform(0,1)
setdata_StochKv(x)
setRNG_StochKv(rng)
rngList.append(rng)
}
}
forsec this.apical {
for (x, 0) {
rng = new Random()
rng.MCellRan4( channelID*10000+100, $1*10000+250+1 )
channelID = channelID + 1
rng.uniform(0,1)
setdata_StochKv(x)
setRNG_StochKv(rng)
rngList.append(rng)
}
}
}
proc distribute_channels(){ localobj bp
bp = new cADpyr229_biophys_5()
bp.distribute($o1, $s2, $s3)
}
// $s1 section
func getLongestBranch(){local maxL,d localobj distallist,sref
sprint(tstr,"%s distance()",$s1)
execute(tstr,this)
if(0==strcmp($s1,"axon")){
sprint(tstr,"%s[0] distance(1)",$s1)
execute(tstr,this)
}
maxL = 0
d = 0
distallist = new SectionList()
forsec $s1 {
sref = new SectionRef()
if (sref.nchild==0) distallist.append()
}
forsec distallist{
d = distance(1)
if(maxL<d) maxL = d
}
// for the soma case
if (maxL == 0) {
$s1 {
maxL = L
}
}
return maxL
}
obfunc locateSites() {local maxL,site,d0,d1,siteX,i localobj vv,ll
ll = new List()
sprint(tstr,"%s distance()",$s1)
execute(tstr,this)
if(0==strcmp($s1,"axon")){
sprint(tstr,"%s[0] distance(1)",$s1)
execute(tstr,this)
}
maxL = getLongestBranch($s1)
site = $2
i = 0
forsec $s1 {
if (distance(0) < distance(1)) {
d0 = distance(0)
d1 = distance(1)
} else {
d1 = distance(0)
d0 = distance(1)
}
if (site <= d1 && site >= d0) {
siteX = (site-d0)/(d1-d0)
secNum = i
vv = new Vector()
ll.append(vv.append(secNum,siteX))
}
i = i+1
}
return ll
}
endtemplate cADpyr229_L23_PC_c2e79db05a