🙆♂️ 일반 cell과 고유 cell class 나누기
from neuron import h, gui
from neuron.units import ms, mV
h.load_file('stdrun.hoc')
먼저 라이브러리들을 import 합니다.
class Cell:
def __init__(self, gid):
self._gid = gid
self._setup_morphology()
self.all = self.soma.wholetree()
self._setup_biophysics()
def __repr__(self):
return '{}[{}]'.format(self.name, self._gid)
일반 cell의 class는 이렇구
class BallAndStick(Cell):
name = 'BallAndStick'
def _setup_morphology(self):
self.soma = h.Section(name='soma', cell=self)
self.dend = h.Section(name='dend', cell=self)
self.dend.connect(self.soma)
self.soma.L = self.soma.diam = 12.6157
self.dend.L = 200
self.dend.diam = 1
def _setup_biophysics(self):
for sec in self.all:
sec.Ra = 100 # Axial resistance in Ohm * cm
sec.cm = 1 # Membrane capacitance in micro Farads / cm^2
self.soma.insert('hh')
for seg in self.soma:
seg.hh.gnabar = 0.12 # Sodium conductance in S/cm2
seg.hh.gkbar = 0.036 # Potassium conductance in S/cm2
seg.hh.gl = 0.0003 # Leak conductance in S/cm2
seg.hh.el = -54.3 # Reversal potential in mV
# Insert passive current in the dendrite
self.dend.insert('pas')
for seg in self.dend:
seg.pas.g = 0.001 # Passive conductance in S/cm2
seg.pas.e = -65 # Leak reversal potential mV
고유한 BallAndStick의 class는 이렇습니다.
둘의 차이점은 BallAndStick에서는 __init__, __repr__ 메서드가 없고 self.all도 없습니다.
일반 cell에서 만들어질 때 한 개 이상의 셀이 있을 때 서로 구분이 되도록 조정을 해야합니다.
class Cell:
def __init__(self, gid, x, y, z, theta):
self._gid = gid
self._setup_morphology()
self.all = self.soma.wholetree()
self._setup_biophysics()
self.x = self.y = self.z = 0 # <-- NEW
h.define_shape()
self._rotate_z(theta) # <-- NEW
self._set_position(x, y, z) # <-- NEW
def __repr__(self):
return '{}[{}]'.format(self.name, self._gid)
# everything below here is NEW
def _set_position(self, x, y, z):
for sec in self.all:
for i in range(sec.n3d()):
sec.pt3dchange(i,
x - self.x + sec.x3d(i),
y - self.y + sec.y3d(i),
z - self.z + sec.z3d(i),
sec.diam3d(i))
self.x, self.y, self.z = x, y, z
def _rotate_z(self, theta):
"""Rotate the cell about the Z axis."""
for sec in self.all:
for i in range(sec.n3d()):
x = sec.x3d(i)
y = sec.y3d(i)
c = h.cos(theta)
s = h.sin(theta)
xprime = x * c - y * s
yprime = x * s + y * c
sec.pt3dchange(i, xprime, yprime, sec.z3d(i), sec.diam3d(i))
x,y,z 좌표값을 각각의 cell 값들에게 부여합니다.
그래서 cell을 만들 때 gid, x, y, z, theta 값을 입력해서 만들어야 합니다.
mycell = BallAndStick(0, 0, 0, 0, 0)
h.topology()
잘 만들어졌습니다. 사실 테스트 용이라 다시 삭제하겠습니다.
del mycell
🙋♂️ cell 생성
def create_n_BallAndStick(n, r):
"""n = number of cells; r = radius of circle"""
cells = []
for i in range(n):
theta = i * 2 * h.PI / n
cells.append(BallAndStick(i, h.cos(theta) * r, h.sin(theta) * r, 0, theta))
return cells
cell을 하나하나 생성하기에는 오래걸리기에 함수를 통해서 생성할 수 있도록 합니다.
n과 r값을 인자로 갖는데 n은 셀의 개수, r은 반지름 값 입니다.
my_cells = create_n_BallAndStick(7, 50)
이렇게 셀 배열을 만들 수 있습니다.
ps = h.PlotShape(True)
ps.show(0)
이런게 나오면서 확인할 수 있습니다.
my_cells = create_n_BallAndStick(5, 50)
새로 5개의 셀을 만들고 싶다면 다른 배열 변수에 넣는 것이 아닌 기존 변수에다가 다시 넣으면 됩니다.
그러면 기존 값은 사라지고 5개 넣은 값만 남습니다.
💆♂️시냅스 입력하기
이번에는 전류자극으로 자극하는 것이 아닌 가상 시냅스를 통해서 자극하는 방법을 알아보겠습니다.
NetCon이라는 네트워크 연결 개체를 통해 뉴런의 개체 간 이벤트를 통신하는데 일반적으로 스파이크의 임계값을 감지합니다.
NetStim을 통해서 스파이크를 생성하여 외부입력으로 작동합니다.
stim = h.NetStim() # Make a new stimulator
# Attach it to a synapse in the middle of the dendrite
# of the first cell in the network. (Named 'syn_' to avoid
# being overwritten with the 'syn' var assigned later.)
syn_ = h.ExpSyn(my_cells[0].dend(0.5))
stim.number = 1
stim.start = 9
ncstim = h.NetCon(stim, syn_)
ncstim.delay = 1
ncstim.weight[0] = 0.04 # NetCon weight is a vector.
시간값이 9일 때 스파이크를 생성하고 10일 때 시냅스 이벤트 전달을 위해 delay는 1로 둡니다.
syn_.tau = 2
tau값은 전류가 얼마나 빨리 감쇠하는지 정하는 값입니다. 2ms로 지정합니다.
전류의 정확한 값은 세포의 막전위와 시냅스의 반전 전위 (syn_.e)에 따라 결정됩니다.
print('Reversal potential = {} mV'.format(syn_.e))
이렇게 확인할 수 있습니다.
'AI > neuron' 카테고리의 다른 글
[neuron][파이썬] 18. 확장된 링 네트워크 (0) | 2022.07.25 |
---|---|
[neuron][파이썬] 17. 링 네트워크 시뮬레이션 실행 및 출력 (0) | 2022.07.22 |
[neuron][파이썬] 15. 여러 개 시뮬레이션2 - Run the simulations (0) | 2022.07.22 |
[neuron][파이썬] 14. 여러 개 시뮬레이션1 - Run the simulation (0) | 2022.07.21 |
[neuron][파이썬] 13. 생물학 값 특정하기 - Specify biophysics (0) | 2022.07.21 |