Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
apoorva6262 opened this issue Jul 23, 2021 · 1 comment
Open

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

apoorva6262 opened this issue Jul 23, 2021 · 1 comment

Comments

@apoorva6262
Copy link

apoorva6262 commented Jul 23, 2021

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

@alexrockhill
Copy link

You might want to just load this in to EEGLAB and save it out as a edf, might save a lot of trouble, sounds like a pretty niche case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants