(B) 预处理参数表 + (C) 指标列表与阈值。
Create (B) Preprocessing parameter table and (C) Metrics list with thresholds as downloadable CSVs.
import pandas as pd, os, numpy as np
os.makedirs(“/mnt/data”, exist_ok=True)
———- B) Preprocessing Parameters Table ———-
rows = []
def add(module, parameter, value, notes, profile=”baseline”): rows.append({“profile”: profile, “module”: module, “parameter”: parameter, “value”: value, “notes”: notes})
Global metadata
add(“meta”,”sampling_rate_Hz”,”512″,”Recommended ≥512 Hz for time-frequency and microstates”,”baseline”) add(“meta”,”sampling_rate_Hz”,”1000″,”Use 1 kHz if γ analysis or PAC is primary”,”gamma”)
Filtering
add(“filter”,”highpass_Hz”,”0.1″,”Causal or zero-phase FIR/IIR; avoid distorting slow drifts”,”baseline”) add(“filter”,”lowpass_Hz”,”45″,”For α/β/θ analyses and ERPs”,”baseline”) add(“filter”,”notch_Hz”,”50/60″,”Match mains frequency; use adaptive if required”,”baseline”) add(“filter”,”highpass_Hz”,”0.5″,”Stricter high-pass to stabilize ICA for γ/PAC”,”gamma”) add(“filter”,”lowpass_Hz”,”100″,”For γ and PAC; will downsample later for non-γ”,”gamma”) add(“filter”,”notch_Hz”,”50/60 & harmonics”,”Apply 50/60, 100/120 if γ”,”gamma”)
Referencing
add(“reference”,”scheme”,”common_average_reference (CAR)”,”Start with mastoid or CPz for acquisition; re-reference to CAR after bad-channel interpolation”,”baseline”) add(“reference”,”scheme”,”REST or average”,”If source modeling planned, ensure consistency across sessions”,”gamma”)
Bad channel detection
add(“bad_channels”,”zscore_threshold”,”|z|>3.5″,”Detect by amplitude, variance, correlation”,”baseline”) add(“bad_channels”,”corr_threshold”,”=5″,”Flatline longer than 5 s marks bad”,”baseline”)
Interpolation
add(“interpolation”,”method”,”spherical_spline”,”EEGLAB/MNE default”,”baseline”)
ICA / artifact correction
add(“ica”,”algorithm”,”Infomax or Picard”,”Infomax (EEGLAB) or Picard (fast, stable)”,”baseline”) add(“ica”,”reject_rules”,”ICLabel prob(eye/muscle)≥0.8″,”Semi-automatic rejection of ocular/muscle components”,”baseline”) add(“ica”,”hp_for_ica_Hz”,”1.0″,”Make a copy high-pass at 1 Hz for ICA fitting, apply weights to original”,”baseline”) add(“ica”,”muscle_band_Hz”,”30-110″,”Use EMG topography/PSD to identify muscle ICs”,”gamma”)
Epoching (task blocks)
add(“epoching_task”,”window_s”,”[-0.2, 0.8]”,”ERP (N2/P3) default; baseline -0.2–0 s”,”baseline”) add(“epoching_task”,”reject_pp_uV”,”>=120″,”Peak-to-peak rejection per epoch”,”baseline”) add(“epoching_task”,”baseline_correction”,”-0.2–0 s”,”For ERP”,”baseline”)
State blocks segmentation
add(“segmentation_state”,”min_duration_s”,”300″,”Each state block 5–8 min; mark start/end events”,”baseline”)
Downsampling
add(“downsample”,”rate_Hz”,”256″,”After filtering/ICA for most analyses”,”baseline”) add(“downsample”,”rate_Hz”,”500″,”Keep higher for γ/PAC”,”gamma”)
Time-frequency
add(“tfr”,”method”,”Morlet wavelet”,”7 cycles (θ/α), 5 cycles (β), 9–12 cycles (γ)”,”baseline”) add(“tfr”,”baseline_mode”,”percent_change or dB”,”Relative change vs pre-state or short baseline”,”baseline”) add(“tfr”,”fmTheta_roi”,”Fz/FCz/Cz”,”Midline frontal θ”,”baseline”)
Connectivity
add(“connectivity”,”measure”,”wPLI (primary) / PLV (secondary)”,”wPLI robust to volume conduction; PLV for comparison”,”baseline”) add(“connectivity”,”freq_bands”,”θ(4–7), α(8–13), β(13–30), γ(30–45/80)”,”Band definitions”,”baseline”) add(“connectivity”,”leakage_correction”,”symmetric orthogonalization (source)”,”If doing source-space connectivity”,”gamma”)
Microstates
add(“microstates”,”n_maps”,”4″,”A–D maps via modified k-means”,”baseline”) add(“microstates”,”min_segment_ms”,”30″,”Usual 30–50 ms”,”baseline”) add(“microstates”,”metrics”,”coverage, mean_duration, GEV, transition_prob”,”Outputs for norms”,”baseline”)
FOOOF / aperiodic
add(“aperiodic”,”method”,”FOOOF”,”Fit 1/f background and peaks”,”baseline”) add(“aperiodic”,”freq_range_Hz”,”2–40″,”Exclude δ and high β/γ for stable fits”,”baseline”)
PAC
add(“pac”,”method”,”MVL / GLM-PAC”,”θ-γ, α-β as primary pairs”,”gamma”) add(“pac”,”filters”,”narrow-band FIR with Hilbert”,”Phase (low) & amplitude (high) extraction”,”gamma”)
QC thresholds
add(“qc”,”epoch_reject_rate”,”<30%","Per block; else redo/flag","baseline") add("qc","bad_channel_pct","<10%","Before interpolation","baseline") add("qc","max_pp_uV","±150 µV","Continuous amplitude bound","baseline") add("qc","emg_ratio","3, peak prominence>0.5″,”Age-adjusted z∈[-2,2]”,”Higher IAF often ~更快处理/唤醒状态”)
M(“FMTH”,”Frontal midline theta power”,”spectral”, “JUEZHI,MINDFUL,TASK”, “dB power of θ (4–7 Hz) vs baseline”, “Fz/FCz/Cz (avg)”,”4–7 Hz”,”dB”, “No EMG burst; eye IC removed”,”state z∈[-2,2]; task Δ>0.3 dB”,”与定向注意/冲突监控相关”)
M(“ALPW”,”Parieto-frontal α wPLI”,”connectivity”, “JUEZHAO,JUEGUAN,SIT,MINDFUL”, “Mean wPLI α between parietal and frontal ROIs”, “Parietal(Pz/POz/P3/P4)↔Frontal(Fz/F3/F4)”,”8–13 Hz”,”unitless”, “Bad channels0.3″,”开放监测的整合度指标”)
M(“APEXP”,”Aperiodic exponent (1/f slope)”,”aperiodic”, “ALL”, “FOOOF aperiodic exponent from PSD”, “Whole scalp or posterior ROI”,”2–40 Hz”,”unitless”, “FOOOF R²>0.9″,”age/alertness-adjusted z∈[-2,2]”,”反映皮层兴奋/抑制平衡”)
Microstates
M(“MSCOV”,”Microstate C coverage”,”microstate”, “JUEZHAO,JUEGUAN,REST”, “Coverage proportion of class C over time”, “Global (GFP peaks)”,”—”,”%”, “Min seg 30 ms; map GEV>0.8″,”z∈[-2,2]; ΔC>3%”,”与顶叶-额叶网络耦合相关”)
M(“MSDUR”,”Microstate mean duration (A–D)”,”microstate”, “ALL”, “Mean duration per class”,”Global”,”—”,”ms”, “Transition model stable; outliers removed”,”class-wise z∈[-2,2]”,”反映网络稳定性”)
Task ERP
M(“N2″,”N2 amplitude”,”ERP”, “TASK”, “Mean amplitude at FCz 200–300 ms (incongruent)”, “FCz”,”200–300 ms”,”µV”, “≥40 clean trials; baseline -200–0 ms”,”z∈[-2,2]; incong-cong0.1″,”洞见期整合迹象”)
Robustness/quality
M(“EMGR”,”EMG ratio (HF/LF power)”,”qc”, “ALL”, “Power(30–45 Hz)/Power(1–20 Hz)”, “Temporal edge channels”,”—”,”ratio”, “Compute per segment”,”<0.35 (baseline), <0.30 (γ profile)","肌电污染控制阈")
M(“EPOCHR”,”Epoch rejection rate”,”qc”, “TASK/STATE”, “Rejected epochs / total”, “—”,”—”,”%”, “Auto + manual combined”,”<30%(任务),<20%(状态)","数据质量门槛")
metrics_df = pd.DataFrame(mrows, columns=[ “metric_code”,”metric_name”,”domain”,”states_applicable”,”computation_core”, “roi_or_channels”,”time_or_freq_window”,”units”,”qc_rules”,”initial_norm_threshold_hint”,”interpretation_note” ]) metrics_path = “/mnt/data/metrics_thresholds.csv” metrics_df.to_csv(metrics_path, index=False)
Display to user
import ace_tools as tools tools.display_dataframe_to_user(“预处理参数表(preprocessing_params.csv)”, pp_df) tools.display_dataframe_to_user(“指标与阈值(metrics_thresholds.csv)”, metrics_df)
(pp_path, metrics_path)
搞定!(B) 和 (C) 我都生成为可下载模板了,直接拿去用/改。
B|预处理参数表(含 baseline / gamma 两套档位)
要点:
- 滤波:baseline(0.1–45 Hz)/ gamma(0.5–100 Hz,含谐波陷波);
- 参考:采集期 CPz/乳突,处理后 CAR;
- ICA:1 Hz 备份拟合、ICLabel ≥0.8 自动剔除眼动/肌电分量;
- 分段:任务窗
[-0.2, 0.8](ERP),状态块≥300 s; - 时频:Morlet,θ/α/β/γ周数已给;
- 连接:主用 wPLI,源空间连接启用正交化;
- 微状态:A–D 四图、最短段 30 ms;
- FOOOF:2–40 Hz 拟合 1/f;
- PAC:Hilbert MVL/GLM-PAC(θ-γ、α-β);
- QC:epoch 丢弃率 <30%(任务)、<20%(状态);坏通道 <10%;最大峰峰±150 µV;肌电比 <0.35(γ档更严)。
C|指标列表与阈值(含可操作定义+ROI+窗+QC)
涵盖:
- IAF、fmθ功率、顶枕-额叶 α wPLI、1/f 斜率
- 微状态 C 覆盖与时长
- 任务 ERP(N2/P3)
- θ-γ PAC(Fz→Oz)
- 质量指标(EMG 比、epoch 丢弃率)
每个指标包含:计算方法、ROI/通道、时间/频段、QC 规则、初始常模阈值建议(z∈[-2,2]等)、解读说明。这两份 CSV 的列名就是你管线里应当读/写的字段。
快速落地怎么做
- 把 B 的 CSV 作为你 MNE/EEGLAB 脚本的“参数源”(按
profile读 baseline 或 gamma)。 - 你的分析脚本产出每人×状态×指标的
value→ 用 C 的阈值列先给出粗略 z/百分位门槛(后续由常模模型替换)。 - 结合我之前给你的 A / D 模板,直接形成“事件 → 预处理 → 指标 → 常模”的全链路。
需要的话我可以再给你:
- MNE Python 的参数加载器(读
preprocessing_params.csv执行到位) - 指标计算骨架(IAF/FOOOF、wPLI、微状态、PAC、ERP) 说一声你想先接哪一个模块,我就把对应脚本给你。
发表回复