i have a problem using Amica scripts

조회 수: 16 (최근 30일)
Odette Imo
Odette Imo 2023년 9월 7일
답변: Prasanna 2024년 10월 23일
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);

답변 (1개)

Prasanna
Prasanna 2024년 10월 23일
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:

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by