It looks like you have data in a CSV or TSV file. You can read such files using numpy.loadtxt… you’ll probably need to do it twice (once for the column headings and once for the data:
import numpy as np
ch_names = np.loadtxt('my_data.txt', max_rows=1, dtype=str).tolist()
data = np.loadtxt('my_data.txt', skiprows=1)
Then you can use mne.create_info and our Array constructor mne.io.RawArray to convert those into a Raw object. Note that you’ll also need to know the sampling frequency, and will probably want to specify something other than ch_types='misc' when you call create_info
Hi @drammock thank for your reply. Can you clarify about data structure, how do I structure the data in my excel file so that I can read it in mne library. That is why I want to open the data from mne dataset with a external software to understand the data structure
The FIFF format is very complicated and I strongly recommend that you do not try to create a FIFF file yourself. Even looking at an existing FIFF file will probably not be helpful, because we have ways to make MNE-Python objects from NumPy arrays (as I mentioned above) which are much safer and easier than trying to do it yourself.
Based on your screenshot, your data is probably already in a suitable arrangement (channel names in the first row, data for each channel in columns below that). The first step is to export from Excel as a CSV file. Then you can proceed with the commands I offered above. Did you try them yet?
Hi @drammock I am very close to solve this problem. I have a little problem only
When I use the next code:
import numpy as np
import mne
ch_names = np.loadtxt('dataset.txt', max_rows=1, dtype=str).tolist()
data = np.loadtxt('dataset.txt', skiprows=1)
print("len", (data.shape)) # (7120, 8)
sfreq = 2000
info = mne.create_info(ch_names, sfreq, ch_types='eeg', verbose=None)
print ("ch", len(info["ch_names"])) # 8
raw = mne.io.RawArray(data, info)
I receive the next error
“ValueError: len(data) (7120) does not match len(info[“ch_names”]) (8)”
I can solve it with the next code, but I think that it is not correct
data = np.reshape(data, (8, 7120))
Because after that this parts of code, not operate
raw.plot_psd(fmax=50) # 50
raw.plot(duration=5, n_channels=8)
ica = mne.preprocessing.ICA(n_components=20, random_state=97, max_iter=800)
ica.fit(raw)
ica.exclude = [1, 2] # details on how we picked these are omitted here
ica.plot_properties(raw, picks=ica.exclude)
Can you clarify, which format is correct for data?
Hi Drammock, thank you so much for your reply, now is better. Only, can you clarify, where I need add information about Channel location?
I have the next error
“RuntimeWarning: Channel locations not available. Disabling spatial colors.”
I tried used this type