728x90
반응형

python 105

[백준][Python] 3003. 킹, 퀸, 룩, 비숏, 나이트, 폰

🙆‍♂️문제 🙋‍♂️풀이 킹은 1개, 퀸도 1개, 룩은 2개, 비숍도 2개, 나이트도 2개, 폰 8개가 있어야 한다. 킹, 퀸, 룩, 비숍, 나이트, 폰에 대한 개수가 입력되면 정상적인 체스 수가 되려면 추가되야 할지 빼야할지에 대해 출력하면 된다. 🚀 입력받기 inputChess = list(map(int,input().split())) 먼저 chess라는 배열에 현재 체스말 수를 입력 받는다. 🚀 문제 풀이 핵심 stdChess = [1,1,2,2,2,8] outputChess =[] for i in range(6): num = stdChess[i]-inputChess[i] outputChess.append(num) 먼저 기준이 되는 stdChess 배열을 정의합니다. 그리고 for문을 사용하여 st..

[백준][Python] 25305. 커트라인

🙆‍♂️문제 🙋‍♂️풀이 점수들을 배열로 저장하고 내림차순으로 정렬하여 k-1번 째 값을 출력하면 커트라인이 출력됩니다. 🚀 입력받기 n,k = map(int,input().split()) scores = list(map(int,input().split())) 배열의 수 n과 커트라인 명 수 k를 입력받습니다. 그리고 점수 배열 scores를 입력 받습니다. 🚀 문제 풀이 핵심 scores.sort(reverse=True) scores 배열을 내림차순으로 정렬합니다. 🚀 출력하기 print(scores[k-1]) 커트라인에 걸린 점수를 출력합니다.

[neuron][파이썬] 18. 확장된 링 네트워크

🙆‍♂️ 일반 셀 클래스 작성 저번 게시물의 링 네트워크를 구성했던 것에서 유연한 변수를 사용하고 캡슐화를 사용하여 확장된 기능을 제공하는 링 네트워를 구성해보겠습니다. from neuron import h, gui from neuron.units import ms, mV h.load_file('stdrun.hoc') 사전 참조를 해주고 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 h.define_shape() self._rota..

AI/neuron 2022.07.25

[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
728x90
반응형