[Eeglablist] script for importing .mat files

James Desjardins jdesjardins at brocku.ca
Fri Jan 2 20:55:32 PST 2015


Hi Muhammad,

I have a "batch_context" extension for EEGLab available at github here: https://github.com/jadesjardins/batch_context.

I have posted an example of its use on youtube here: https://www.youtube.com/watch?v=KKuX-k5hF1A. The demo closely resembles what you are trying to achieve, except in the case of the demo the input files are *.bdf.

I am not familiar with the pop_read_gtec function but I expect that it can accept a file name as a input and then output the EEG structure. This is important for it to be compatible with uninterrupted batch processing. I expect that you could call the function as follows:

EEG=pop_read_gtec(EEG,'C:\\Users\\Documents\\MATLABfiles\\EEG_Data\\Test\\myfile_1_raw.mat');

... or something like that, depending on what it expects as the file name input...

You can use the "Download ZIP" button at the github repository then extract the folder to your "plugins" folder within the EEGLab folder structure.

To execute a history template batching script follow the example in the demo video.

If my guess about pop_read_gtec file name input is correct your *.htb script should be as follows:



EEG=pop_read_gtec(EEG,'[batch_dfp]\\[batch_dfn]);
EEG = eeg_checkset( EEG );
EEG = pop_chanevent(EEG, 65,'edge','leading','edgelen',0);
EEG = eeg_checkset( EEG );
EEG = pop_saveset( EEG, 'filename','[batch_dfn,.,-1].set','filepath','C:\\Users\\Documents\\MATLABfiles\\EEG_Data\\Test\\');
EEG = eeg_checkset( EEG );



Assuming that your input file names are something like S###_Oddball.mat, if you copy the above script to a text file and name it *.htb and then execute it on all of your *.mat files (like in the demo) it will generate new *.set & *.fdt pairs (assuming your eeglab settings) that simply replace the extensions of the input file names and places them in 'C:\\Users\\Documents\\MATLABfiles\\EEG_Data\\Test\\'.

If you try this and run into problems don't hesitate to contact me directly to help troubleshoot.

The batch_context script execution will not hesitate to overwrite files, so of course, always work on backed up copies.

I hope this is helpful.


James Desjardins, MA
Electrophysiology Technologist
Cognitive and Affective Neuroscience Lab, Psychology Department
Jack and Nora Walker Centre for Lifespan Development Research
High Performance Computing Consultant
SHARCNet, Compute/Calcul Canada

Brock University
500 Glenridge Ave.
St. Catharines, ON, Canada L2S 3A1
905-688-5550 x4676
--
"'Cause you never can tell What goes on down below!
"This pool might be bigger Than you or I know!"

McElligot's Pool
Dr.Seuss 1947
________________________________
From: eeglablist-bounces at sccn.ucsd.edu [eeglablist-bounces at sccn.ucsd.edu] on behalf of Muhammad Adeel Parvaz [mparvaz at gmail.com]
Sent: January-01-15 11:11 PM
To: eeglablist at sccn.ucsd.edu
Subject: [Eeglablist] script for importing .mat files

Hi,

I am new to EEGLAB. I have an EEG data (.mat) that I can successfully import it in EEGLAB, use the last channel (#65) to load events and then save the data as a .set and .fdt pair. However, I have about 80 of these files and I would like to repeat these 3 processes to each of these files. I looked into doing it through GUI on the first file and then using the dataset history to get the commands for each step and applying to other files, but I am not quite sure how to do that.

By the way, I can manually import a bunch of files and then run the history commands to automatically perform the other two steps. So, the automatic import seems to be the limiting factor. I would ideally like the script to run through the directory and perform these steps on each file.

My command history for one dataset looks like this:

pop_read_gtec(ALLEEG) % importing function supplied by the vendor
EEG = eeg_checkset( EEG );
EEG = pop_chanevent(EEG, 65,'edge','leading','edgelen',0);
EEG = eeg_checkset( EEG );
EEG = pop_saveset( EEG, 'filename','S001_Oddball.set','filepath','C:\\Users\\Documents\\MATLABfiles\\EEG_Data\\Test\\');
EEG = eeg_checkset( EEG );

Any and every help would be much appreciated.

Thanks and a happy new year!

-Muhammad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sccn.ucsd.edu/pipermail/eeglablist/attachments/20150103/973365b8/attachment.html>


More information about the eeglablist mailing list