<jupyter_start><jupyter_text>Exploratory  EEGECoG Data info EEG-ECoG Task    *Task design    The blindfolded monkey was seated in a primate chair and tied hand.    *Data Format    A. ECoG_n.mat        Data matrix: (Channel+trigger) x Time        Sampling rate: 1000Hz        Location of electrodes:see "Su_brain.png"        Filter:Bandpass filter(butterworth) From 0.3Hz To 500Hz    B. EEG_n.mat        Data matrix: (Channel+trigger) x Time        Sampling rate:4096Hz        Location of electrodes:Fp1,Fp2,F7,F3,Fz,F4,F8,T3,C3,C4,T4,T5,P3,Pz,P4,T6,O1,O2 (determined by 10-20 system)    n means trial number.    Trigger signals should be used for timing synchronization signal between EEG and ECoG.    [Author] <NAME>,<NAME>, <NAME>   Data access<jupyter_code>cd ..
%matplotlib inline
import matplotlib.pyplot as plt
import h5py
from SpectralCV import ecog_pipe as ep
import numpy as np
#load data from h5 
h5_file = '../Voytek/scv.h5'
from neurodsp import spectral
import neurodsp as ndsp
#plt.style.use('seaborn-colorblind')
#plt.rcParams['image.cmap'] = 'RdBu'
import scipy as sp
import scipy.io as io
import scipy.signal as sig<jupyter_output><empty_output><jupyter_text>ECoG<jupyter_code>data_path ="/Users/Lauren/Data/NeuroTycho/EEGECoG/20110607S1_EEGECoG_Su_Oosugi-Naoya+Nagasaka-Yasuo+Hasegawa+Naomi_ECoG128-EEG18_mat/ECoG01.mat"
import h5py
with h5py.File(data_path, 'r') as f:
    dset = f['WaveData']
    data = []
    data.append(dset[:][:])
data = data[0]
data.shape
plt.plot(data[:,0])<jupyter_output><empty_output><jupyter_text>Psd<jupyter_code>fs = 1000
nperseg = 1000
noverlap = nperseg/2
start = 0
end = 1
session_num = 1
#f_axis, f_time, spg = sig.spectrogram(data.T, fs=fs, nperseg=nperseg, noverlap=nperseg/2)

# plot psd
#plt.loglog(np.mean(spg,axis=1))

freqs, psd = ndsp.spectral.psd(data[:,:].T, Fs=fs, nperseg=nperseg, noverlap=nperseg/2)
plt.loglog(freqs,psd.T);
freqs, scv = spectral.scv(data[:,0], fs, nperseg=int(fs),noverlap=noverlap)
plt.loglog(freqs,scv)
plt.plot(data[:,0])<jupyter_output><empty_output><jupyter_text>EEG  data access<jupyter_code>data_path ="/Users/Lauren/Data/NeuroTycho/EEGECoG/20110607S1_EEGECoG_Su_Oosugi-Naoya+Nagasaka-Yasuo+Hasegawa+Naomi_ECoG128-EEG18_mat/EEG01.mat"
matfile = io.loadmat(data_path, squeeze_me=True)
data = matfile['EEG2']
data
data.shape[1]/fs<jupyter_output><empty_output><jupyter_text>PSD &scv<jupyter_code>fs = 4096
nperseg = fs
noverlap = nperseg/2
start = 0
end = 1
session_num = 1
f_axis, f_time, spg = sig.spectrogram(data, fs=fs, nperseg=nperseg, noverlap=nperseg/2)

# plot psd
_ = plt.loglog(np.mean(spg,axis=0))
scv = spectral.scv(data, fs, nperseg=int(fs),noverlap=noverlap)
scv[1]
_ = plt.loglog(scv[1].T)<jupyter_output><empty_output><jupyter_text>ECoG Visual Grating<jupyter_code>data_path = "/Users/Lauren/Data/NeuroTycho/VisualGrating/20100723S1_VGT_K2_KazuhitoTakenaka-ToruYanagawa_mat_ECoG128-Event3/"
from codes import access_nt as asc
session = 0
#chan = np.arange(1,129).tolist()
chan = [1]
data = asc.get_ECoG(data_path, session, chan)
fs = 1000
nperseg = 1000
noverlap = nperseg/2
start = 0
end = 1
session_num = 1
f_axis, f_time, spg = sig.spectrogram(data, fs=fs, nperseg=nperseg, noverlap=nperseg/2)

# plot psd
_ = plt.loglog(np.mean(spg,axis=0))
scv = spectral.scv(data, fs, nperseg=int(fs),noverlap=noverlap)
_ = plt.plot(scv[1][0])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13097713097713098, 'fraction_numerical': 0.04158004158004158, 'mean_word_length': 5.6958250497017895, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '16798', 'license': 'MIT', 'n_tokens_mistral': 1551, 'n_tokens_neox': 1468, 'n_words': 262, 'path': 'old_code/notebooks_preprocessing/exploratory_newdata.ipynb', 'repo_name': 'voytekresearch/sca', 'size': '3389'}