#!/usr/bin/python import sys from getopt import getopt def show_help(): print "mat2ftsv - Matlab matrix to laydi dataset converter." print print "Usage: mat2ftsv [ ...]" print print "Description: For each mat file given as input, a ftsv file" print " will be created with the same name, but suffixed with.ftsv" print " in addition to .mat or any other suffix already on the" print " file name." options, params = getopt(sys.argv[1:], 'h', ['help']) for opt, val in options: if opt in ['-h', '--help']: show_help() sys.exit(0) if len(params) == 0: show_help() sys.exit(0) from scipy import io from numpy import ndarray from laydi import dataset fn_in = params[0] data = io.loadmat(fn_in) for key, value in data.items(): if isinstance(value, ndarray): ds = dataset.Dataset(value, name=key) dataset.write_ftsv(fn_in + '.ftsv', ds)