#plt.imshow(coeffs[stimclass,:,:])
    
    #coeff_mag[stimclass] = np.linalg.norm(coeffs[stimclass,:,:],axis=1)
    #Here, we'll CHOOSE a coefficient
    coeff_mag[stimclass] = coeffs[stimclass,:,choose_band]
    
    #Here, we'll do PCA to find the components across all bands
    pca = PCA()
    pca.fit(coeffs[stimclass,:,:])
    rot_coeff = pca.fit_transform(coeffs[stimclass,:,:])
    
    # plt.figure()
    # for bb in range(5):
    #     kde = KernelDensity(kernel='gaussian', bandwidth=0.2).fit(rot_coeff[:,bb].reshape(-1,1))
    #     plt.plot(kde.score_samples(rot_coeff[:,bb].reshape(-1,1)))
    #     #plt.hist(rot_coeff[:,:])
    
    #THIS ASSUMES COEFFICIENTS ARE ALL SIMILARLY DISTRIBUTED for each band
    coeff_max = np.linalg.norm(np.abs(rot_coeff),axis=1)
    coeff_max = stats.zscore(coeff_max)
    
    alpha_coeffs = stats.zscore(np.abs(rot_coeff[:,2]))
    
    mainfig = plt.figure()
    EEG_Viz.plot_3d_scalp(alpha_coeffs>2,mainfig,clims=(0,3),animate=False,label=label_map[stimclass],unwrap=True)
    plt.title(label_map[stimclass])
    
    
#%%
# need to do rPCA here for coefficients
    
Пример #2
0
        _, _, SG = sig.spectrogram(sel_sig,
                                   nperseg=512,
                                   noverlap=500,
                                   window=sig.get_window(
                                       'blackmanharris', 512),
                                   fs=fs / ds_fact)
        ch_blip.append(np.max(SG[F_idxs[0], :]) - np.min(SG[F_idxs[0], :]))
    ch_blip = np.array(ch_blip)

    #%%
    thresh = 0
    ch_blip_z = stats.zscore(ch_blip)
    plt.hist(ch_blip_z, bins=50, range=(-1, 1))

    #%%
    EEG_Viz.maya_band_display(ch_blip_z > thresh)
    print(np.where(ch_blip_z > thresh))

    #%%
    #take out the alpha band in each channel
    alpha = np.zeros((257))
    theta = np.zeros((257))
    for ch in range(257):
        Fidx = np.where(np.logical_and(F > 8, F <= 14))
        alpha[ch] = np.sum(diff_PSD[ch, Fidx], axis=1)
        Fidx = np.where(np.logical_and(F > 4, F <= 8))
        theta[ch] = np.sum(diff_PSD[ch, Fidx], axis=1)
    #%%
    #Topoplot it

    #egipos = mne.channels.read_montage('/tmp/GSN257.sfp')
    blintv = (0, 9)
elif pt == '907':
    blintv = (0, 20)

sEEG.calc_baseline(intv=blintv)
#%%
sEEG.label_segments()
sEEG.plot_segment_labels()

#%%
# This is for 906
# Intervals are in SECONDS
if pt == '906':
    intv_list = {'L': (11, 31), 'R': (51, 71), 'BL': (91, 111)}
elif pt == '907':
    intv_list = {'L': (11, 31), 'R': (51, 71), 'BL': (91, 111)}

intv_order = ['L', 'R', 'BL']

median_response = []
for voltage in intv_order:

    median_response.append(
        sEEG.median_response(intv=intv_list[voltage], do_plot=True))

    plt.suptitle(voltage)

#%%
median_response = np.array(median_response)
EEG_Viz.plot_3d_scalp(np.mean(median_response, axis=0)[:, 2], unwrap=True)