Saving brain vision eeg file after pre-processing

Hi, I am trying to work with EEG data that I need to utilise for multimodal fusion. Since my EEG data is in the .eeg format, I have used MNE python for filtering and resampling my data as is required for my research. I have basically just used a simple function for resampling the EEG data after reading the raw BrainVision files. My question now is, how can I save the pre-processed files locally?

Here’s a snippet of the code:

import mne
import glob

file_list = glob.glob('D:/EEG+Eye_data_classification/Data' + '/*.vhdr')


def read_data(file):
    raw_fname = mne.io.read_raw_brainvision(file, eog=('EOG1', 'EOG2', 'EOG3'), preload=True, verbose=False)
    channel_loc = mne.channels.make_standard_montage("standard_1020")
    raw_fname.rename_channels({"Ref2": "A2"})
    mne.set_eeg_reference(raw_fname, ['A2'])
    raw_fname.set_montage(channel_loc)
    raw = raw_fname.copy()
    filter = raw.filter(l_freq=1., h_freq=45.)
    filter.notch_filter(freqs=49)
    downsampled_data = filter.resample(100.)

    return downsampled_data

I have 51 files in total including the header and marker files for the Brain Vision data. Thank you in advance !

Hello, you can use raw.save() to save to a .fif file, and raw.export() for exporting to BV and other formats:

https://mne.tools/stable/generated/mne.io.Raw.html#mne.io.Raw.export

Best wishes,
Richard

2 Likes

Thank you so much! I could export the files.