Beispiel #1
0
npzfile = np.load(filename)
psds = npzfile['psds']
adhd = npzfile['adhd']
freqs = npzfile['freqs']

ch_names = npzfile['info'][()]['ch_names']
picks = npzfile['picks'][()]
psd_channels = []
p = picks[::-1]
for i in p:
    psd_channels.append(ch_names.pop(i))
# now, select only the ones we want
look_for = ['M.F']
for sel in look_for:
    picks = fiff.pick_channels_regexp(psd_channels, sel)

band_psd = np.zeros([len(adhd), len(limits)])
for idx, bar in enumerate(limits):
    index = np.logical_and(freqs >= bar[0], freqs <= bar[1])
    band_psd[:, idx] = np.mean(np.mean(psds[:, :, index], axis=2), axis=1)


# fot machine learning we use the 2 data directly (as relative pixel
# positions info is ignored by this model)
X = band_psd
n_features = X.shape[1]

# the label to predict is the id of the person
y = adhd
Beispiel #2
0
    ax.set_xlim(-width, len(ind) + width)
    # ax.set_ylim(0, 45)
    ax.set_ylabel('Power')
    ax.set_title('Power by band and group' + aux_title)
    # xTickMarks = ['Group' + str(i) for i in range(1, N + 1)]
    ax.set_xticks(ind + width)
    xtickNames = ax.set_xticklabels(xTickMarks)
    plt.setp(xtickNames, rotation=20, fontsize=10)

    ## add a legend
    ax.legend((rects1[0], rects2[0]), ('ADHD', 'NV'))

    plt.show()


# plotting all channels
plot_bars(psds, adhd, freqs, ': all sensors')

# plotting only the ones in the paper
ch_names = npzfile['info'][()]['ch_names']
picks = npzfile['picks'][()]
psd_channels = []
p = picks[::-1]
for i in p:
    psd_channels.append(ch_names.pop(i))
# now, select only the ones we want
look_for = ['M.F', 'M.T']
for sel in look_for:
    picks = fiff.pick_channels_regexp(psd_channels, sel)
    plot_bars(psds[:, picks, :], adhd, freqs, sel)
from spreadsheet import get_subjects_from_excel

###############################################################################
# Set parameters
data_path = '/Users/sudregp/MEG_data/fifs/'
tmin, tmax = 10, 130  # use the first 2min of data after the first 10s
fmin, fmax = 1, 228  # look at frequencies between 1 and 228
NFFT = 2048  # the FFT size (NFFT). Ideally a power of 2

subjs = get_subjects_from_excel()

# let's do one subject to get the dimensions
subj = subjs.keys()[0]
raw_fname = data_path + subj + '_rest_LP100_HP0.6_CP3_DS300_raw.fif'
raw = fiff.Raw(raw_fname)
picks = fiff.pick_channels_regexp(raw.info['ch_names'], 'M..-*')
tmp, freqs = compute_raw_psd(raw,
                             tmin=tmin,
                             tmax=tmax,
                             picks=picks,
                             fmin=fmin,
                             fmax=fmax,
                             NFFT=NFFT,
                             n_jobs=1,
                             plot=False,
                             proj=False)
psds = np.zeros_like(np.tile(tmp, [len(subjs), 1, 1]))

# Loop through all the subjects we find. Calculate the power in all channels
for idx, subj in enumerate(subjs):
    raw_fname = data_path + subj + '_rest_LP100_HP0.6_CP3_DS300_raw.fif'
from spreadsheet import get_subjects_from_excel

###############################################################################
# Set parameters
data_path = '/Users/sudregp/MEG_data/fifs/'
tmin, tmax = 10, 130  # use the first 2min of data after the first 10s
fmin, fmax = 1, 228  # look at frequencies between 1 and 228
NFFT = 2048  # the FFT size (NFFT). Ideally a power of 2

subjs = get_subjects_from_excel()

# let's do one subject to get the dimensions
subj = subjs.keys()[0]
raw_fname = data_path + subj + '_rest_LP100_HP0.6_CP3_DS300_raw.fif'
raw = fiff.Raw(raw_fname)
picks = fiff.pick_channels_regexp(raw.info['ch_names'], 'M..-*')
tmp, freqs = compute_raw_psd(raw, tmin=tmin, tmax=tmax, picks=picks,
        fmin=fmin, fmax=fmax, NFFT=NFFT, n_jobs=1,
        plot=False, proj=False)
psds = np.zeros_like(np.tile(tmp, [len(subjs), 1, 1]))

# Loop through all the subjects we find. Calculate the power in all channels
for idx, subj in enumerate(subjs):
    raw_fname = data_path + subj + '_rest_LP100_HP0.6_CP3_DS300_raw.fif'

    # Setup for reading the raw data
    raw = fiff.Raw(raw_fname)

    psds[idx], freqs = compute_raw_psd(raw, tmin=tmin, tmax=tmax, picks=picks,
        fmin=fmin, fmax=fmax, NFFT=NFFT, n_jobs=1,
        plot=False, proj=False)