RESS output shape appears to be (samples, trials) instead of (samples, channels, trials)
Hororohoruru opened this issue · 6 comments
Hello!
I've been trying the recent RESS implementation of the library, and I am a bit puzzled at the output. The documentation on the ress function specifies that the input data should be in (samples, channels, trials) shape, and so it's done in the example script.
After trying with my own data of shape (3500, 32, 40), I get an output of shape (3500, 40). I also inspected a bit the code of the example, and the output for the simulated (1000, 10, 50) shaped data is also a (1000, 50) shaped array. From my understanding of the MATLAB implementation, I assumed the output would be the same shape as the input, but with the RESS components applied. Maybe I am missing something or the output of the RESS function is intended to be projected to the data, but I did not find any clues looking around the code.
Thanks in advance!
Hi @Hororohoruru,
data of shape (3500, 32, 40)
RESS will by default output a single (best) component. Therefore an input data of shape (n_samples, n_channels, n_trials)
will result in an output of shape (n_samples, 1, n_trials)
, which is squeezed into (n_samples, n_trials)
(for no particular reason except convenience)
You can specify how many components to keep using the n_keep
parameter.
This is absolutely identical to the Matlab implementation.
Maybe what caused the confusion is that the Matlab example also outputs so-called "maps" in order to plot topographies. These maps are also computed in my code (see here), except they're not provided in the function's output. I could provide a return_maps
argument if that is useful to you.
Ok, understood! The confusion came from my assumption that the output of the function will be the data array with the component backprojected on it.
The only addition I would like to suggest to the implementation is for the n_keep parameter to allow the function to return all components. You can close! Thank you very much.
Ok, will do. I'll also add some details on how to backproject to sensor space in the docstring.
Hey @Hororohoruru , can you have a look at #20 ? This should improve things for you.
n_keep = -1
now keeps all components.
The RESS output is now always (n_samples, n_keep, n_trials)
(not squeezing singleton dimensions anymore).
I'm also outputting an unmixing matrix to backproject to sensor space. Here's an example showing how to do that:
https://github.com/nbara/python-meegkit/blob/nb/fix-issue-19/examples/example_ress.ipynb
Sorry for the late reponse, the code works perfectly! Also the example was very ilustrative in how to backproject the data. Thank you very much once again.