Hi all. Is it possible to load a malab figure using io.loadmat. It works well with a matrix saved as mat file, but if I try to load a fig file I get the following output: scipy.io.loadmat('test2.mat') {'a': 'Read error: Cannot read matlab functions', '__version__': '1.0', '__header__': 'MATLAB 5.0 MAT-file, Platform: GLNX86, Created on: Sat Aug 4 16:56:09 2012', '__globals__': []}
I use scipy shipped with the Debian stable repositories. Thanks. Petro.
Le samedi 04 août 2012 à 17:48 +0200, x.piter@gmail.com a écrit :
Hi all. Is it possible to load a malab figure using io.loadmat. It works well with a matrix saved as mat file, but if I try to load a fig file I get the following output: scipy.io.loadmat('test2.mat') {'a': 'Read error: Cannot read matlab functions', '__version__': '1.0', '__header__': 'MATLAB 5.0 MAT-file, Platform: GLNX86, Created on: Sat Aug 4 16:56:09 2012', '__globals__': []}
I use scipy shipped with the Debian stable repositories. Thanks.
Are not matlab figure supposed to be .fig files ? The 'a' items of the resulting dictionary seems weird. I can load (with loadmat, Debian unstable) matlab figure files, but the trouble is in converting the whole tree stored in the file into some matplotlib (or similar) instances... -- Fabrice Silva
Hi Fabrice Silva <silva@lma.cnrs-mrs.fr> writes:
Are not matlab figure supposed to be .fig files ? The 'a' items of the resulting dictionary seems weird. I was not sure if fig files are compartiple with loadmat, so I had loaded figure in matlab with -mat key and saved the structure a.mat I can load (with loadmat, Debian unstable) matlab figure files, but the trouble is in converting the whole tree stored in the file into some matplotlib (or similar) instances... This is another trouble but I will think about it when I reach this stage (I need only numbers). May be I need the latest scipy.
Regards Petro
Le dimanche 05 août 2012 à 11:50 +0200, x.piter@gmail.com a écrit :
Hi Fabrice Silva <silva@lma.cnrs-mrs.fr> writes:
Are not matlab figure supposed to be .fig files ? The 'a' items of the resulting dictionary seems weird. I was not sure if fig files are compartiple with loadmat, so I had loaded figure in matlab with -mat key and saved the structure a.mat
Debian unstable ships scipy 0.10 which succeed in loading .fig files. Example : In [1]: import scipy; scipy.__version__ Out[1]: '0.10.1' In [2]: import scipy.io as io In [3]: d = io.loadmat('AR.fig', squeeze_me=True, struct_as_record=False); d.keys() Out[3]: ['hgS_070000', '__version__', '__header__', '__globals__'] Note the hgS_* magic key indicating matlab v7 figure type In [4]: print d['__header__'] MATLAB 5.0 MAT-file, Platform: GLNXA64, Created on: Fri Jul 6 13:43:19 2012 In [5]: print d['hgS_070000'].type figure You then need to introspect through the structured hierarchy to extract your data In [6]: print d['hgS_070000'].children.type axes In [7]: print d['hgS_070000'].children.children.shape (43,) In [8]: print d['hgS_070000'].children.children[0].type graph2d.lineseries In [9]: dir(d['hgS_070000'].children.children[0].properties) Out[9]: ['ApplicationData', 'CodeGenColorMode', 'CodeGenLineStyleMode', 'CodeGenMarkerMode', 'Color', 'LineWidth', 'ObeyXDataMode', 'OldSwitchProps', 'OldSwitchVals', 'SwitchProps', 'XData', 'XDataJitter', 'XDataMode', 'XDataSource', 'YData', 'YDataSource', 'ZDataSource', '__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__slotnames__', '__str__', '__subclasshook__', '__weakref__', '_fieldnames'] Getting X and Y arrays for the first line of the first axes In [10]: X = d['hgS_070000'].children.children[0].properties.XData In [11]: Y = d['hgS_070000'].children.children[0].properties.YData In [12]: import matplotlib.pyplot as plt In [13]: plt.plot(X,Y) Out[13]: [<matplotlib.lines.Line2D at 0xa164b8c>]
This is another trouble but I will think about it when I reach this stage (I need only numbers). May be I need the latest scipy.
Have you seen the note at the end of this page, concerning v7.3 format not handled by scipy 0.7 (also neither by recent versions) ? http://docs.scipy.org/doc/scipy-0.7.x/reference/generated/scipy.io.loadmat.h... -- Fabrice Silva <silva@lma.cnrs-mrs.fr> LMA UPR CNRS 7051
Fabrice Silva <silva@lma.cnrs-mrs.fr> writes:
Le dimanche 05 août 2012 à 11:50 +0200, x.piter@gmail.com a écrit :
Have you seen the note at the end of this page, concerning v7.3 format not handled by scipy 0.7 (also neither by recent versions) ? http://docs.scipy.org/doc/scipy-0.7.x/reference/generated/scipy.io.loadmat.h... Yes, I have seen it and tried to load different version of figures, none of them worked. Now I try to install scipy 10.1 instead of default 7th version, so far without success.
Le dimanche 05 août 2012 à 18:52 +0200, Petro a écrit :
Fabrice Silva <silva@lma.cnrs-mrs.fr> writes:
Le dimanche 05 août 2012 à 11:50 +0200, x.piter@gmail.com a écrit :
Have you seen the note at the end of this page, concerning v7.3 format not handled by scipy 0.7 (also neither by recent versions) ? http://docs.scipy.org/doc/scipy-0.7.x/reference/generated/scipy.io.loadmat.h... Yes, I have seen it and tried to load different version of figures, none of them worked. Now I try to install scipy 10.1 instead of default 7th version, so far without success.
Could you post a complete minimal example (with the file, and traceback) ? -- Fabrice Silva
Hi, On Sun, Aug 5, 2012 at 11:31 AM, Fabrice Silva <silva@lma.cnrs-mrs.fr> wrote:
Le dimanche 05 août 2012 à 18:52 +0200, Petro a écrit :
Fabrice Silva <silva@lma.cnrs-mrs.fr> writes:
Le dimanche 05 août 2012 à 11:50 +0200, x.piter@gmail.com a écrit :
Have you seen the note at the end of this page, concerning v7.3 format not handled by scipy 0.7 (also neither by recent versions) ? http://docs.scipy.org/doc/scipy-0.7.x/reference/generated/scipy.io.loadmat.h... Yes, I have seen it and tried to load different version of figures, none of them worked. Now I try to install scipy 10.1 instead of default 7th version, so far without success.
Could you post a complete minimal example (with the file, and traceback) ?
An example would be very good. It looks like figure file have matlab functions inside, which we can't do much with, because the format is rather opaque. They should load OK though, in recent scipy versions. Did you succeed in installing scipy 10.1? Best, Matthew
participants (4)
-
Fabrice Silva -
Matthew Brett -
Petro -
x.piter@gmail.com