- 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
i have a problem using Amica scripts
16 views (last 30 days)
Show older comments
i am working on eeg data preprocessing, and i want to use the Amica algorithm to clean clean my data but i am having trouble with the script. i think the issue comes from the data extension i am using, (.mat). i cannot just change it into .set file to confirm if that is the issue.
another thing is that while running the scripts with (.mat), i get some results then it stops with errors, i've tried finding solutions to this issue but with no success.
i am using EEGLAB plugin AMICA1.7
here is the code:
load('E:\Documents\essay\filtered_data.mat')
%[weights,sphere,mods] = runamica15(dat,'Key1',Value1,...);
outdir = [pwd filesep 'amicaouttmp' filesep];
W =[];
S =[];
[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);
0 Comments
Answers (1)
Prasanna
on 23 Oct 2024
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:
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!