Hi Odette,
The error obtained usually occurs when you are having NaN or Inf values in your EEG data when using the AMICA algorithm which uses the ‘svd’ function. To debug the issue, check for NaN or Inf values in the data before running the Amica algorithm and handle them appropriately. Also, ensure that the data is pre-processed correctly before running the AMICA algorithm.
A sample MATLAB code to check for and handle NaN or inf values in your data is as below:
% Load the data
load('E:\Documents\essay\filtered_data.mat');
% Check for NaN or Inf values
if any(isnan(X(:))) || any(isinf(X(:)))
disp('Data contains NaN or Inf values.');
% Replace NaN or Inf values with the mean of the non-NaN/Inf values
X(isnan(X)) = mean(X(~isnan(X)));
X(isinf(X)) = mean(X(~isinf(X)));
end
outdir = [pwd filesep 'amicaouttmp' filesep];
% Run AMICA
[mods, weights, sphere] = runamica15(X, 'num_models', 1, 'num_mix_comps', 4, ...
'max_iter', 2000, 'share_start', 100, 'do_history', 1, 'histstep', 5, ...
'outdir', outdir);
You can also ensure your data is properly pre-processed before running AMICA by performing filtering, artifact removal and normalization using the corresponding functions from EEGLAB. Also, ensure that the data matrix is structured as channels by time points, as AMICA expects data in this format. For more information on the above used functions, refer to the following documentations:
- isnan: https://www.mathworks.com/help/matlab/ref/double.isnan.html
- isinf: https://www.mathworks.com/help/matlab/ref/double.isinf.html
- ismissing: https://www.mathworks.com/help/matlab/ref/ismissing.html