save_matfile#
- class braintools.file.save_matfile(filename, data, verbose=False, **kwargs)[source]#
Save a dictionary of variables to a MATLAB
.matfile via scipy.This is the counterpart of
load_matfile(). It is a thin, validated wrapper aroundscipy.io.savemat().- Parameters:
filename (
str|PathLike) – Destination path for the.matfile.data (
Dict[str,Any]) – Mapping from MATLAB variable names (str) to array-like values.verbose (
bool) – If True, print saving information. Defaults to False.**kwargs – Additional keyword arguments passed to
scipy.io.savemat()(e.g.do_compression,oned_as,format).
- Raises:
TypeError – If filename is not path-like, or data is not a dict.
ValueError – If saving fails.
See also
load_matfileLoad a MATLAB .mat file.
scipy.io.savematUnderlying MATLAB file writer.
- Return type:
Examples
>>> import numpy as np >>> save_matfile('out.mat', {'x': np.arange(3), 'label': 'trial-1'})