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.
Changing diameters of reconstructed neurons
-
- Posts: 267
- 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.
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.
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
}
}
Last edited by ramcdougal on Tue Jul 31, 2018 5:00 am, edited 1 time in total.
-
- Site Admin
- Posts: 6300
- 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:
With scalediam3d() you can do things like this
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
}
}
}
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
}
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
}
}
forall {
for (j = 0; j < n3d(); j+=1) {
diam3d(j)=1.0
}
}
-
- Posts: 267
- 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
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)
}
}
-
- Site Admin
- Posts: 6300
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
Re: Changing diameters of reconstructed neurons
So in proc scalediam3d(), this statementramcdougal wrote:diam3d is ready only. Use pt3dchange to set the diameter
diam3d(i) = fac * diam3dvec.x[j]
should be replaced by
pt3dchange(i, fac * diam3dvec.x[j])
For the convenience of future readers of this thread, I have now made that change to my post from 20180730.