Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Returns
-------
dict
Time and data
Examples
--------
>>> tname, names = read_names('data.mat')
>>> data = read_data('data.mat', [tname, *names])
>>> t = data[tname] # time
>>> x1 = data[names[0]] # first data series
"""
# ignore the data field (if it exists) which contains the time series data in
# latest file format
data = read_mat(path)
if "chan_names" in data.keys():
# latest exhange format based on v.7.3 mat files
data = dict(zip(data["chan_names"], np.transpose(data["data"])))
else:
# exhange format based on v.7.2 mat files
ignored = ["comment", "fs", "test_num", "test_date", "__header__", "__version__", "__globals__"]
data = {k: v for k, v in data.items() if k not in ignored}
if names is not None:
return {k: v for k, v in data.items() if k in names}
else:
return data