Problem running ICA on data with multiple discontinuous epochs

4 views (last 30 days)
Hello everyone,
I have been using EEGLab ICA Infomax algorithm on single epoch continuous data using the runica.m script (not the GUI). I have not had an issue with the continuous data but when I use the same runica. m script on multiple epoch data (channel X frames X epochs) runica.m script gives an error which is related to the use of transpose operation. I believe the problem is due to multiple epoch data being 3D and "transpose" operation not being suitable for 3D arrays.
More specifically the error is
Error using '
TRANSPOSE does not support N-D arrays. Use PAGETRANSPOSE/PAGECTRANSPOSE to transpose pages or PERMUTE to reorder dimensions
of N-D arrays.
Error in runica (line 625)
rowmeans = mean(data,2)'; %BLG
I can get away with this error by using the squeeze function after mean. But then I have the same error later in the script when sphering matrix is generated which also requires transposing the data.
I would be grateful if I can have some insights from anyone as to how fix this problem.#
Cigdem

Answers (2)

Prasanna
Prasanna on 26 Feb 2024
Hi Cigdem,
It is my understanding that you are performing ICA using EEGLAB’s “runica” function and is facing an error while using “runica” on multiple epoch data with regards to the transpose operator.
The error you're encountering occurs because MATLAB's transpose operator ' is designed to work with 2D matrices, not with N-dimensional arrays (where N > 2). When you attempt to use the transpose operator on a 3D array, MATLAB does not know how to handle the operation because transposing is inherently a two-dimensional concept.
The error in EEGLAB's runica.m occurs because MATLAB's transpose operator ' can't handle the 3D array from your EEG data epochs. After using mean, you get a 2D matrix with a singleton dimension, which MATLAB still treats as 3D, causing an error when transposing.
When you encounter the error with the sphering matrix, you'll need to handle the 3D array appropriately. The sphering matrix is typically calculated on the covariance matrix, which is a 2D matrix, so ensure that you are correctly reshaping or slicing your 3D data into a 2D format before generating the sphering matrix.
To solve the issue, replace the transpose operation with permute or pagetranspose, wherever the transpose operation is causing an error to correctly handle the 3D data. Please refer to the following documentation links to obtain more information on the same:
In summary, the error is due to the incompatibility of the transpose operation with N-D arrays, and the solution involves using functions like “pagetranspose” and “permute” designed to handle multi-dimensional data.
I hope this helps,
Regards,
Prasanna

Cigdem Gelegen van Eijl
Cigdem Gelegen van Eijl on 28 Feb 2024
Thank you Prasanna
Sometimes I found it difficult to use EEGLab scripts outside the GUI - with your suggestion and looking a bit further into it - it works ok now
regards Cigdem

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!