def session1(bread, data_path, chan, fs, nperseg, noverlap): """ storing session 1 into bread (the 3D array) for a monkey. Parameters ---------- bread : array-like 3d data into a 3d array. data_path : String set the path. chan : integer grab the particular channel. fs : array-like 1d frequency. nperseg : integer desired window per segment. noverlap : integer desired overlapping of window. Returns ------- bread : array-like 3d return the session 1 stored into bread data- frequency x channel x condition. """ # session 1 for i in range(1, chan): #grabbing session 1 channel i data = getECoGdata(data_path, 1, i) #grabbing TimeFile from session 1 to set the indices for each condition tf1 = getTimeFile(data_path, 1) # AwakeEyesOpened s1start1 = int(getStart(tf1, 0) * fs) s1end1 = int(getEnd(tf1, 1) * fs) bread[0][i - 1][:] = spectral.scv(data[s1start1:s1end1], fs, nperseg=int(fs), noverlap=noverlap, outlierpct=5.)[1] #print(fs, s1start1, s1end1) #print(len(f_), f_) #print(len(scv_), scv_) #print(len(spectral.scv(data[s1start1:s1end1],fs,nperseg=int(fs),noverlap=noverlap)[0])) #print(len(spectral.scv(data[s1start1:s1end1],fs,nperseg=int(fs),noverlap=noverlap)[1])) #print(bread.shape) #AwakeEyesClosed s1start2 = int(getStart(tf1, 2) * fs) s1end2 = int(getEnd(tf1, 3) * fs) #s1SP2 = getSP(data, s1start2, s1end2, fs, nperseg, noverlap) bread[1][i - 1][:] = spectral.scv(data[s1start2:s1end2], fs, nperseg=int(fs), noverlap=noverlap, outlierpct=5.)[1] return bread
def session2(bread, data_path, chan, fs, nperseg, noverlap): """ storing session 2 into bread (the 3D array) for a monkey. Parameters ---------- bread : array-like 3d data into a 3d array. data_path : String set the path. chan : integer grab the particular channel. fs : array-like 1d frequency. nperseg : integer desired window per segment. noverlap : integer desired overlapping of window. Returns ------- bread : array-like 3d return the session 2 stored into bread data- frequency x channel x condition. """ # session 2 for i in range(1, chan): if ('0730PF' in data_path and i == 63): bread[2][i - 1][:] = "Nan" bread[3][i - 1][:] = "Nan" else: #grabbing session 2 channel i data = getECoGdata(data_path, 2, i) #grabbing TimeFile from session 2 to set the indices for each condition tf2 = getTimeFile(data_path, 2) #Anesthetized-Start s2start1 = int(getStart(tf2, 1) * fs) s2end1 = int(getEnd(tf2, 2) * fs) bread[2][i - 1][:] = spectral.scv(data[s2start1:s2end1], fs, nperseg=int(fs), noverlap=noverlap, outlierpct=5.)[1] #RecoveryEyesClosed s2start2 = int(getStart(tf2, 3) * fs) s2end2 = int(getEnd(tf2, 4) * fs) #s2SP2 = getSP(data, s2start2, s2end2, fs, nperseg, noverlap) bread[3][i - 1][:] = spectral.scv(data[s2start2:s2end2], fs, nperseg=int(fs), noverlap=noverlap, outlierpct=5.)[1] return bread
def test_scv(): """ Confirm SCV calculation """ # Load data data_idx = 1 x = _load_example_data(data_idx=data_idx) fs = 1000. # load ground truth scv gt_scv = np.load(os.path.dirname(neurodsp.__file__) + '/tests/data/sample_data_' + str(data_idx) + '_scv.npz') # compute SCV freq, SCV = spectral.scv(x, fs) assert np.allclose(np.sum(np.abs(gt_scv['freq'] - freq)), 0, atol=10 ** -5) assert np.allclose(np.sum(np.abs(gt_scv['SCV'] - SCV)), 0, atol=10 ** -5)
def session3(bread, data_path, chan, fs, nperseg, noverlap): """ storing session 3 into bread (the 3D array) for a monkey. Parameters ---------- bread : array-like 3d data into a 3d array. data_path : String set the path. chan : integer grab the particular channel. fs : array-like 1d frequency. nperseg : integer desired window per segment. noverlap : integer desired overlapping of window. Returns ------- bread : array-like 3d return the session 3 stored into bread data- frequency x channel x condition. """ # session 3 for i in range(1, chan): #grabbing session 3 channel i data = getECoGdata(data_path, 3, i) #grabbing TimeFile from session 3 to set the indices for each condition tf3 = getTimeFile(data_path, 3) # RecoveryEyesOpened s3start = int(getStart(tf3, 0) * fs) s3end = int(getEnd(tf3, 1) * fs) #s3SP = getSP(data, s3start, s3end, fs, nperseg, noverlap) bread[4][i - 1][:] = spectral.scv(data[s3start:s3end], fs, nperseg=int(fs), noverlap=noverlap, outlierpct=5.)[1] return bread