Blame LFPy-2.0.7/examples/example_LFPyCellTemplate.py

7d68d07
# -*- coding: utf-8 -*-
7d68d07
"""
7d68d07
A very generic case where the same morphology on different file formats
7d68d07
is loaded in LFPy using a generic template specification, defined by
7d68d07
file LFPyCellTemplate.hoc
7d68d07
7d68d07
Execution:
7d68d07
7d68d07
    python example_LFPyCellTemplate.py
7d68d07
    
7d68d07
Copyright (C) 2017 Computational Neuroscience Group, NMBU.
7d68d07
7d68d07
This program is free software: you can redistribute it and/or modify
7d68d07
it under the terms of the GNU General Public License as published by
7d68d07
the Free Software Foundation, either version 3 of the License, or
7d68d07
(at your option) any later version.
7d68d07
7d68d07
This program is distributed in the hope that it will be useful,
7d68d07
but WITHOUT ANY WARRANTY; without even the implied warranty of
7d68d07
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7d68d07
GNU General Public License for more details.
7d68d07
"""
7d68d07
import LFPy
7d68d07
import neuron
7d68d07
import numpy as np
7d68d07
import matplotlib.pyplot as plt
7d68d07
7d68d07
#A plottin' function
7d68d07
def plotcell(cell, color='k'):
7d68d07
    for sec in cell.template.all:
7d68d07
        idx = cell.get_idx(sec.name())
7d68d07
        plt.plot(np.r_[cell.xstart[idx], cell.xend[idx][-1]],
7d68d07
                 np.r_[cell.zstart[idx], cell.zend[idx][-1]],
7d68d07
                 color=color)
7d68d07
    print(' ')
7d68d07
7d68d07
#delete cell instances from previous script executions,
7d68d07
neuron.h('forall delete_section()')
7d68d07
7d68d07
#create some cell instances, set the positions, plot the morphologies
7d68d07
cell1 = LFPy.TemplateCell(
7d68d07
    morphology='morphologies/markram/CNG version/C010398B-P2.CNG.swc',
7d68d07
    templatefile='LFPyCellTemplate.hoc',
7d68d07
    templatename='LFPyCellTemplate',
7d68d07
    templateargs=None)
7d68d07
cell1.set_pos(0)
7d68d07
plotcell(cell=cell1, color='r')
7d68d07
7d68d07
7d68d07
cell2 = LFPy.TemplateCell(
7d68d07
    morphology='morphologies/markram/Source-Version/C010398B-P2.asc',
7d68d07
    templatefile='LFPyCellTemplate.hoc',
7d68d07
    templatename='LFPyCellTemplate',
7d68d07
    templateargs=None)
7d68d07
cell2.set_pos(200)
7d68d07
plotcell(cell=cell2, color='g')
7d68d07
7d68d07
7d68d07
cell3 = LFPy.TemplateCell(
7d68d07
    morphology='morphologies/markram/hoc-version/C010398B-P2.hoc',
7d68d07
    templatefile='LFPyCellTemplate.hoc',
7d68d07
    templatename='LFPyCellTemplate',
7d68d07
    templateargs=None)
7d68d07
cell3.set_pos(400)
7d68d07
plotcell(cell=cell3, color='b')
7d68d07
plt.show()
7d68d07