Пример #1
0
        rpt = RNNPreprocessTransform.load(preproc_file)
        rpt.write_pred_file(rnn_file, pred_file, lfp_enc_file=linear_file)
    visualize_pred_file(pred_file, 3, 0, 2.4, electrode_order=ROSTRAL_CAUDAL_ELECTRODES_LEFT[::-1], dbnoise=4.0)
    leg = custom_legend(['k', 'r', 'b'], ['Real', 'Linear', 'RNN'])
    plt.legend(handles=leg)

    fname = os.path.join(get_this_dir(), 'rnn_preds.svg')
    plt.savefig(fname, facecolor='w', edgecolor='none')

    plt.show()


def draw_figures():
    agg = RNNAggregator.load('/auto/tdrive/mschachter/data/aggregate/rnn.h5')

    # stats(agg)

    draw_preds(agg)


if __name__ == '__main__':
    set_font()
    draw_figures()







Пример #2
0
def plot_nofund(agg, data_dir='/auto/tdrive/mschachter/data'):

    spec_colormap()

    aprops = ['fund', 'maxfund', 'minfund', 'cvfund', 'fund2', 'voice2percent',
               'stdspect', 'skewspect', 'kurtosisspect', 'entropyspect', 'sal',
               'meanspect', 'q1', 'q2', 'q3', 'skewtime', 'kurtosistime', 'entropytime', 'maxAmp']
    Xz, good_indices = agg.remove_duplicates(acoustic_props=aprops)

    stim_durs = agg.df.end_time.values - agg.df.start_time.values
    good_indices = [gi for gi in good_indices if stim_durs[gi] > 0.040 and stim_durs[gi] < 0.450]

    stims = [(stim_id, order, stim_type) for stim_id, order, stim_type in zip(agg.df.stim_id[good_indices],
                                                                              agg.df.syllable_order[good_indices],
                                                                              agg.df.stim_type[good_indices])]

    plt.figure()
    plt.hist(stim_durs[good_indices], bins=25)
    plt.show()

    fund_i = agg.acoustic_props.index('fund')
    funds = np.array([agg.Xraw[xindex, fund_i] for xindex in agg.df.xindex[good_indices]])

    print 'funds.min=%f, q1=%f, q2=%f' % (funds.min(), np.percentile(funds, 1), np.percentile(funds, 2))

    no_fund = np.where(funds <= 0)[0]
    yes_fund = np.where(funds > 0)[0]
    print 'no_fund=', no_fund

    plt.figure()
    plt.hist(funds, bins=20)
    plt.title('funds')
    # plt.show()

    # np.random.seed(1234567)
    # np.random.shuffle(no_fund)
    # np.random.shuffle(yes_fund)

    # get syllable properties for some examples of syllables with and without fundamental frequencies
    set_font(10)
    figsize = (23, 10)
    fig = plt.figure(figsize=figsize)
    fig.subplots_adjust(wspace=0.35, hspace=0.35, left=0.05, right=0.95)

    num_syllables = 5
    no_fund_i = no_fund[:num_syllables]
    yes_fund_i = yes_fund[:num_syllables]

    gs = plt.GridSpec(2, num_syllables)
    for k in range(num_syllables):

        fi = no_fund_i[k]
        f = funds[fi]
        stim_id,stim_order,stim_type = stims[fi]
        sprops = get_syllable_props(agg, stim_id, stim_order, data_dir)

        ax = plt.subplot(gs[0, k])
        si = sprops['spec_si']
        ei = sprops['spec_ei']
        plot_spectrogram(sprops['spec_t'][si:ei], sprops['spec_freq'], sprops['spec'][:, si:ei], ax=ax,
                         colormap='SpectroColorMap', colorbar=False)
        plt.title('%d_%d (%s), fund=%0.2f' % (stim_id, stim_order, stim_type, f))

        fi = yes_fund_i[k]
        f = funds[fi]
        stim_id, stim_order, stim_type = stims[fi]
        sprops = get_syllable_props(agg, stim_id, stim_order, data_dir)

        ax = plt.subplot(gs[1, k])
        si = sprops['spec_si']
        ei = sprops['spec_ei']
        plot_spectrogram(sprops['spec_t'][si:ei], sprops['spec_freq'], sprops['spec'][:, si:ei], ax=ax,
                         colormap='SpectroColorMap', colorbar=False)
        plt.title('%d_%d (%s), fund=%0.2f' % (stim_id, stim_order, stim_type, f))

    plt.show()