x.piter | 4 Aug 2012 17:48
Picon

loadmat and figure

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.
Fabrice Silva | 4 Aug 2012 18:13
Picon
Favicon

Re: loadmat and figure

Le samedi 04 août 2012 à 17:48 +0200, x.piter <at> 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

_______________________________________________
SciPy-User mailing list
SciPy-User <at> scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user
x.piter | 5 Aug 2012 11:50
Picon

Re: loadmat and figure

Hi
Fabrice Silva <silva <at> 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
Fabrice Silva | 5 Aug 2012 12:29
Picon
Favicon

Re: loadmat and figure

Le dimanche 05 août 2012 à 11:50 +0200, x.piter <at> gmail.com a écrit :
> Hi
> Fabrice Silva <silva <at> 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
(Continue reading)

Petro | 5 Aug 2012 18:52
Picon

Re: loadmat and figure

Fabrice Silva <silva <at> lma.cnrs-mrs.fr> writes:

> Le dimanche 05 août 2012 à 11:50 +0200, x.piter <at> 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.html#scipy.io.loadmat
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.

_______________________________________________
SciPy-User mailing list
SciPy-User <at> scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user
Fabrice Silva | 5 Aug 2012 20:31
Picon
Favicon

Re: loadmat and figure

Le dimanche 05 août 2012 à 18:52 +0200, Petro a écrit :
> Fabrice Silva <silva <at> lma.cnrs-mrs.fr> writes:
> 
> > Le dimanche 05 août 2012 à 11:50 +0200, x.piter <at> 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.html#scipy.io.loadmat
> 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

_______________________________________________
SciPy-User mailing list
SciPy-User <at> scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user
Matthew Brett | 10 Aug 2012 21:57
Picon
Gravatar

Re: loadmat and figure

Hi,

On Sun, Aug 5, 2012 at 11:31 AM, Fabrice Silva <silva <at> lma.cnrs-mrs.fr> wrote:
> Le dimanche 05 août 2012 à 18:52 +0200, Petro a écrit :
>> Fabrice Silva <silva <at> lma.cnrs-mrs.fr> writes:
>>
>> > Le dimanche 05 août 2012 à 11:50 +0200, x.piter <at> 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.html#scipy.io.loadmat
>> 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

Gmane