A LuaJIT FFI interface to MATIO and simple bindings for torch
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 24 commits behind soumith:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
dev
test
LICENSE
README.md
cdefs.lua
defines.lua
ffi.lua
init.lua
matio-scm-1.rockspec

README.md

matio-ffi

A LuaJIT interface to MATIO

Installation

First, make sure MATIO is installed on your system. This package only requires the binary shared libraries (.so, .dylib, .dll). Please see your package management system to install MATIO. You can also download and compile matio from MATIO web page

# OSX
brew install libmatio

# Ubuntu
sudo apt-get install libmatio2
luarocks install matio

Usage

###Load a tensor from matlab array

local matio = require 'matio'
-- load a single array from file
tensor = matio.load('test.mat', 'var_a')
-- load multiple arrays from file
tensors = matio.load('test.mat',{'var1','var2'})
-- load all arrays from file
tensors = matio.load('test.mat')

###Load structs, cell arrays and strings

There is some basic support for more complex data structures defined by the MAT file format. Structs will be converted to lua tables, indexed by their field names. Cell arrays are converted tua lua arrays (tables indexed by numerals).

local matio = require 'matio'
-- load a struct, which contains tensors, cell arrays and strings
my_complex_data = matio.load('test.mat')

If you want to read sequences of characters as lua strings instead of Torch CharTensor, enable the following flag:

matio.use_lua_strings = true
-- load data
data_with_strings = matio.load('test.mat')

Calling MATIO C functions

All MATIO C functions are available in the matio.ffi. namespace returned by require. The only difference is the naming, which is not prefixed by Mat_ anymore.

For example, look at matio.load in init.lua