[ANN] MAT.jl v0.11 -- classes and struct arrays

MAT.jl v0.11 release

After almost 1.5 years since the release of v0.10.7, we have managed to make some big improvements to MAT.jl in v0.11.0.
:birthday_cake:
Please try it out and report back to us if you find any issues :slight_smile:

Breaking changes

Unfortunately some breaking changes to support better writing:

  • Read MatlabStructArray instead of a Dict{String,Any} with Array{Any,N} values
  • Read MatlabClassObject instead of a Dict{String,Any} with "class" key

New features

But you gain these wonderful features:

  • Write MatlabStructArray; my personal reason to contribute, see the object array docs for more info
  • Write MatlabClassObject; these are old types of MATLAB classes stored in directories like @MyClass
  • Read MatlabOpaque; the modern MATLAB classes, with automatic type conversion for:
    • string to String
    • duration to Dates.Millisecond
    • datetime to Dates.DateTime
    • categorical to PooledArrays.PooledArray
    • table to MatlabTable or tables like DataFrame

Fixes:

These fixes were mostly dangling unreleased in the master branch:

  • MAT v4: handle null-terminator '\0' in names
  • Writing AbstractArray types
  • Writing Char type

Example: DataFrame reading

Finally we can read DataFrames! Unless the table columns are ND-arrays instead of vectors, but what kind of monster would do that?

using MAT, DataFrames
filepath = abspath(pkgdir(MAT), "./test/v7.3/struct_table_datetime.mat")
vars = matread(filepath; table = DataFrame)
vars["s"]["testTable"]

# outputs

3Γ—5 DataFrame
 Row β”‚ FlightNum  Customer  Date                 Rating  Comment
     β”‚ Float64    String    DateTime             String  String
─────┼─────────────────────────────────────────────────────────────────────────────────────
   1 β”‚    1261.0  Jones     2016-12-20T00:00:00  Good    Flight left on time, not crowded
   2 β”‚     547.0  Brown     2016-12-21T00:00:00  Poor    Late departure, ran out of dinne…
   3 β”‚    3489.0  Smith     2016-12-22T00:00:00  Fair    Late, but only by half an hour. …

Many credits to the creator of the Python matio package for helping to load the undocumented Matlab Class Object Subsystem (MCOS) in Julia. Now you can finally load modern .mat files that would throw errors or warnings before in v0.10.
We intend to add writing of these MatlabOpaque classes in a next release.

If you have (weird) .mat files, go try out MAT.jl v0.11. Please open Github issues if you find problems, because I’m sure we missed many corner cases.

5 Likes