Skip to content
Patricia Wollstadt edited this page Jul 18, 2018 · 1 revision

IDTxl provides a set of simple import functions for various file formats. To import data from MATLAB files (.mat) into IDTxl's data format, use the import_matarray() function.

The import function reads MATLAB's hdf5 files ("-v7.3" or higher) as well as earlier, non-hdf5 files. The mat file must contain a single array only. Additionally, the array name and the orientation of the array has to be provided (which dimension represents samples, replications, and processes).

Import IO functions

from idtxl import idtxl_io as io

Read mat-file and return Data() object

Example: 1D MATLAB array, v7.3

data = io.import_matarray(
    file_name='test/data/one_dim_v7_3.mat),
    array_name='a',  # name of the array saved in the mat file
    dim_order='s',  # 1D, where entries along the first dim represent samples
    file_version='v7.3',  # file version
    normalise=False)  # don't normalise data when instantiating the data object

Example: 1D MATLAB array, v7.3

data = io.import_matarray(
    file_name='test/data/three_dim_v7_3.mat',
    array_name='c', # name of the array saved in the mat file
    dim_order='rsp',  # 3D, where order of dims is replications, samples, processes
    file_version='v7.3',  # file version
    normalise=False)  # don't normalise data when instantiating the data object

Example: 2D MATLAB array, v4

data = io.import_matarray(
        file_name='test/data/two_dim_v4.mat',
        array_name='b', # name of the array saved in the mat file
        dim_order='ps',  # 3D, where order of dims is processes. samples
        file_version='v4',  # file version
        normalise=False)  # don't normalise data when instantiating the data object