Help for adding multiple neurons and connecting them.
Posted: Tue Jun 24, 2025 12:05 am
Hello, I've recently been working on a project to simulate how signals pass from neuron to neuron and we'd like to use some pre-collected data. We were able to use a single SWC file but when we attempt to use more I'm unable to properly connect/add all of the neurons. Not sure if I've explained that correctly. Anyhow, ill share the code and see if yall have any ideas. Much appreciated in advance!
Code: Select all
// Modified by ~
// Load topology from six different .swc files and connect them
objref cell[6], swc[6], i3d[6], null, dend_indices, axon_indices, dend_list[6], axon_list[6]
// File names for SWC morphologies
objref filenames[6]
filenames[0] = new String("864691135356398031_0.swc")
filenames[1] = new String("864691135404857070_1.swc")
filenames[2] = new String("864691136389878647_2.swc")
filenames[3] = new String("864691135777479597_3.swc")
filenames[4] = new String("864691135119056861_4.swc")
filenames[5] = new String("864691135577012766_5.swc")
// Procedure to import SWC files into NEURON
proc import_all_swc() {
for i = 0, 5 {
swc[i] = new Import3d_SWC_read()
swc[i].input(filenames[i].s)
i3d[i] = new Import3d_GUI(swc[i], 0)
cell[i] = new SectionList() // dummy init to avoid nil error
i3d[i].instantiate(null)
// Initialize lists
dend_list[i] = new List()
axon_list[i] = new List()
// Classify sections
forsec cell[i] {
if (strm(secname(), "1")) {
dend_list[i].append(new SectionRef())
} else if (strm(secname(), "2")) {
axon_list[i].append(new SectionRef())
}
}
}
}
import_all_swc()
/*
// Set up synapses on the postsynaptic cell (cell[0])
objref exc_syn[5], nc_exc[5]
// Define synapse parameters and connections
proc connect_synapses() {
// dendrite indices and axon segment indices for each presynaptic neuron
dend_indices = new Vector(5)
axon_indices = new Vector(5)
dend_indices.x[0] = 12
dend_indices.x[1] = 27
dend_indices.x[2] = 44
dend_indices.x[3] = 49
dend_indices.x[4] = 4
axon_indices.x[0] = 43
axon_indices.x[1] = 62
axon_indices.x[2] = 39
axon_indices.x[3] = 65
axon_indices.x[4] = 55
for i = 0, 4 {
dend_list[0].o(dend_indices.x[i]).sec exc_syn[i] = new ExpSyn(0.5)
exc_syn[i].tau = 2
exc_syn[i].e = 0
axon_list[i+1].o(axon_indices.x[i]).sec nc_exc[i] = new NetCon(&v(0.5), exc_syn[i])
nc_exc[i].threshold = -20
nc_exc[i].weight = 0.05
}
}
connect_synapses()
*/