Hello!
I am trying to decompose with AMICA 54 to 165 recordings of EEG (10-40 minutes long). The recordings are not standardized, are from different patients and in different conditions, so I believe AMICA is the only viable option for cleaning the data.
There are 21 channels and 250/256 sampling rate.
But it seems like they are not linking when I run the script and I cannot figure out why. I run the script, I save it from the EEGLab interface and when I open the sets the next time, it says there is no ICA weights.
Where can I change the script to make it work?
Thank you!
% Path for results
output_path = 'C:\EEGLAB\amica_out';
% Loop through all loaded datasets in EEGLAB
for i = 1:length(ALLEEG)
EEG = ALLEEG(i); % Current dataset
outdir = fullfile(output_path, sprintf('amica_output_dataset_%d', i));
try
% AMICA
[mods, weights, sphere] = runamica15(EEG.data, ... % Use EEG.data for input
'num_models', 1, ...
'num_mix_comps', 4, ...
'max_iter', 2000, ...
'share_start', 100, ...
'do_history', 0, ... % Disable history to avoid related errors
'max_threads', 7, ... % Number of threads based on the core of the PC
'outdir', outdir);
% Validate output
if isempty(weights) || isempty(sphere) || ~isfield(mods, 'W')
error('Incomplete AMICA results for dataset %d.', i);
end
% Store results in EEG structure
EEG.icaweights = weights;
EEG.icasphere = sphere;
EEG.icawinv = pinv(weights * sphere); % Compute inverse
EEG.amica = mods; % Store full AMICA model
% Save updated dataset back to ALLEEG
[ALLEEG, EEG, CURRENTSET] = eeg_store(ALLEEG, EEG, i);
fprintf('AMICA completed for dataset %d.\n', i);
catch ME
fprintf('Error running AMICA on dataset %d: %s\n', i, ME.message);
continue; % Skip to the next dataset
end
% Clear variables for the next iteration
clear EEG mods weights sphere;
end
Hello!
I am trying to decompose with AMICA 54 to 165 recordings of EEG (10-40 minutes long). The recordings are not standardized, are from different patients and in different conditions, so I believe AMICA is the only viable option for cleaning the data.
There are 21 channels and 250/256 sampling rate.
But it seems like they are not linking when I run the script and I cannot figure out why. I run the script, I save it from the EEGLab interface and when I open the sets the next time, it says there is no ICA weights.
Where can I change the script to make it work?
Thank you!
% Path for results
output_path = 'C:\EEGLAB\amica_out';
% Loop through all loaded datasets in EEGLAB
for i = 1:length(ALLEEG)
EEG = ALLEEG(i); % Current dataset
outdir = fullfile(output_path, sprintf('amica_output_dataset_%d', i));
try
% AMICA
[mods, weights, sphere] = runamica15(EEG.data, ... % Use EEG.data for input
'num_models', 1, ...
'num_mix_comps', 4, ...
'max_iter', 2000, ...
'share_start', 100, ...
'do_history', 0, ... % Disable history to avoid related errors
'max_threads', 7, ... % Number of threads based on the core of the PC
'outdir', outdir);
end