## Changing diameters of reconstructed neurons

Managing anatomically complex model cells with the CellBuilder. Importing morphometric data with NEURON's Import3D tool or Robert Cannon's CVAPP. Where to find detailed morphometric data.
Tuoma
Posts: 9
Joined: Mon Apr 23, 2018 6:59 am

### Changing diameters of reconstructed neurons

I have a reconstructed morphology (loaded from an .asc file), where I would like to change the diameters of the sections by some factor. Is there a neat way of doing it? For a starter, I tried

forall {
for (j = 0; j < nseg+1; j+=1 ) {
diam(j/nseg) = diam(j/nseg)*1.0
}
}

but it changed the diameter at certain points. It would do that even if I replaced nseg by a large number.

ramcdougal
Posts: 214
Joined: Fri Nov 28, 2008 3:38 pm
Location: Yale School of Public Health

### Re: Changing diameters of reconstructed neurons

Use diam3d instead of diam, and forall sections adjust indices from 0 to n3d-1, inclusive.

EDIT: The idea is right but this code is wrong. diam3d is read only and diameters most he changed with pt3dchange. See my next post.

Code: Select all

forall {
for (j = 0; j < n3d(); j+=1) {
diam3d(j) = diam3d(j)*1.0
}
}
There is a discussion at the top of the linked help page that explains all this, but in brief the functions ending with 3d are for imported morphologies which can have arbitrarily many different diameters and 3d points while the way you tried is for stylized morphologies where each segment has a uniform diameter.
Last edited by ramcdougal on Tue Jul 31, 2018 5:00 am, edited 1 time in total.

ted
Posts: 5770
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

### Re: Changing diameters of reconstructed neurons

Two suggested refinements.
1. Wrap the code in a procedure.
2. Provide a way to restore the original diameters.
Example:

Code: Select all

// revised 20180731 by NTC
// if \$1>0 scale diam3ds by \$1
// else restore original diams
objref diam3dvec
diam3dvec = new Vector() // to hold original diameters
proc scalediam3d() { local i, j, fac
// if original diams haven't been saved, save them
if (diam3dvec.length()==0) {
forall for i=0,n3d()-1 diam3dvec.append(diam3d(i))
}
j = 0 // track where we are in diam3dvec
if (\$1>0) {
fac = \$1 // scale diameters
} else {
fac = 1 // restore original diameters
}
forall for i=0,n3d()-1 {
// this won't work: diam3d(i) = fac * diam3dvec.x[j] (see note by ramcdougal below)
// here's how to change diam3d:
pt3dchange(i, fac * diam3dvec.x[j])
j+=1
}
}
}
With scalediam3d() you can do things like this

Code: Select all

// run simulations with diameters 90%, 100%, and 110%
// of experimentally observed values
for i = -1,1 {
scale = 1+0.1*i
scalediam3d(scale)
run()
postprocess() // analyze results of simulation
}

Tuoma
Posts: 9
Joined: Mon Apr 23, 2018 6:59 am

### Re: Changing diameters of reconstructed neurons

I'm getting a syntax error with NEURON 7.5 whenever I try to assign something to diam3d(j), e.g.
forall {
for (j = 0; j < n3d(); j+=1) {
diam3d(j)=1.0
}
}

ramcdougal
Posts: 214
Joined: Fri Nov 28, 2008 3:38 pm
Location: Yale School of Public Health

### Re: Changing diameters of reconstructed neurons

My mistake, sorry. I made that post on my phone without checking it.

You're right. diam3d is ready only. Use pt3dchange to set the diameter: the

Code: Select all

forall {
for (j = 0; j < n3d(); j+=1) {
pt3dchange(j, diam3d(j)*1.0)
}
}

ted