Functions

src/io_matlab.c File Reference

#include "io_matlab.h"
#include <matio.h>

Go to the source code of this file.

Functions

double get_double_from_struct_field (matvar_t *eeg, const char *name, int struct_array_index)
Arrayread_array_matlab (const char *file, const char *varname)
 read a MATLAB-array from a .mat file.
EEGread_eeglab_file (const char *file)
 read EEG struct from EEGlab (MATLAB) .set-file.
int write_array_matlab (const Array *a, const char *varname, const char *file, bool append)
 save Array-struct as MATLAB .mat file.
int write_eeglab_file (EEG *eeg, const char *file)
 write EEG-struct to EEGlab-compatible MATLAB file.

Function Documentation

double get_double_from_struct_field ( matvar_t *  eeg,
const char *  name,
int  struct_array_index 
)

Definition at line 275 of file io_matlab.c.

Array* read_array_matlab ( const char *  file,
const char *  varname 
)

read a MATLAB-array from a .mat file.

Todo:
Currently, the returned array is always DOUBLE.
Parameters:
file the .mat file
varname the name of the variable in the .mat file; can be NULL, in this case the first variable is read.
Returns:
the Array-struct or NULL in case an error occurred

Definition at line 204 of file io_matlab.c.

EEG* read_eeglab_file ( const char *  file  ) 

read EEG struct from EEGlab (MATLAB) .set-file.

This reader uses MatIO to parse EEGlab files and construct a LibEEGTools EEG struct. It was developed with EEGlab version 6.01b.

Currently, the EEGlab set must be "epoched", that means that the data must be three-dimensional with channels x n x trials. Continuous data is not yet supported and the reader will fail.

The reader currently works only if the storage is in single .set file (as opposed to a pair of .set and .dat file).

Parameters:
file eeglab .set file
Returns:
the EEG struct

Definition at line 45 of file io_matlab.c.

int write_array_matlab ( const Array a,
const char *  varname,
const char *  file,
bool  append 
)

save Array-struct as MATLAB .mat file.

Currently, the function converts all arrays to double-arrays. Should be easy to implement for arbitrary types if needed.

Parameters:
a the Array
varname MATLAB-name of the array
file the filename
append if TRUE, the function tries to open() the file, else it is overwritten
Returns:
error code

Definition at line 330 of file io_matlab.c.

int write_eeglab_file ( EEG eeg,
const char *  file 
)

write EEG-struct to EEGlab-compatible MATLAB file.

This write uses MatIO to create an EEGlab file. It was developed with EEGlab version 6.01b.

Todo:
NOT IMPLEMENTED!
Parameters:
eeg the struct
file eeglab .set file
Returns:
error code

Definition at line 303 of file io_matlab.c.