- MNE version: 1.7.1_0
- operating system: Windows 11
Hi, I’m trying to use MNE for time-frequency analysis. My data is in .cfs form and it is collected using Signal. I’m trying to figure out the best way to import my data in a usable way. Will it work just with this file type? Do I need to somehow change the file type? I can export it as .txt or .mat as well.
Hey @squidguy3400
Assuming that MNE-Python doesn’t have a reader for this filetype, you want to take a look at Creating MNE-Python data structures from scratch — MNE 1.8.0.dev133+g868746b42 documentation
The gist is that you will need to:
- Pass a list of the channel names, a list of the channel types (e.g. “eeg”), and the sampling frequency, to mne.create_info
- Get your data into a numpy array. If you export your data to .mat format, you may be able to use pymatreader for this. Just make sure your numpy array has a shape
(n_channels, n_samples).
- pass the
info object you created in step 1, and the numpy array to mne.io.RawArray
Thanks for the help. If I may ask, how can I change my numpy array shape? the current shape is (samples[450641], channels[11]) and I can’t seem to reshape it using
my_array.reshape([11,450641])
No worries. The easiest way is probably just to use the transpose method (.T for short):
import numpy as np
my_data = np.random.rand(450641, 11)
my_data = my_data.T
Make sure you are assigning the transposed array back into a variable, like I did above. Numpy doesn’t modify your array “in-place”, it always returns a copy.
EDIT: I probably shouldn’t say always copies, I just mean that when you do my_array.T or my_array.reshape(...), the result is not persistent, so you need to pass that result into some variable.