aolabNeuro / aolabNeuro/analyze

coherence calculations

オープン
#274 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
enhancement
主要言語
Python
スター
7
フォーク
0
平均マージ
22時間 29分
マージ済み PR(30日)
2

説明

patrick wrote these functions, they should be added here to aopy.analysis

```
def calc_avg_coherence(lfp_fef, lfp_m1, samplerate):
cohere_elecs = []
f_elecs = []
for fef_elec in range(lfp_fef.shape[1]):
for m1_elec in range(lfp_m1.shape[1]):
f, coh = signal.coherence(lfp_fef[:, fef_elec], lfp_m1[:, m1_elec], fs=samplerate)
cohere_elecs.append(coh)
f_elecs.append(f)
cohere_avg = np.average(np.stack(cohere_elecs, axis=0), axis=0)
return f_elecs[0], cohere_avg

def calc_coherence_bands(f, coh):
bands = {
"delta": (0, 4),
"theta": (4, 10),
"alpha": (8, 12),
"beta": (12, 30),
"gamma": (60, 150),
}
coh_bands = {}
for key, val in bands.items():
indices = (f >= val[0]) & (f <= val[1])
band_val = np.average(coh[indices])
coh_bands[key] = band_val
return coh_bands

def calc_coherence_bands_by_pairs(lfp_fef, lfp_m1, samplerate):
bands = {
"delta": np.array([]),
"theta": np.array([]),
"alpha": np.array([]),
"beta": np.array([]),
"gamma": np.array([]),
}
for fef_elec in range(lfp_fef.shape[1]):
for m1_elec in range(lfp_m1.shape[1]):
f, coh = signal.coherence(lfp_fef[:, fef_elec], lfp_m1[:, m1_elec], fs=samplerate)
coh_bands = calc_coherence_bands(f, coh)
for k, v in coh_bands.items():
bands[k] = np.append(bands[k], v)
return bands


def calc_avg_correlation(lfp_fef, lfp_m1):
lfp_mat = np.concatenate((lfp_fef, lfp_m1), axis=1)
print(lfp_mat.shape)
corr = np.corrcoef(lfp_mat.T)
return corr
```

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。