HOW TO omit the start and end points in a vertor

The basics of how to develop, test, and use models.
Post Reply
melissamou
Posts: 38
Joined: Fri Aug 27, 2010 7:23 am

HOW TO omit the start and end points in a vertor

Post by melissamou »

Dear Ted,
i want to add extracellular potetial at the internodes of each segment of my axon model, first i compute xyz coordinates of those nodes, the code is according yours "interpxyz". but i don't insert xtra, so i use vertor to put the xyz coordinates, and i use append to put together, but the 0 and 1 ends of each segment are also included, how to omit these two points in my code? the following is my code. thank you a million.

Code: Select all

proc grindaway() { local ii, nn, kk, xr
	forsec neurite{
	 		// get the data for the section
		nn = n3d()
		xx = new Vector(nn)
		yy = new Vector(nn)
		zz = new Vector(nn)
		length = new Vector(nn).........
                                ......
                                ......
		xint = new Vector(nseg+2)
		yint = new Vector(nseg+2)
		zint = new Vector(nseg+2)
		xint.interpolate(range, length, xx)
		yint.interpolate(range, length, yy)
		zint.interpolate(range, length, zz)

		[color=#BF80FF]
                                x_model=new Vector()
                                y_model=new Vector()
                                z_model=new Vector()

                                x_model.append(xint)	
                                y_model.append(yint)	
                                z_model.append(zint)[/color]	
}	
// Write location information to files	
	f = new File("D:/home/Model2/my model2/coordinate/x_loca1.dat")
	f.wopen()
	x_model.vwrite(f)
	f.close()
	
	f = new File("D:/home/Model2/my model2/coordinate/y_loca1.dat")
	f.wopen()
	y_model.vwrite(f)
	f.close()
	
	f = new File("D:/home/Model2/my model2/coordinate/z_loca1.dat")
	f.wopen()
	z_model.vwrite(f)
	f.close()
}
ted
Site Admin
Posts: 6299
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: HOW TO omit the start and end points in a vertor

Post by ted »

i want to add extracellular potetial at the internodes of each segment of my axon model
In the context of NEURON (and other compartmental simulators) I know what a node is. But what is an "internode"?

Are you concerned that the "highlighted" code won't produce vectors that contain copies of the contents of the *int vectors? If you need reassurance that they are exact copies, insert some diagnostic code that compares the originals and the copies and prints an error message (and stops program execution) if there is a difference.

Code: Select all

f = new File("D:/home/Model2/my model2/coordinate/x_loca1.dat")
This will ensure that your code fails dramatically when anyone else tries it on their own computer. It is a bad idea to use paths that are specific to a particular operating system; collaborators who use different operating systems will not be able to run the code. It is also a mistake to use paths that refer to locations that lie outside of the directory subtree whose root contains the model source code; such directories are likely to exist only on your computer, and not on anyone else's. Finally, it is not good programming practice to embed a literal string deep inside a program; this needlessly complicates program maintenance. You can fix this last problem by defining a few strings near the top of your source code, e.g.
strdef infilename, outfilename
infilename = "nameofinputfile.dat" // or whatever it is called
outfilename = "nameofoutputfile.dat"
and then using infilename and outfilename in the body of your program.
melissamou
Posts: 38
Joined: Fri Aug 27, 2010 7:23 am

Re: HOW TO omit the start and end points in a vertor

Post by melissamou »

Thanks very much for your advice, i will use it in my code.
sorry, the internode is a mistake, i want to say the center of each segment. in your model"extracellular_stim_and_rec",there is a hoc" interpxyz.hoc", say

Code: Select all

// for each node, assign the xyz values to x_xtra, y_xtra, z_xtra
//		for ii = 0, nseg+1 {
// don't bother computing coords of the 0 and 1 ends
// also avoid writing coords of the 1 end into the last internal node's coords
		for ii = 1, nseg {
			xr = range.x[ii]
			x_xtra(xr) = xint.x[ii]
			y_xtra(xr) = yint.x[ii]
			z_xtra(xr) = zint.x[ii]
}
however in my project i didn't use Xtra, so i can't use x_xtra, y_xtra, z_xtra, that's the reason i define new vector as x_model, y_model, z_model to save the xyz coordinates. but i don't know how to omit the coords of the 0 and 1 ends .

Code: Select all

    x_model=new Vector()
                                y_model=new Vector()
                                z_model=new Vector()

                                x_model.append(xint)   
                                y_model.append(yint)   
                                z_model.append(zint)
do you have any advice?
thanks
ted
Site Admin
Posts: 6299
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: HOW TO omit the start and end points in a vertor

Post by ted »

melissamou wrote:i don't know how to omit the coords of the 0 and 1 ends
Well, you could do this for each vector: just copy elements 1 through nseg. Example:
x_model = xint.c(1,xint.size()-2)
melissamou
Posts: 38
Joined: Fri Aug 27, 2010 7:23 am

Re: HOW TO omit the start and end points in a vertor

Post by melissamou »

Cheers,now it work, i modify the code like this:

Code: Select all

x_model.append(xint.c(1,xint.size()-2))   
                                y_model.append(xint.c(1,xint.size()-2))   
                                z_model.append(xint.c(1,xint.size()-2))
the result is correct then,
thank you very much.
Post Reply