(filename)
return {k: todict(v) for k, v in data.iteritems()}
Loads mat files with hierarchies as nested dictionaries
Loads mat files with hierarchies as nested dictionaries
Loads mat files with hierarchies as nested dictionaries
def loadmat(filename):
    '''Loads mat files with hierarchies as nested dictionaries'''
    def todict(d):
        if isinstance(d, sio.matlab.mio5_params.mat_struct):
            return {name: todict(d.__dict__[name]) for name in d._fieldnames}
        elif isinstance(d, np.ndarray) and d.dtype == np.object:
            return np.vectorize(todict)(d)
        return d

    data = sio.loadmat(filename, struct_as_record=False, squeeze_me=True, mat_dtype=True)
    return {k: todict(v) for k, v in data.iteritems()}
def loadmat ( filename ) : def todict ( d ) : if isinstance ( d , sio . matlab . mio5_params . mat_struct ) : return { name : todict ( d . __dict__ [ name ] ) for name in d . _fieldnames } elif isinstance ( d , np . ndarray ) and d . dtype == np . object : return np . vectorize ( todict ) ( d ) return d data = sio . loadmat ( filename , struct_as_record = False , squeeze_me = True , mat_dtype = True ) return { k : todict ( v ) for k , v in data . iteritems ( ) }