Hi everyone!
I’m currently working on a project where I utilize SPoC to extract EEG spatial patterns from EMG data. I am having some trouble with figuring out the best way to do so and was hoping I would be able to find some clarity here.
My first approach is to do a log transformation on the EMG data to help with outliers and take the first principle component. Then I am between taking the variance per trial or the sum power per trial as my EMG feature for the SPoC decomposition. This is because I am working with Epoched data with dimensions (648, 61, 1200) for EEG (with 100 sfreq) and (648, 2400) for EMG (with 200 sfreq) which would give me the dimension (648,) for the EMG as the target.
Here is the documentation for the SPoC fit(X, y) parameters:
X ndarray, shape (n_epochs, n_channels, n_times)
y array, shape (n_epochs,)
This seems to work for both the sum power and variance methods - however; I find it strange to only have one value per epoch to extract these patterns from. Thus I decided to try the fit_transform(X, y, **fit_params) method which has parameters:
X array, shape (n_samples, n_features)
y array, shape (n_samples,)
giving a target value for each sample. So I downsampled my EMG data to match the EEG data with 100 sfreq, performed the log transformation, and took the first PC from the EMG and then flattened both (n_epochs * n_times) so the dimensions are now: (777600, 61) for EEG and (777600,) for EMG.
However, when I do the following:
spoc = SPoC(n_components=6, reg=0.001)
spoc_data = spoc.fit_transform(flattened_eeg, flattened_emg)
I get the following which seems to contradict the documentation:
ValueError: X must have at least 3 dimensions.
Has anyone else run into this issue? Do you have advice if I should stick with my first method (and if so with the sum power or rather the variance?) or continue along this avenue?
I am using:
- MNE version: mne==1.7.0
- operating system: macOS Sonoma 14.2.1
Any help is very much appreciated! Thank you ![]()