-
Notifications
You must be signed in to change notification settings - Fork 52
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
MRG: Improve cells #200
Changes from all commits
166c1ce
6650d81
5231256
1d69221
434a78e
e3e6270
10c6d9c
eeacc0c
b28a628
ff7ba7e
fdeb0e9
4495b26
8f96d1a
93b57b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,73 +105,46 @@ 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(): | ||
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) | ||
|
||
def translate_to(self, x, y, z): | ||
"""Translate to position.""" | ||
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 = x - x0 | ||
dy = y - y0 | ||
dz = z - z0 | ||
# print('dx:',dx,'dy:',dy,'dz:',dz) | ||
self.translate3d(dx, dy, dz) | ||
dx = self.pos[0] * 100 - x0 | ||
dy = self.pos[2] - y0 | ||
dz = self.pos[1] * 100 - z0 | ||
|
||
def move_to_pos(self): | ||
"""Move cell to position.""" | ||
self.translate_to(self.pos[0] * 100, self.pos[2], self.pos[1] * 100) | ||
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) | ||
|
||
# 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 | ||
# 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 | ||
|
@@ -188,7 +161,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) | ||
|
@@ -244,14 +217,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). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it might be documented wrongly :-) fix is always welcome! btw, |
||
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 | ||
------- | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't quite get this ... why
pos[2]
fory
and why notpos[2] * 100
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is confusing. Why
pos[2]
instead ofpos[1]
for the y-coordinate?Is the factor of
100
supposed to represent the actual distance between cells (i.e., scales the integer positions within the coordinate grid)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I honestly don't know ... I raised an issue #202. Keeping it unchanged for now. Just reorganized the code.