Is it possible to make fixed length epochs on existing epoched file ? I currently have an EEG file that has epochs of length 30s each. I need to preprocess this file and run autoreject. To do so, I need to make 1s length epochs and then run autoreject. Is there a way I can create more epochs on the existing file ?
Sorry, yes I did use epochs. Then it gave me an error that it is 3d and data must be 2d. So I tried using epochs.transpose.reshape and then it gave me an error that ‘EpochsFIF’ object has no attribute ‘transpose’
please give us the exact lines of code that you ran as well as the error traceback. Also, some general advice:
different kinds of data objects have different methods. NumPy arrays allow things like my_array.transpose() but MNE-Python Epochs objects do not have a .transpose() method. If you type the name of your variable in an iPython console and push . and then the tab key, you can get a pop-up of all its available methods and attributes. That can help you avoid trying things that won’t work (like my_epochs.transpose()… because “transpose” won’t be one of the available options that pops up). Here’s an example:
in MNE-Python, the actual data (the numbers representing voltage X in channel Y at time Z) are stored in a NumPy array that is part of a larger object that also contains other data (like channel positions, etc). From any MNE-Python object you can always do my_object.get_data() or my_object.data if you need direct access to the NumPy array, but do not confuse the (Raw, Epochs, Evoked) object for the data array that it contains.
glad you got it working! One more tiny suggestion: instead of doing epoch=epochs.get_data(), use a more descriptive variable name like epoch_data or data_array or similar. Having 2 variables called “epoch” and “epochs” implies that they are both the same type of object, differing in how many trials they include. In your code, however, one is a mne.Epochs object and the other is a numpy.ndarray object, and both of them contain all trials… so the variable names are misleading and make it easier to get confused.