matlabstr2py

tifffile.matlabstr2py(matlabstr, /)

Return Python object from Matlab string representation.

Use to access ScanImage metadata.

Parameters:

matlabstr (str) – String representation of Matlab objects.

Returns:

Matlab structures are returned as dict. Matlab arrays or cells are returned as lists. Other Matlab objects are returned as str, bool, int, or float.

Return type:

Any

Examples

>>> matlabstr2py('1')
1
>>> matlabstr2py("['x y z' true false; 1 2.0 -3e4; NaN Inf @class]")
[['x y z', True, False], [1, 2.0, -30000.0], [nan, inf, '@class']]
>>> d = matlabstr2py(
...     "SI.hChannels.channelType = {'stripe' 'stripe'}\n"
...     "SI.hChannels.channelsActive = 2"
... )
>>> d['SI.hChannels.channelType']
['stripe', 'stripe']