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

MRG: Improve cells #200

Merged
merged 14 commits into from
Nov 9, 2020
57 changes: 19 additions & 38 deletions hnn_core/cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,32 +105,6 @@ def create_soma(self):
self.soma.Ra = soma_props['Ra']
self.soma.cm = soma_props['cm']

def get3dinfo(self):
"""Get 3d info."""
ls = self.get_sections()
lx, ly, lz, ldiam = [], [], [], []
for s in ls:
for i in range(s.n3d()):
lx.append(s.x3d(i))
ly.append(s.y3d(i))
lz.append(s.z3d(i))
ldiam.append(s.diam3d(i))
return lx, ly, lz, ldiam

def getbbox(self):
"""Get cell's bounding box."""
lx, ly, lz, ldiam = self.get3dinfo()
minx, miny, minz = 1e9, 1e9, 1e9
maxx, maxy, maxz = -1e9, -1e9, -1e9
for x, y, z in zip(lx, ly, lz):
minx = min(x, minx)
miny = min(y, miny)
minz = min(z, minz)
maxx = max(x, maxx)
maxy = max(y, maxy)
maxz = max(z, maxz)
return ((minx, maxx), (miny, maxy), (minz, maxz))

def translate3d(self, dx, dy, dz):
"""Translate 3d."""
for s in self.get_sections():
Expand Down Expand Up @@ -158,20 +132,27 @@ def move_to_pos(self):
# 2. a list needs to be created with a Dipole (Point Process) in each
# section at position 1
# In Cell() and not Pyr() for future possibilities
def dipole_insert(self, yscale):
"""Insert dipole into each section of this cell."""
def insert_dipole(self, yscale):
"""Insert dipole into each section of this cell.

Parameters
----------
yscale : dict
Dictionary of length scales to calculate dipole without
3d shape.
"""
# dends must have already been created!!
# it's easier to use wholetree here, this includes soma
seclist = h.SectionList()
seclist.wholetree(sec=self.soma)
# create a python section list list_all
self.list_all = [sec for sec in seclist]
for sect in self.list_all:
list_all = [sec for sec in seclist]
for sect in list_all:
sect.insert('dipole')
# Dipole is defined in dipole_pp.mod
self.dipole_pp = [h.Dipole(1, sec=sect) for sect in self.list_all]
self.dipole_pp = [h.Dipole(1, sec=sect) for sect in list_all]
# setting pointers and ztan values
for sect, dpp in zip(self.list_all, self.dipole_pp):
for sect, dpp in zip(list_all, self.dipole_pp):
# assign internal resistance values to dipole point process (dpp)
dpp.ri = h.ri(1, sec=sect)
# sets pointers in dipole mod file to the correct locations
Expand All @@ -188,7 +169,7 @@ def dipole_insert(self, yscale):
pos = np.array([seg.x for seg in sect.allseg()])
# diff in yvals, scaled against the pos np.array. y_long as
# in longitudinal
y_scale = (yscale[sect.name()] * sect.L) * pos
y_scale = (yscale[sect.name().split('_', 1)[1]] * sect.L) * pos
# y_long = (h.y3d(1, sec=sect) - h.y3d(0, sec=sect)) * pos
# diff values calculate length between successive section points
y_diff = np.diff(y_scale)
Expand Down Expand Up @@ -244,14 +225,14 @@ def syn_create(self, secloc, e, tau1, tau2):

Parameters
----------
secloc : float (0. to 1.0)
The section location
secloc : instance of nrn.Segment
The section location. E.g., soma(0.5).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Describing nrn objects with floats and ints shows up in several docstrings. Is this just referencing the numerical argument that instantiates the object?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it might be documented wrongly :-) fix is always welcome!

btw, soma(0.5) just means the middle of the soma ... I guess you know that already but putting it out there in case that was not clear.

e: float
Reverse potential
Reverse potential (in mV)
tau1: float
Rise time
Rise time (in ms)
tau2: float
Decay time
Decay time (in ms)

Returns
-------
Expand Down
Loading