Skip to content

Commit

Permalink
style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
torbjone committed Apr 28, 2023
1 parent 32ed2d7 commit 906b734
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 101 deletions.
21 changes: 10 additions & 11 deletions LFPy/cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -2744,7 +2744,7 @@ def _set_area(self):
np.sqrt(np.diff(self.d, axis=-1)**2 + self.length**2)

def get_multi_current_dipole_moments(self, timepoints=None):
'''
"""
Return 3D current dipole moment vector and middle position vector
from each axial current in space.
Expand Down Expand Up @@ -2785,20 +2785,18 @@ def get_multi_current_dipole_moments(self, timepoints=None):
>>> timepoints = np.array([1,2,3,4])
>>> multi_dipoles, dipole_locs = cell.get_multi_current_dipole_moments(
>>> timepoints=timepoints)
'''
"""
i_axial, d_axial, pos_axial = self.get_axial_currents_from_vmem(
timepoints=timepoints)
Ni, Nt = i_axial.shape

multi_dipoles = np.zeros((Ni, 3, Nt))
for i in range(Ni):
multi_dipoles[i, ] = (i_axial[i][:, np.newaxis] * d_axial[:, i]).T

return multi_dipoles, pos_axial

def _find_parent_and_segment_M(self, M, seg_idx, parent_idx, bottom_seg,
branch, parentsec,
conn_point, sec):
branch, parentsec, conn_point, sec):
"""
Finds matrix elements of transfer matrix M from membrane potential
to membrane currents, for given segment and parent indexes.
Expand All @@ -2816,7 +2814,6 @@ def _find_parent_and_segment_M(self, M, seg_idx, parent_idx, bottom_seg,
Parameters
----------
M: ndarray, dtype=float
Tranfrormation matrix that is modified inplace
seg_idx: int
Expand Down Expand Up @@ -2857,7 +2854,8 @@ def _find_parent_and_segment_M(self, M, seg_idx, parent_idx, bottom_seg,
else:
# if branch point, need to account for effect of siblings
[sib_idcs] = np.take(self.children_dict[parentsec.name()],
np.where(self.children_dict[parentsec.name()]
np.where(self.children_dict[
parentsec.name()]
!= seg_idx))
sibs = [self.get_idx_name(sib_idcs)[i][1]
for i in range(len(sib_idcs))]
Expand Down Expand Up @@ -2887,8 +2885,8 @@ def _find_parent_and_segment_M(self, M, seg_idx, parent_idx, bottom_seg,
M[seg_idx, seg_idx] += - 1 / ri_
M[parent_idx, seg_idx] += + 1 / ri_

# When multiplied with cell.vmem, this gives the (equal but opposite)
# membrane current of the parent segment
# When multiplied with cell.vmem, this gives the
# equal but opposite membrane current of the parent segment
M[parent_idx, parent_idx] += - 1 / ri_
M[seg_idx, parent_idx] += + 1 / ri_

Expand Down Expand Up @@ -2956,7 +2954,8 @@ def get_transformation_matrix_vmem_to_imem(self):
internal_parent_idx = 0 # first seg in sec
else:
# if parentseg is not first or last seg in parentsec
segment_xlist = np.array([segment.x for segment in parentsec])
segment_xlist = np.array([segment.x
for segment in parentsec])
internal_parent_idx = np.abs(segment_xlist -
conn_point).argmin()

Expand All @@ -2976,4 +2975,4 @@ def get_transformation_matrix_vmem_to_imem(self):
branch = False
bottom_seg = False

return M
return M
Loading

0 comments on commit 906b734

Please sign in to comment.