// to parse the morphology data, then calculate the distance from the soma // implemented by Kai Du, kai.du@ki.se function findChildrenElements (parent) str parent, msgtype , list int num1,num2, numRaxial,numAxial, i list = "" num1 = {getmsg {parent} -out -count} // count the total outcoming msgs numbers num2 = {getmsg {parent} -in -count} // incoming // this is the ending compartment, // so it has NO child comparment and return -1 if ((num1==1) && (num2==1)) return {list} end // if it is not the ending compartment for (i=0;i< num1 ; i=i+1) msgtype = {getmsg {parent} -out -type {i}} // find the msg-type corresponding to the msg-index number if ({msgtype} == "AXIAL" ) // we only need the msg sending to its "child" compartments list = {list}@" "@{getmsg {parent} -out -destination {i}} // note: we need a SPACE !! end // end of if end // end of for return {list} end function deleteLastNode(nodelist) str nodelist, list, node int num,i list = "" num = {getarg {arglist {nodelist}} -count} if({num == 0}) echo the nodelist is NULL return // elif({num} == 1) // return {list} else for (i=1;i0) // echo "" // echo the parent compt is {parent} and the number of nodes is {num2} //we first find what is/are the next child compartment(s) list2 = {findChildrenElements {parent}} // echo the child compartment of {parent} is {list2} // count the total number of child-compartment(s) num1 = {getarg {arglist {list2}} -count} // echo num1 is {num1} /***************************************************/ /***if this is an ending compartment, we do:********/ /***************************************************/ if ({num1} == 0 ) parent = {getarg {arglist {nodes}} -arg {num2}} // switch to the last node in the list // echo there are {num2} nodes in the list // echo {child} is an end compartment, so it switches to {parent} /*****************************************************/ // if this is a single child compartment, we do: /*****************************************************/ elif ({num1} == 1) child = {arglist {list2}} findDistance {parent} {child} // (1) calculation of distance parent = {child} // (2) update the parent compartment echo this is a single compt, so it switches to next one /********************************************************/ // if this is a bifurcation /*******************************************************/ elif ({num1} > 1) i=1 child = {getarg {arglist {list2}} -arg {i}} // we choose the first one // echo we now work on {child}!! position1 = {getfield {child} position} //adding this node into the node-list if the first child-compartment is not visited if ({position1} ==0) // echo the {child} has not been visited! nodes = {nodes}@" "@{parent} // echo add the parent nodes {parent} into the node-list findDistance {parent} {child} parent = {child} // echo updated parent compartment {parent} end // if this compartment has already been visited, then move to the next one // "position > 0" meaning this one has been visited while({ position1 > 0}&&({i}<={num1})) // echo {child} has been visited // echo i is {i} and num1 is {num1} if({i0) parent = {getarg {arglist {nodes}} -arg {num2}} // switch to the last node in the list end end // end of if i=i+1 end // end of while end // end of if num2 = {getarg {arglist {nodes}} -count} end // end of while //n=n+1 //end // end // end of foreach end function checkSet(cellpath) str cellpath,compt, badCompts float position1 int i=0 badCompts = "" foreach compt ({el {cellpath}/##[TYPE=compartment]}) position1 = {getfield {compt} position} if ({position1}==0) badCompts = {badCompts}@" "@{compt} i=i+1 end end //return {i} return {badCompts} end //#################################################################################################### function add_exSyns_evenly(cellpath,a,b,number) // number: num of AMPA/NMDA per compartment str cellpath,compt,NMDAname,AMPAname float a,b,position int number,i float AMPAcond = 170e-12 float NMDAcond = 470e-12 str buffer1 = "Ca_difshell_1" // name of the calcium pool in the spine str buffer2 = "Ca_difshell_2" str buffer3 = "Ca_difshell_3" // only to record NMDA-dependent [Ca] foreach compt ({el {cellpath}/##[TYPE=compartment]}) position={getfield {compt} position} if ({position>=a} && {position=a} && {position b) echo You set a WRONG boundary of a and b (add_CaShell) return end //************************* End Warnings ********************************** foreach compt ({el {cellpath}/##[TYPE=compartment]}) //************** Begin external if statement***************************** if (!{{compt} == {{cellpath}@"/axIS"} || {compt} == {{cellpath}@"/ax"}}) dia = {getfield {compt} dia} position = {getfield {compt} position} echo the position of this compt is {position} len = {getfield {compt} len} Rm = {getfield {compt} Rm} Cm = {getfield {compt} Cm} Ra = {getfield {compt} Ra} if ({{getpath {compt} -tail} == "soma"}) len = dia end //************** Begin internal if statement************************** //if the compartment is not a spine and its position is between [a,b] if ({position >= a} && {position < b} ) len2 = len*{pow {F} {2.0/3.0}} dia2 = dia*{pow {F} {1.0/3.0}} Rm2 = Rm*(dia*len/(dia2*len2)) echo the old Rm is {Rm} and the new Rm is {Rm2} Cm2 = Cm*(dia2*len2/(dia*len)) //Cm2 = Cm*10 echo the old Cm is {Cm} and the new Cm is {Cm2} Ra2 = Ra*(len2*dia*dia/(len*dia2*dia2))*F2 echo the old Ra is {Ra} and the new Ra is {Ra2} setfield {compt} dia {dia2} setfield {compt} len {len2} setfield {compt} Rm {Rm2} setfield {compt} Cm {Cm2} setfield {compt} Ra {Ra2} end end end // end of foreach... end