For example, let's assume that the user wants to populate a cylindrical fascicle with R=1mm and L=100mm with N=100 axonal trajectories randomly distributed. In order to maintain the 'Model' panel clean, a 'Axonal Trajectories' folder is created as well.

The following code does the job:

```
import s4l_v1 as s4l
import numpy as np
from s4l_v1 import Vec3
# Parameters definition
R=1 # Radius (mm)
L=100 # Length of the cylinder (mm)
N=100 # Number of axons
## Creates a folder in the Model Panel
folder=s4l.model.CreateGroup('Axon Trajectories')
# Initialization
points=[]; cnt=0
while cnt<N:
# Creates Randomly Distributed Points in the cross section
x=2*R*(-0.5+np.random.rand());
y=2*R*(-0.5+np.random.rand())
# only the axons within the cylinders are taken
if (x*x+y*y<R*R):
pin=Vec3(x,y,-0.5*L); pend=Vec3(x,y,-0.5*L)
axon=s4l.model.CreatePolyLine([pin,pend])
axon.Name='Axon_'+str(cnt)
folder.Add(axon)
cnt+=1
```

The code can be modified to permit arbitrary distributions of fibers within the fascicle entity.

]]>For example, let's assume that the user wants to populate a cylindrical fascicle with R=1mm and L=100mm with N=100 axonal trajectories randomly distributed. In order to maintain the 'Model' panel clean, a 'Axonal Trajectories' folder is created as well.

The following code does the job:

```
import s4l_v1 as s4l
import numpy as np
from s4l_v1 import Vec3
# Parameters definition
R=1 # Radius (mm)
L=100 # Length of the cylinder (mm)
N=100 # Number of axons
## Creates a folder in the Model Panel
folder=s4l.model.CreateGroup('Axon Trajectories')
# Initialization
points=[]; cnt=0
while cnt<N:
# Creates Randomly Distributed Points in the cross section
x=2*R*(-0.5+np.random.rand());
y=2*R*(-0.5+np.random.rand())
# only the axons within the cylinders are taken
if (x*x+y*y<R*R):
pin=Vec3(x,y,-0.5*L); pend=Vec3(x,y,-0.5*L)
axon=s4l.model.CreatePolyLine([pin,pend])
axon.Name='Axon_'+str(cnt)
folder.Add(axon)
cnt+=1
```

The code can be modified to permit arbitrary distributions of fibers within the fascicle entity.

]]>