# who can help me solve this problem?

• MNE version: e.g. 1.3.1
• operating system: Windows 11

this is my code:
import mne
import numpy as np
from scipy.signal import hilbert

print(mne.version)

# 加载数据集

data_path = mne.datasets.sample.data_path()
raw_fname = data_path / ‘MEG’ / ‘sample’ / ‘sample_audvis_raw.fif’

# 选择感兴趣的电极和频段

picks = mne.pick_types(raw.info, meg=True, eeg=False, exclude=‘bads’)
raw.filter(low_cut=8., high_cut=12., method=‘iir’) # 正确的参数名
epochs = mne.Epochs(raw, events=None, event_id=None, tmin=-0.5, tmax=0.5, picks=picks, preload=True)

# 计算两个通道之间的PLV

def compute_plv(signal1, signal2):
# 计算信号的解析信号
analytic_signal1 = hilbert(signal1)
analytic_signal2 = hilbert(signal2)

``````# 计算瞬时相位
instant_phase1 = np.unwrap(np.angle(analytic_signal1))
instant_phase2 = np.unwrap(np.angle(analytic_signal2))

# 计算相位差
phase_diff = instant_phase1 - instant_phase2

# 计算PLV
plv = np.abs(np.mean(np.exp(1j * phase_diff)))

return plv
``````

# 初始化PLV矩阵

n_channels = len(epochs.ch_names)
plv_matrix = np.zeros((n_channels, n_channels))

# 计算所有通道对之间的PLV

for i in range(n_channels):
for j in range(i + 1, n_channels):
# 获取通道信号
signal1 = epochs.get_data()[:, i, :]
signal2 = epochs.get_data()[:, j, :]

``````    # 计算PLV
plv = compute_plv(signal1, signal2)

# 存储PLV值（因为PLV是对称的，所以只存储上三角矩阵）
plv_matrix[i, j] = plv
plv_matrix[j, i] = plv
``````

and this is the result:
1.3.1
Opening raw data file C:\Users\jie\mne_data\MNE-sample-data\MEG\sample\sample_audvis_raw.fif…
Read a total of 3 projection items:
PCA-v1 (1 x 102) idle
PCA-v2 (1 x 102) idle
PCA-v3 (1 x 102) idle
Range : 25800 … 192599 = 42.956 … 320.670 secs
Reading 0 … 166799 = 0.000 … 277.714 secs…
Traceback (most recent call last):
File “D:/brain_wave/PLV.py”, line 21, in
raw.filter(low_cut=8., high_cut=12., method=‘iir’) # 正确的参数名
TypeError: filter() got an unexpected keyword argument ‘low_cut’

Process finished with exit code 1

so who can help me slove this problem?

Filter doesn’t have keywords (low_cut and high_cut) – change it to `raw.filter(l_freq=8., h_freq=12.0, .....) `

``````Signature:
raw.filter(
l_freq,
h_freq,
``````

–Jeff

2 Likes

(1) browse the documentation website: MNE — MNE 1.6.1 documentation and especially the API reference Python API Reference — MNE 1.6.1 documentation for explicit errors `got an unexpectted (...) argument`.
(2) to format your code when posting a question (Ctrl + E or tool in the editor bar)

Mathieu

2 Likes

apart from the recommendations that @mscheltienne gave above, I would also recommend that you take the time to formulate a concise question, instead of merely supplying a code example.

Example for a good question title (picked semi-randomly from the current front page):

→ Here, users already know the question will deal with:

• EDF files (raw)
• file IO
• concatenation of files

Whereas “who can help me solve this problem” doesn’t say a lot about what you need.

Good luck!

3 Likes