728x90
반응형

파이썬 뉴런 라이브러리 10

[neuron][파이썬] 17. 링 네트워크 시뮬레이션 실행 및 출력

🙆‍♂️ 세포 작동여부 확인 아직 자극은 주지 않았지만 만든 cell이 작동하는지 확인해보겠습니다. recording_cell = my_cells[0] soma_v = h.Vector().record(recording_cell.soma(0.5)._ref_v) dend_v = h.Vector().record(recording_cell.dend(0.5)._ref_v) t = h.Vector().record(h._ref_t) 기록하고 h.finitialize(-65) h.continuerun(25) 값 지정해주고 %matplotlib inline import matplotlib.pyplot as plt plt.plot(t, soma_v, label='soma(0.5)') plt.plot(t, dend_v, l..

AI/neuron 2022.07.22

[neuron][파이썬] 16. 링 네트워크 구성을 위한 초기 구성 - Initial configuration for build a ring network

🙆‍♂️ 일반 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 = 'Ball..

AI/neuron 2022.07.22

[neuron][파이썬] 15. 여러 개 시뮬레이션2 - Run the simulations

🙆‍♂️ 전류 진폭의 역할 - Role of current amplitude(amp) 전류 진폭의 차이를 확인하기 위해서 for문을 통해 값과 색을 변경하여 그래프를 확인해보겠습니다. from bokeh.io import output_notebook import bokeh.plotting as plt output_notebook() f = plt.figure(x_axis_label='t (ms)', y_axis_label='v (mV)') amps = [0.075 * i for i in range(1, 5)] colors = ['green', 'blue', 'red', 'black'] for amp, color in zip(amps, colors): stim.amp = amp h.finitialize(-..

AI/neuron 2022.07.22

[neuron][파이썬] 14. 여러 개 시뮬레이션1 - Run the simulation

🙆‍♂️ 사전작업 🚀 자극 주입 시뮬레이션 확인에 앞서 만든 모델에 자극을 주입합니다. stim = h.IClamp(my_cell.dend(1)) 시뮬레이션 시작 후 5ms부터 dendrite 원위부 끝에 자극을 줍니다 . stim.get_segment() 위 코드로 자극이 주입되는 세그먼트를 확인할 수 있습니다. 잘 진행되고 있습니다. dir(stim)을 통해서 stim의 속성 값들을 확인할 수 있는데 더 좋은 코드는 print(', '.join(item for item in dir(stim) if not item.startswith('__'))) 위 코드를 이용하면 __를 뺀 속성들만 간단하게 볼 수 있습니다. 이렇게 존재합니다. stim.delay = 5 stim.dur = 1 stim.amp = ..

AI/neuron 2022.07.21

[neuron][파이썬] 13. 생물학 값 특정하기 - Specify biophysics

🙆‍♂️ biophysics 값들 설정 현재 값은 대왕오징어의 생물학적 값으로 대입되어있어서 다시 재설정을 해줘야합니다. 축 저항 값과 막 용량 값을 재설정 합니다. class BallAndStick: def __init__(self, gid): self._gid = gid self.soma = h.Section(name='soma', cell=self) self.dend = h.Section(name='dend', cell=self) self.all = [self.soma, self.dend]#전체 속성 값 배열 self.dend.connect(self.soma) self.soma.L = self.soma.diam = 12.6157 self.dend.L = 200 self.dend.diam = 1 fo..

AI/neuron 2022.07.21

[neuron][파이썬] 12. 스타일 정의 - Define stylized geometry

🙆‍♂️ 길이와 직경 설정 class BallAndStick: def __init__(self, gid): self._gid = gid 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 __repr__(self): return 'BallAndStick[{}]'.format(self._gid) my_cell = BallAndStick(0) 소마의 길이와 직경은 12.6157µm 수상돌기의 길이는 200..

AI/neuron 2022.07.21

[neuron][파이썬] 11. 섹션 연결 - Connect the sections

🙆‍♂️ soma와 dend 연결 soma와 dend를 연결하기 위해서는 역시 class 속 함수의 내용을 바꿔줘야 합니다. class BallAndStick: def __init__(self, gid): self._gid = gid self.soma = h.Section(name='soma', cell=self) self.dend = h.Section(name='dend', cell=self) self.dend.connect(self.soma) def __repr__(self): return 'BallAndStick[{}]'.format(self._gid) connect 메소드를 사용해서 연결해줄 수 있습니다. 지금 상황은 완전하게 연결된 것은 아니고 soma가 끝나는 지점에 dend가 시작되어서 연결..

AI/neuron 2022.07.21

[neuron][파이썬] 10. 여러 섹션 만들기 - Create the sections

🙆‍♂️ 시작 설정 from neuron import h from neuron.units import ms, mV h.load_file('stdrun.hoc') 시작하기 전에 라이브러리들을 import 시켜주고 %matplotlib notebook 주피터 노트북에서 하고 있다면 이 코드도 넣어줍니다. 🙋‍♂️ 섹션 생성 섹션 = 셀입니다. 셀은 ball과 stick으로 구성되는데 ball은 soma(세포체)이고 stick은 dendrites(수상 둘기) 입니다. 이전에 배웠던 방법으로는 여러 셀을 만들 수 없습니다. 클래스로 정의해서 만들어야 합니다. class BallAndStick: def __init__(self): self.soma = h.Section(name='soma', cell=self) ..

AI/neuron 2022.07.21

[neuron][파이썬] 09. 결과 저장하고 불러오기 - Saving and loading results

🙆‍♂️ CSV csv 파일 형식은 데이터 교환에 널리 사용되는 방식ㅇ빈디ㅏ. csv 모듈을 제공하니 import 하여 사용할 수 있습니다. import csv 그전에 해당 폴더에 data.csv를 만들고 🚀 작성하기 with open('data.csv', 'w') as f: csv.writer(f).writerows(zip(t, v)) 이렇게 작성하면 data.csv에 t값과 v값이 작성됩니다. 🚀 csv 불러오기 with open('data.csv') as f: reader = csv.reader(f) tnew, vnew = zip(*[[float(val) for val in row] for row in reader if row]) tnew 변수와 vnew 변수를 통해서 csv에 저장되어 있었던 값들..

AI/neuron 2022.07.20

[neuron][파이썬] 07. 시뮬레이션 실행 - Run the simulation

🙆‍♂️ 라이브러리 로드 h 모듈에서도 시뮬레이션 기능을 제공하지만 더 높은 사양을 위해서 stdrun 라이브러리를 로드해야 합니다. h.load_file('stdrun.hoc') 로드 후 run을 했을 때 1.0이 보인다면 잘 로드가 된 것입니다. h.finitialize(-65) 휴지 전위 상태의 막 전위 값을 -65로 설정하기 위해서 finitialize 함수를 사용합니다. 설정 수치는 -65mV입니다. h.continuerun(40) 그리고 시뮬레이션 지속 시간을 40ms로 설정할 수 있습니다. from neuron import h soma = h.Section(name='soma') soma.L = 20 soma.diam = 20 soma.insert('hh') mech = soma(0.5).h..

AI/neuron 2022.07.20
728x90
반응형