HenrikBengtsson / R.matlab

R package: R.matlab
https://cran.r-project.org/package=R.matlab
86 stars 25 forks source link

fieldnames in nested structures lost #41

Open ashenkin opened 5 years ago

ashenkin commented 5 years ago

Hi Henrik,

Thanks for the useful package! i'm having an issue where nested structure fields aren't being imported with their names. Mat file is here: https://www.dropbox.com/s/ls8jzre5dyvf6xu/rmatlab_example.mat?dl=0. Any help greatly appreciated!

Thanks, Allie

> library(R.matlab)
> matstruct = readMat("rmatlab_example.mat")
> names(matstruct$qsm)
NULL

image

stefanocoretta commented 4 years ago

Any news on this front?

HenrikBengtsson commented 4 years ago

Sorry, not on my end. I don't actively develop R.matlab but PRs (code coupled with solid test scripts) are welcome.

yananzhaotpg commented 4 years ago

use 'rmatio' instead

stefanocoretta commented 4 years ago

An update. I realised that field names are not dropped. MATLAB structs are read into R as 3-dimensional arrays and the content of the struct is in the first element of the 3rd dimension. Field names are retained as dimension names of the first dimension.

I’ll add a reproducible example later.

rmatio does not currently work for me (see issue here).

boral commented 1 year ago

@stefanocoretta can you please give a reproducible example please ? OR maybe a PR

stefanocoretta commented 1 year ago

Hi @boral, unfortunately not because I am not using MATLAB any more.