Skip to content

Commit

Permalink
set position of sections upon creation
Browse files Browse the repository at this point in the history
  • Loading branch information
rythorpe committed May 31, 2021
1 parent 8e03221 commit cde4ed2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 24 deletions.
26 changes: 8 additions & 18 deletions hnn_core/cell.py
Expand Up @@ -250,13 +250,20 @@ def _create_sections(self, p_secs, topology):
for height and xz plane for depth. This is opposite for model as a
whole, but convention is followed in this function ease use of gui.
"""
# distance from initial to final root postion
dx = self.pos[0] - self.p_secs['soma']['sec_pts'][0][0]
dy = self.pos[2] - self.p_secs['soma']['sec_pts'][0][1]
dz = self.pos[1] - self.p_secs['soma']['sec_pts'][0][2]

for sec_name in p_secs:
sec = h.Section(name=f'{self.name}_{sec_name}')
self.sections[sec_name] = sec

h.pt3dclear(sec=sec)
for pt in p_secs[sec_name]['sec_pts']:
h.pt3dadd(pt[0], pt[1], pt[2], 1, sec=sec)
h.pt3dadd(pt[0] + dx,
pt[1] + dy,
pt[2] + dz, 1, sec=sec)
sec.L = p_secs[sec_name]['L']
sec.diam = p_secs[sec_name]['diam']
sec.Ra = p_secs[sec_name]['Ra']
Expand Down Expand Up @@ -301,23 +308,6 @@ def build(self, sec_name_apical=None):
f'section of the current cell or None. '
f'Got {sec_name_apical}.')

def move_to_pos(self):
"""Move cell to position."""
x0 = self.soma.x3d(0)
y0 = self.soma.y3d(0)
z0 = self.soma.z3d(0)
dx = self.pos[0] * 100 - x0
dy = self.pos[2] - y0
dz = self.pos[1] * 100 - z0

# dummy comment
for s in self.get_sections():
for i in range(s.n3d()):
h.pt3dchange(i, s.x3d(i) + dx, s.y3d(i) + dy,
s.z3d(i) + dz, s.diam3d(i), sec=s)
h.pt3dchange(i, s.x3d(i) - dx, s.y3d(i) - dy,
s.z3d(i) - dz, s.diam3d(i), sec=s)

# two things need to happen here for h:
# 1. dipole needs to be inserted into each section
# 2. a list needs to be created with a Dipole (Point Process) in each
Expand Down
6 changes: 0 additions & 6 deletions hnn_core/network_builder.py
Expand Up @@ -317,7 +317,6 @@ def _build(self):
self._all_spike_gids = h.Vector()

self._record_spikes()
self.move_cells_to_pos()
self._connect_celltypes()

if _get_rank() == 0:
Expand Down Expand Up @@ -514,11 +513,6 @@ def state_init(self):
elif cell.name == 'L5Basket':
seg.v = -64.9737

def move_cells_to_pos(self):
"""Move cells 3d positions to positions used for wiring."""
for cell in self._cells:
cell.move_to_pos()

def _clear_neuron_objects(self):
"""Clear up NEURON internal gid information.
Expand Down

0 comments on commit cde4ed2

Please sign in to comment.