Forum Developers Cortex API Conversion of .CSV file into MNE-Python Object

Tagged: 

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #736
    Upadhayay Bibek
    Participant
    @ibibek-612674a0db0ef

    Hello,

    I am wondering if there is any built-in method or an alternative or some Github repo, that contains the example where the exported EEG data in CSV file can be converted to the MNE-Python object.

    #739
    luckham jerill
    Participant
    @starex12-6058fa0f16135

    Hello Bibek.  Thank you for your question.  You can try this string:

    import mne
    import numpy as np
    import pandas as pd

    df = pd.read_csv(“<path to psychopy_recording>.csv.gz”)
    for c in df.columns:
    print(c)

    eeg_channels = [‘AF3’, ‘T7’, ‘Pz’, ‘T8’, ‘AF4’] # get from the columns printed above
    sampling_frequency = 1 / (df[‘timestamp’][df.shape[0]-1] – df[‘timestamp’][df.shape[0]-2])
    print(eeg_channels)
    ch_types = [‘eeg’] * len(eeg_channels)
    info = mne.create_info(eeg_channels, ch_types=ch_types, sfreq=sampling_frequency)
    info.set_montage(‘standard_1020’)

    data = np.array(df.loc[:,eeg_channels])
    mne_object = mne.io.RawArray(data.T, info)
    mne_object.plot(show_scrollbars=False, show_scalebars=False)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.