Save source estimates in BIDS derivatives using mne-bids :
from mne_bids import write_anat write_anat(bids_root, subject='001', t1w_anat='sub-001_T1w.nii.gz') Assuming you have one evoked response per subject per condition:
import mne def preprocess_raw(raw, l_freq=0.1, h_freq=40, notch=50): """ Apply standard EEG preprocessing. Adjust parameters for MEG (e.g., high-pass 1 Hz, low-pass 100 Hz). """ # 1. Filter (bandpass) raw.filter(l_freq, h_freq, fir_design='firwin', verbose=True) mne bids pipeline
For group analysis, save evoked data in BIDS-derivatives:
t_obs, clusters, p_values, H0 = cluster_stats Use a configuration file (YAML) # config.yaml subjects: ['001', '002', '003'] task: 'visual' preprocessing: l_freq: 0.1 h_freq: 40 notch: 50 epochs: tmin: -0.2 tmax: 0.8 baseline: [-0.2, 0] Python script with argparse import yaml, argparse from mne_bids import BIDSPath, read_raw_bids def main(subject, config): # load config # run pipeline for one subject pass Save source estimates in BIDS derivatives using mne-bids
# 3. Interpolate bad channels (defined in BIDS channels.tsv) # MNE automatically reads 'status' column as bad if 'bad' is present. raw.interpolate_bads(reset_bads=True)
from mne_bids import read_raw_bids bids_path = BIDSPath( subject='001', session='01', task='visual', suffix='eeg', root=bids_root, ) Filter (bandpass) raw
with open(args.config, 'r') as f: config = yaml.safe_load(f) main(args.subject, config)