[Eeglablist] EEGlab Import events on loop - error

bruno.de at ovgu.de bruno.de at ovgu.de
Thu Jul 2 07:17:27 PDT 2020


Dear list members,

I want my code to load all .set files in a folder  
(['E:\PM_Frequency\EEG\2_correctTriggers\), then import the events  
from .csv files  
('E:\\PM_Frequency\\EEG_log_files\\EEG_Log_Files_Renamed\\') into the  
loaded .set files and save them into another directory  
('E:\\PM_Frequency\\EEG_Data_To_Epoch\\').
It works fine when using the GUI, so I've used the history function  
from matlab:
clc
clear
sub = [01, 02, 03, 04, 05, 06, 07, 08, 09, 10:44];
run = [1:3];
% Loop between all subjects and runs
for i = sub;
     for j = run;
         if  
exist(['E:\PM_Frequency\EEG\2_correctTriggers\',sprintf('p0%i_%i.set',  
i,j)]);
             EEG = pop_loadset('filename',sprintf('p0%i_%i.set',  
i,j),'filepath','E:\\PM_Frequency\\EEG\\2_correctTriggers\\');
             [ALLEEG, EEG, CURRENTSET] = eeg_store( ALLEEG, EEG, 0);
             EEG = eeg_checkset( EEG );
             new_file_name = [EEG.setname];
             EEG = pop_importevent( EEG,  
'append','no','event','E:\\PM_Frequency\\EEG_log_files\\EEG_Log_Files_Renamed_3_Columns\\',sprintf('p0%i_%i.csv', i,j),'fields',{'latency' 'type'  
'duration'},'skipline',1,'timeunit',1);
             [ALLEEG, EEG] = eeg_store(ALLEEG, EEG, CURRENTSET);
             EEG = eeg_checkset( EEG );
             EEG = pop_saveset( EEG,  
'filename',new_file_name,'filepath','E:\\PM_Frequency\\EEG_Data_To_Epoch\\');
             EEG = pop_saveset( EEG, 'filename',sprintf('p0%i_%i.set',  
i,j),'filepath','E:\\PM_Frequency\\EEG_Data_To_Epoch\\');
             [ALLEEG EEG] = eeg_store(ALLEEG, EEG, CURRENTSET);
         else
             %do nothing
         end
     end
end

But I've received the following error message after executing the code:

pop_loadset(): loading file  
E:\\PM_Frequency\EEG\2_correctTriggers\p01_1.set ...
Reading float file 'E:\\PM_Frequency\EEG\2_correctTriggers\p01_1.fdt'...
Undefined function or variable 'ALLEEG'.

Error in set_events_using_log_files (line 16)
             [ALLEEG, EEG, CURRENTSET] = eeg_store( ALLEEG, EEG, 1);

If I delete this line:
             [ALLEEG, EEG, CURRENTSET] = eeg_store( ALLEEG, EEG, 0 );

I would really appreciate any help,

Cheers,

Bruno





More information about the eeglablist mailing list