Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed soma #396

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fixed soma
  • Loading branch information
Hjorthmedh committed Oct 26, 2023
commit 0ac019a4acfebfba4a23d43f50021b82cad159e3
14 changes: 8 additions & 6 deletions snudda/simulate/simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,7 @@ def set_resting_voltage(self, neuron_id, rest_volt=None):

soma = [x for x in self.neurons[neuron_id].icell.soma]
axon = [x for x in self.neurons[neuron_id].icell.axon]
# If there are no dendrites this will crash NEURON icell.dend has length == 1, but that is WRONG
dend = [x for x in self.neurons[neuron_id].icell.dend]

cell = soma + axon + dend
Expand Down Expand Up @@ -1365,17 +1366,17 @@ def add_volt_recording_all(self, cell_id=None, centre_only_flag=True):
local_cell_id = np.intersect1d(cell_id, list(self.neurons.keys()))

for cid in local_cell_id:
sec_id = [0]
sec_id = [-1] # Soma is sec_id = -1
sec_x = [0.5]

for sid, sec in enumerate(self.neurons[cid].icell.dend):

if centre_only_flag:
sec_id.append(sid+1)
sec_id.append(sid)
sec_x.append(0.5)
else:
for seg in sec.allseg():
sec_id.append(sid + 1) # NEURON indexes from 0, Snudda has soma as 0, and first dendrite is 1
sec_id.append(sid)
sec_x.append(seg.x)

self.add_volt_recording(cell_id=cid, sec_id=sec_id, sec_x=sec_x)
Expand All @@ -1390,7 +1391,7 @@ def add_volt_recording_soma(self, cell_id=None):
for cid in cell_id:

if cid in self.neurons.keys() and not self.is_virtual_neuron[cid]:
self.add_volt_recording(cid, [-1], [0.5]) # Soma is sec_id=-1
self.add_volt_recording(cid, [-1], [0.5]) # Soma is sec_id = -1

def add_volt_recording(self, cell_id: int, sec_id, sec_x):

Expand All @@ -1403,8 +1404,9 @@ def add_volt_recording(self, cell_id: int, sec_id, sec_x):
v = self.sim.neuron.h.Vector()
v.record(getattr(s(sx), '_ref_v'))

# From the Snudda synapse matrix. sec_id 0 is soma, sec_id >= 1 is dendrite, sec_id <= -1 is axon
self.record.register_compartment_data(neuron_id=cell_id, data_type="voltage", data=v,
# From the Snudda synapse matrix. sec_id -1 is soma, sec_id >= 0 is dendrite, sec_id <= -2 is axon
self.record.register_compartment_data(neuron_id=cell_id,
data_type="voltage", data=v,
sec_id=sid, sec_x=sx)

if self.record.time is None:
Expand Down
Loading