示例#1
0
# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.
"""

from scipy import io
from anlffr import tfr
import numpy as np

dat = io.loadmat('ERPsummary_zscore.mat')
t = dat['t'].flatten()
c7 = dat['c7']
c14 = dat['c14']
c20 = dat['c20']

f = np.arange(5, 200)
powertd, itc, times = tfr.tfr_multitaper(c20[:26, None, :], 1000., f)
times = times + t[0]
powertd_adj = tfr.rescale(powertd, times, (-0.2, 0.), mode='logratio')
tfr.plot_tfr(powertd_adj, times, f)

powerasd, itc, times = tfr.tfr_multitaper(c20[26:, None, :], 1000., f)
times = times + t[0]
powerasd_adj = tfr.rescale(powerasd, times, (-0.2, 0.), mode='logratio')
tfr.plot_tfr(powerasd_adj, times, f)
示例#2
0
    label_mean_evoked = np.mean(stc_evoked_label.data, axis=0)

    #######################################################
    # Calculating label TFR stuff

    epo_array = np.zeros((len(stcs), 1, stcs[0].shape[1]))
    nVerts = stc_evoked_label.shape[0]
    nTopVerts = 1
    corr_list = np.zeros(nVerts)
    for k in range(nVerts):
        corr_list[k] = np.corrcoef(label_mean_evoked,
                                   stc_evoked_label.data[k, :])[0, 1]
    topverts = np.argsort(corr_list)[-nTopVerts:]
    for k, stc in enumerate(stcs):
        epo_array[k, 0, :] = stc.data[topverts, :].mean(axis=0)

    freqs = np.arange(5., 130., 2.)
    n_cycles = freqs * 0.250
    power, itc, faketimes = tfr_multitaper(epo_array, epochs.info['sfreq'],
                                           freqs, n_cycles=n_cycles,
                                           time_bandwidth=2.0, zero_mean=False,
                                           verbose='DEBUG')
    powers += [power, ]
    itcs += [itcs, ]

power_contrast = 20. * np.log10(powers[0] / powers[1])
power_contrast_scaled = rescale(power_contrast, times, baseline=(-0.2, 0.),
                                mode='zscore')
plot_tfr(power_contrast_scaled, times, freqs)
pl.show()
示例#3
0
        dat = loadmat(fpath + matnames[0])

        freq = float(freq)
        if freq != dat['f0'][0][0]:
            raise RuntimeError("File contains data from the wrong probe"
                               "frequency! Cannot continue!")

        P = dat['Pcanal']
        goods = rejecttrials(P, thresh=1.5)
        P_ave = np.mean(P[goods, :], axis=0)

        # Wavelet analysis
        P_env, itc, t = tfr_multitaper(P_ave[None, None, :],
                                       fs,
                                       frequencies=[
                                           freq,
                                       ],
                                       time_bandwidth=2.0,
                                       n_cycles=freq * 0.05)
        P_env = rescale(P_env,
                        t,
                        baseline=(0.3, 0.5),
                        mode='logratio',
                        copy=False)
        pl.figure(1)
        label = str(int(freq))
        pl.plot(t, 10 * P_env.squeeze(), label=label)
        pl.hold(True)
    pl.figure(1)
    pl.xlabel('Time (s)', fontsize=16)
    pl.ylabel('Ear canal pressure change (dB)', fontsize=16)