Unable to open scipy.io.savemat mat file
Dickon Humphrey
dickon.humphrey at kcl.ac.uk
Thu Jul 9 14:24:59 CDT 2009
John W. Eaton wrote:
> On 8-Jul-2009, Dickon Humphrey wrote:
>
> | John W. Eaton wrote:
> | > On 7-Jul-2009, Dickon Humphrey wrote:
> | >
> | > | Bug report for Octave 3.2.0 configured for i686-pc-mingw32
> | > |
> | > | Description:
> | > | -----------
> | > |
> | > | Octave will not open a mat file saved using scipy.io.savemat. I believe
> | > | the version of scipy used is 0.7.0, which has recently been reworked.
> | > | The release notes for scipy 0.7.0 state:
> | > |
> | > | The Matlab (TM) file readers/writers have a number of improvements:
> | > |
> | > | * default version 5
> | > | * v5 writers for structures, cell arrays, and objects
> | > | * v5 readers/writers for function handles and 64-bit integers
> | > | * new struct_as_record keyword argument to ``loadmat``, which loads
> | > | struct arrays in matlab as record arrays in numpy
> | > | * string arrays have ``dtype='U...'`` instead of ``dtype=object``
> | > |
> | > | The error I get when opening the attached file is:
> | > |
> | > | > load D66_TH_Dcr2_POLG-RNAi-A2_small.mat
> | > | error: unable to resize object to fewer than 2 dimensions
> | > |
> | > | The code that produces the mat file is the 'WriteMAT' function in the
> | > | attached python file from an application called Ctrax
> | > | (http://developer.berlios.de/projects/ctrax/ ).
> | > |
> | > | Repeat-By:
> | > | ---------
> | > |
> | > | > load <file exported by scipy.io.savemat>.mat
> | >
> | > Instead of sending a scipy script, how about sending a (small) .mat
> | > file created by scipy that shows the problem?
> | >
> | > jwe
> | >
> | Sorry, our mail server here stripped out the mat file. Please find
> | attached a zipped version.
>
> OK. I checked in the following change.
>
> http://hg.savannah.gnu.org/hgweb/octave/rev/434ae96dc10f
>
> Thanks,
>
> jwe
>
Great. Just speaking to the developer of Ctrax, they said:
"Scipy changed the way mat files are saved by default. I'm
guessing this is the source of confusion. The change that I noticed
was that the variables had previously been stored as row vectors and
were now being stored as column vectors. Looking at the doc page for
scipy.io.savemat, it looks like it is still saving the files in a
form compatible with matlab 5+
http://docs.scipy.org/doc/scipy-0.7.x/reference/generated/scipy.io.sa...
<http://docs.scipy.org/doc/scipy-0.7.x/reference/generated/scipy.io.savemat.html#scipy.io.savemat>.
All the variables are stored as column vectors. Since column vectors
are N x 1, I'm wondering if the mat file just stores the N (which is
how numpy/scipy work in python) and Matlab assumes the 1 by default,
but octave does not."
I also found that I could import the same mat file if I first imported
and then exported it using scipy version 0.8.0.dev5698 in the enthought
python distribution.
Thanks for looking at this,
Dickon
--
Post Doctoral Researcher
MRC Centre for Neurodegeneration Research
King's College London
Institute of Psychiatry PO 37
16 De Crespigny Park
London SE5 8AF
Tel.: 0207 848 5375
Fax.: 0207 708 0017
dickon.humphrey at kcl.ac.uk
http://www.iop.kcl.ac.uk
More information about the Bug-octave
mailing list