Page 1 of 1

How to connect multiple compartments of an axon using a for loop?

Posted: Tue Jan 28, 2020 1:19 am
by zyousuf
So I have an axon which has a 1000 compartments. I have written a for loop that connects the [1] part of one compartment to the [0] of the other and so on until all 1000 compartments are connected. However, I then get the following error: "axon_1[0] connection will form loop
in axon_diam_part2.hoc near line 23". Could anyone help me debug this part of my code? Would really appreciate!!

Code:

numParts =1000
create axon_1[numParts] //axon of 10 um diameter
access axon_1
for (i=0; i<numParts; i=i+1){
axon_1{
length=100
diam=10
Rm=40000 //ohm-cm^2
Ra=200 //ohm-cm
insert hh //Inserting Hodgkin Huxley
}
}

for (i=0; i<numParts; i=i+1){
connect axon_1[i-1](1), axon_1(0) // connects end of axon[0] to start of axon[1]
}

//Inserting stimulus for axon 1
objectvar mystim // This is a variable name
axon_1 mystim = new IClamp(0) // Inserting current stim at start of axon
mystim.del = 100 // ms, Delay until stim turns on
mystim.dur = 100 // ms, How long stim stays on
mystim.amp = 9 // nA, from inside to outside membrane
tstop = 300 // ms, defaults to 5

Re: How to connect multiple compartments of an axon using a for loop?

Posted: Tue Jan 28, 2020 1:28 am
by zyousuf
EDIT: For some reason, it isn't showing here that there is an i in square brackets next to the axon_1(0). It's present in my code though. I'm really confused why this isn't working.

for (i=0; i<numParts; i=i+1){
connect axon_1[i-1](1), axon_1(0) // connects end of axon[0] to start of axon[1]
}

Re: How to connect multiple compartments of an axon using a for loop?

Posted: Tue Jan 28, 2020 12:39 pm
by ted
Could anyone help me debug this part of my code?
Do you think the task might be simpler if you used a million "compartments" (sections, actually)? Or maybe it would be easier to figure out what went wrong if you tried just 3.

Re: How to connect multiple compartments of an axon using a for loop?

Posted: Tue Jan 28, 2020 12:43 pm
by ted
For some reason, it isn't showing here that there is an i in square brackets next to the axon_1(0).
Why don't you use the Forum's markup features? Those little buttons above the big edit field include one that is used to wrap blocks of code. Maybe read about this in the Forum's FAQ list, under "Formatting".