def plot_m_types(ax, PSET, colors, section=['dend', 'apic'], spacing=300, linewidths=0.05):
    '''draw comparison plot of each individual morphology'''
    CWD=PSET.CWD
    CELLPATH=PSET.CELLPATH
    n_segs = []
    areas = []

    for i, data in enumerate(PSET.populationParameters):
        
        NRN = data["me_type"]
        os.chdir(os.path.join(CWD, CELLPATH, NRN))
        cell = NetworkCell(**PSET.cellParameters[NRN])
        cell.set_pos(x=i*spacing, y=0, z=data['pop_args']['loc'])
        cell.set_rotation(x=np.pi/2)
        print(NRN, cell.zstart.min(), cell.zmid.min(), cell.zend.min(), cell.zstart.max(), cell.zmid.max(), cell.zend.max())   
        n_segs += [cell.totnsegs]
        areas += [cell.area[cell.get_idx(section)].sum()]

        zips = []
        for x, z in cell.get_idx_polygons(projection=('x', 'z')):
            zips.append(list(zip(x, z)))

        polycol = PolyCollection(zips,
                                 edgecolors=colors[i],
                                 linewidths=linewidths,
                                 facecolors=colors[i],
                                 label=NRN,
                                 )
        ax.add_collection(polycol)
        os.chdir(CWD)
    
    axis = ax.axis(ax.axis('tight'))

    # draw lines showing the layer boundaries
    ax.hlines(np.r_[0., -PSET.layer_data['thickness'].cumsum()][:4], axis[0], axis[1]-300, 'k', lw=0.5)
    ax.hlines(np.r_[0., -PSET.layer_data['thickness'].cumsum()][4:], axis[0], axis[1], 'k', lw=0.5)
    
    # annotate hlines with values
    for z in np.r_[0., -PSET.layer_data['thickness'].cumsum()]:
        ax.text(axis[0], z, r'$z={}$'.format(int(z)) + '$\mu$m', ha='right', va='center')
    
    ax.set_yticks(PSET.layer_data['center'])
    ax.set_yticklabels(PSET.layer_data['layer'])
    
    ax.set_xticks(np.arange(PSET.populationParameters.size)*spacing)
    ax.set_xticklabels(PSET.populationParameters['m_type'], rotation='vertical')

    ax.axis(ax.axis('equal'))
    ax.set_title('m-types')
    neuron.h("forall delete_section()")
    
    return n_segs, areas
示例#2
0
def plot_m_types(ax,
                 PSET,
                 colors,
                 section=['dend', 'apic'],
                 spacing=300,
                 linewidths=0.05):
    '''draw comparison plot of each individual morphology'''
    CWD = PSET.CWD
    CELLPATH = PSET.CELLPATH
    n_segs = []
    areas = []

    for i, data in enumerate(PSET.populationParameters):

        NRN = data["me_type"]
        os.chdir(os.path.join(CWD, CELLPATH, NRN))
        cell = NetworkCell(**PSET.cellParameters[NRN])
        cell.set_pos(x=i * spacing, y=0, z=data['pop_args']['loc'])
        cell.set_rotation(x=np.pi / 2)
        print(NRN, cell.zstart.min(), cell.zmid.min(), cell.zend.min(),
              cell.zstart.max(), cell.zmid.max(), cell.zend.max())
        n_segs += [cell.totnsegs]
        areas += [cell.area[cell.get_idx(section)].sum()]

        zips = []
        for x, z in cell.get_idx_polygons(projection=('x', 'z')):
            zips.append(list(zip(x, z)))

        polycol = PolyCollection(
            zips,
            edgecolors=colors[i],
            linewidths=linewidths,
            facecolors=colors[i],
            label=NRN,
        )
        ax.add_collection(polycol)
        os.chdir(CWD)

    axis = ax.axis(ax.axis('tight'))

    # draw lines showing the layer boundaries
    ax.hlines(np.r_[0., -PSET.layer_data['thickness'].cumsum()][:4],
              axis[0],
              axis[1] - 300,
              'k',
              lw=0.5)
    ax.hlines(np.r_[0., -PSET.layer_data['thickness'].cumsum()][4:],
              axis[0],
              axis[1],
              'k',
              lw=0.5)

    # annotate hlines with values
    for z in np.r_[0., -PSET.layer_data['thickness'].cumsum()]:
        ax.text(axis[0],
                z,
                r'$z={}$'.format(int(z)) + '$\mu$m',
                ha='right',
                va='center')

    ax.set_yticks(PSET.layer_data['center'])
    ax.set_yticklabels(PSET.layer_data['layer'])

    ax.set_xticks(np.arange(PSET.populationParameters.size) * spacing)
    ax.set_xticklabels(PSET.populationParameters['m_type'],
                       rotation='vertical')

    ax.axis(ax.axis('equal'))
    ax.set_title('m-types')
    neuron.h("forall delete_section()")

    return n_segs, areas
示例#3
0
    plotting.remove_axis_junk(ax)

    # draw the first NCELLS cells in each population
    NCELLS = 20
    CWD = PSET.CWD
    CELLPATH = PSET.CELLPATH
    # cell positions and rotations file:
    f = h5py.File(os.path.join(PSET.OUTPUTPATH,
                               'cell_positions_and_rotations.h5'), 'r')

    for i, data in enumerate(PSET.populationParameters):
        NRN = data["me_type"]
        os.chdir(os.path.join(CWD, CELLPATH, NRN))
        for j in range(NCELLS):
            try:
                cell = NetworkCell(**PSET.cellParameters[NRN])
                cell.set_pos(
                    x=f[NRN]['x'][j],
                    y=f[NRN]['y'][j],
                    z=f[NRN]['z'][j])
                cell.set_rotation(
                    x=f[NRN]['x_rot'][j],
                    y=f[NRN]['y_rot'][j],
                    z=f[NRN]['z_rot'][j])

                zips = []
                for x, z in cell.get_idx_polygons(projection=('x', 'z')):
                    zips.append(list(zip(x, z)))

                polycol = PolyCollection(zips,
                                         edgecolors=colors[i],
示例#4
0
"""
# import modules:
from matplotlib.pyplot import subplot, plot, ylabel, xlabel, show, close
import neuron
from LFPy import NetworkCell, StimIntElectrode
# class NetworkCell parameters:
cellParameters = dict(
    morphology='BallAndStick.hoc',
    templatefile='BallAndStickTemplate.hoc',
    templatename='BallAndStickTemplate',
    templateargs=None,
    v_init=-65.
)
# create cell:
cell = NetworkCell(
    tstart=0., tstop=100.,
    **cellParameters
)
# create stimulus device:
iclamp = StimIntElectrode(
    cell=cell,
    idx=0,
    pptype='IClamp',
    amp=0.5,
    dur=80.,
    delay=10.,
    record_current=True
)
# run simulation:
cell.simulate()

# plot cell response:
示例#5
0
"""
import matplotlib.pyplot as plt
from LFPy import NetworkCell, StimIntElectrode
import neuron
# class NetworkCell parameters
cellParameters = dict(
    morphology='BallAndStick.hoc',
    templatefile='BallAndStickTemplate.hoc',
    templatename='BallAndStickTemplate',
    templateargs=None,
    passive=False,
    v_init=-65
    )
# create cell instance
cell = NetworkCell(
    tstart=0, tstop=100,
    **cellParameters
    )
# stimulus device
iclamp = StimIntElectrode(
    cell=cell,
    idx=0,
    pptype='IClamp',
    amp=0.5,
    dur=80,
    delay=10,
    record_current=True
    )
# run simulation
cell.simulate()

plt.subplot(2,1,1)
示例#6
0
文件: figure_4.py 项目: LFPy/LFPy
    plotting.remove_axis_junk(ax)

    # draw the first NCELLS cells in each population
    NCELLS = 20
    CWD=PSET.CWD
    CELLPATH=PSET.CELLPATH
    # cell positions and rotations file:
    f = h5py.File(os.path.join(PSET.OUTPUTPATH,
                               'cell_positions_and_rotations.h5'), 'r')
    
    for i, data in enumerate(PSET.populationParameters):
        NRN = data["me_type"]
        os.chdir(os.path.join(CWD, CELLPATH, NRN))
        for j in range(NCELLS):
            try:                
                cell = NetworkCell(**PSET.cellParameters[NRN])
                cell.set_pos(x=f[NRN]['x'][j], y=f[NRN]['y'][j], z=f[NRN]['z'][j])
                cell.set_rotation(x=f[NRN]['x_rot'][j], y=f[NRN]['y_rot'][j], z=f[NRN]['z_rot'][j])
        
                zips = []
                for x, z in cell.get_idx_polygons(projection=('x', 'z')):
                    zips.append(list(zip(x, z)))
        
                polycol = PolyCollection(zips,
                                         edgecolors=colors[i],
                                         linewidths=0.05,
                                         facecolors=colors[i],
                                         label=NRN,
                                         zorder=f[NRN]['y'][j],
                                         )
                ax.add_collection(polycol)