Exemplo n.º 1
0
def spec_current_kernel(fparam, fts, fspec, f_max):
    I_syn = currentfn.SynapticCurrent(fts)

    # Generate spec results
    spec_L2 = MorletSpec(I_syn.t, I_syn.I_soma_L2Pyr, fparam, f_max)
    spec_L5 = MorletSpec(I_syn.t, I_syn.I_soma_L5Pyr, fparam, f_max)

    # Save spec data
    np.savez_compressed(fspec,
                        t_L2=spec_L2.t,
                        f_L2=spec_L2.f,
                        TFR_L2=spec_L2.TFR,
                        t_L5=spec_L5.t,
                        f_L5=spec_L5.f,
                        TFR_L5=spec_L5.TFR)
Exemplo n.º 2
0
def pkernel(dfig_dpl, f_dpl, f_spk, f_spec, f_current, f_spec_current, f_param, ax_handles, spec_cmap='jet'):
    T = paramrw.find_param(f_param, 'tstop')
    xlim = (50., T)

    # into the pdipole directory, this will plot dipole, spec, and spikes
    # create the axis handle
    f = ac.FigDipoleExp(ax_handles)

    # create the figure name
    fprefix = fio.strip_extprefix(f_dpl) + '-dpl'
    fname = os.path.join(dfig_dpl, fprefix + '.png')

    # grab the dipole
    dpl = dipolefn.Dipole(f_dpl)
    dpl.convert_fAm_to_nAm()

    # plot the dipole to the agg axes
    dpl.plot(f.ax['dpl_agg'], xlim)
    dpl.plot(f.ax['dpl_agg_L5'], xlim)
    # f.ax['dpl_agg_L5'].hold(True)
    # dpl.plot(f.ax['dpl_agg_L5'], xlim, 'L5')

    # plot individual dipoles
    dpl.plot(f.ax['dpl'], xlim, 'L2')
    dpl.plot(f.ax['dpl_L5'], xlim, 'L5')

    # f.ysymmetry(f.ax['dpl'])
    # print dpl.max('L5', (0., -1)), dpl.max('L5', (50., -1))
    # print f.ax['dpl_L5'].get_ylim()
    # f.ax['dpl_L5'].set_ylim((-1e5, 1e5))
    # f.ysymmetry(f.ax['dpl_L5'])

    # plot the current
    I_soma = currentfn.SynapticCurrent(f_current)
    I_soma.plot_to_axis(f.ax['I_soma'], 'L2')
    I_soma.plot_to_axis(f.ax['I_soma_L5'], 'L5')

    # plot the dipole-based spec data
    pc = specfn.pspec_ax(f.ax['spec_dpl'], f_spec, xlim, 'L2')
    f.f.colorbar(pc, ax=f.ax['spec_dpl'])

    pc = specfn.pspec_ax(f.ax['spec_dpl_L5'], f_spec, xlim, 'L5')
    f.f.colorbar(pc, ax=f.ax['spec_dpl_L5'])

    # grab the current spec and plot them
    spec_L2, spec_L5 = data_spec_current = specfn.read(f_spec_current, type='current')
    pc_L2 = f.ax['spec_I'].imshow(spec_L2['TFR'], aspect='auto', origin='upper',cmap=plt.get_cmap(spec_cmap))
    pc_L5 = f.ax['spec_I_L5'].imshow(spec_L5['TFR'], aspect='auto', origin='upper',cmap=plt.get_cmap(spec_cmap))

    # plot the current-based spec data
    # pci = specfn.pspec_ax(f.ax['spec_I'], f_spec_current, type='current')
    f.f.colorbar(pc_L2, ax=f.ax['spec_I'])
    f.f.colorbar(pc_L5, ax=f.ax['spec_I_L5'])

    # get all spikes
    s = spikefn.spikes_from_file(f_param, f_spk)

    # these work primarily because of how the keys are done
    # in the spike dict s (consequence of spikefn.spikes_from_file())
    s_L2 = spikefn.filter_spike_dict(s, 'L2_')
    s_L5 = spikefn.filter_spike_dict(s, 'L5_')

    # resize xlim based on our 50 ms cutoff thingy
    xlim = (50., xlim[1])

    # plot the spikes
    spikefn.spike_png(f.ax['spk'], s_L2)
    spikefn.spike_png(f.ax['spk_L5'], s_L5)

    f.ax['dpl'].set_xlim(xlim)
    # f.ax['dpl_L5'].set_xlim(xlim)
    # f.ax['spec_dpl'].set_xlim(xlim)
    f.ax['spk'].set_xlim(xlim)
    f.ax['spk_L5'].set_xlim(xlim)

    f.savepng(fname)
    f.close()

    return 0