Skip to content

Error opening a raw file that is converted from epoch file #2

@apoorva6262

Description

@apoorva6262

Hi @jackz314 , I am getting an error on eeglab when I open a raw.set file that was earlier converted from an epoch.set file. I was trying to convert an existing epoch file(.set) to non-epoched file (.set) .

Here is a sample file that I opened as a raw object and then saved it as an epoch.set file locally. I then opened the epoch.set file separately and created a raw.set file again to get rid of the epochs (https://mne.discourse.group/t/converting-epoch-file-to-non-epoch-file/3421) . I tried opening this new raw.set file on eeglab and gave me an error (attached image).

Also, if you run this all at the same time, then the error does not show up on eeglab. But if you save the epoch.set file locally and then open it and convert it to a non-epoched file and then you get an error on eeglab.

import os
import mne
from mne.datasets import sample
from eeglabio.utils import export_mne_raw
from eeglabio.utils import export_mne_epochs
sample_data_folder = mne.datasets.sample.data_path()
sample_data_raw_file = os.path.join(sample_data_folder, 'MEG', 'sample',
'sample_audvis_filt-0-40_raw.fif')
raw = mne.io.read_raw_fif(sample_data_raw_file)
raw.crop(tmax=60).load_data()
raw.pick(['EEG 0{:02}'.format(n) for n in range(41, 60)])
epochs = mne.make_fixed_length_epochs(raw, duration=1, preload=True)
export_mne_epochs(epochs, "epoch_name.set")


import mne
from eeglabio.utils import export_mne_raw
epoch_set=mne.io.read_epochs_eeglab('/Users/Desktop/epoch_name.set')
sfreq=epoch_set.info['sfreq']
ch_names=epoch_set.info['ch_names']
ch_types = ['eeg'] * 19
info = mne.create_info(ch_names=ch_names, ch_types=ch_types, sfreq=sfreq)
epoch=epoch_set.get_data()
n_epochs, n_channels, n_times = epoch.shape
data=epoch.transpose([1, 0, 2]).reshape((n_channels, n_epochs * n_times))
raw= mne.io.RawArray(data, info)
export_mne_raw(raw, "new_file_no_epoch.set")


Screenshot 2021-07-22 at 21 10 49

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions