Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version of .mat file when saving #84

Closed
zhengliuer opened this issue Nov 11, 2024 · 10 comments
Closed

Version of .mat file when saving #84

zhengliuer opened this issue Nov 11, 2024 · 10 comments
Assignees

Comments

@zhengliuer
Copy link

zhengliuer commented Nov 11, 2024

Hi. great project! Really useful.

I want to use this project to help me save data to a .mat file, then read .mat in MATLAB. But my data could be larger than 2 GB. Sometimes it may come to 100+ GB. ignore the limit of my memory, does matio-cpp support this?

.mat has several version. The latest is v7.3, or above. When I loaded a mat file created using matio-cpp, size > 2GB, then MATLAB failed to read it. So I guess matio-cpp only support v7 .mat?

Best,
Zheng

@traversaro
Copy link
Collaborator

Hello @zhengliuer, you can select the version of the saved .mat file from the code, see #52 (comment) .

@zhengliuer
Copy link
Author

zhengliuer commented Nov 11, 2024

Thanks @traversaro ! I just noticed that parameter. But when I did like

matioCpp::File matFile = matioCpp::File::Create("test.mat", matioCpp::FileVersion::MAT7_3);

it caused

[ERROR][matioCpp::File::Create] Failed to open the file named test.mat.
[ERROR][matioCpp::File::write] The file is not open.

Not quite sure why. When I removed the vetsion, it works fine.

BTW, the platform is Windows10 x64 and I used vcpkg to manage the dependency, compile the program using VS2022.

..\vcpkg_installed\x64-windows-static\debug\lib\zlibd.lib
..\vcpkg_installed\x64-windows-static\debug\lib\libmatio.lib
..\vcpkg_installed\x64-windows-static\debug\lib\libhdf5_D.lib
shlwapi.lib
..\vcpkg_installed\x64-windows-static\debug\lib\libszip_D.lib
kernel32.lib
user32.lib
gdi32.lib
winspool.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib
comdlg32.lib
advapi32.lib

And this is the list of the libs. Any ideas?

Best,
Zheng

@traversaro
Copy link
Collaborator

traversaro commented Nov 11, 2024

Are you sure that the matio compiled by vcpkg is compiled with hdf5 support? Can you report your vcpkg list?

@zhengliuer
Copy link
Author

Here is the content of vcpkg.json

{
    "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json",
    "name": "kit",
    "version": "1.0.0",
    "dependencies": [
         "zlib",
         "hdf5",
         "matio",
         "visit-struct"
    ]
  }
 

@traversaro
Copy link
Collaborator

I am not familiar with vpckg's manifest mode (I typically use it in classic mode), but at first glance it does not seems that you enabled the hdf5 feature of matio, can you try with something like (I did not double checked if this is the correct syntax):

{
    "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json",
    "name": "kit",
    "version": "1.0.0",
    "dependencies": [
        "zlib",
        "hdf5",
        {
            "name": "matio",
            "features": ["hdf5"]
        },
        "visit-struct"
    ]
}

@traversaro
Copy link
Collaborator

Actually hdf5 should be in the default features (see https://github.com/microsoft/vcpkg/blob/5d66a8994296bd141b9bf870edb2b4663975acf9/ports/matio/vcpkg.json#L14), so hdf5 should be already be available, however it may be try to enable it explicitly. If you want to debug more deeply, the relevant part of the code is https://github.com/ami-iit/matio-cpp/blob/f30bce77cd214f0fa8a2c8fc75799957d85eaa9f/src/File.cpp#L221C28-L221C41 and https://github.com/tbeu/matio/blob/9e26c65fc31de240a051c8921119391f2c14f249/src/mat.c#L442-L466, it seems that if the call works with 4/5 and fails with 7.3 probably there is something wrong going either in passing the parameter, or indeed hdf5 support somehow is not enabled (some bug in the vcpkg port?).

@traversaro
Copy link
Collaborator

hdf5 support somehow is not enabled (some bug in the vcpkg port?).

To double check this, we can try to read a v7.3 mat file. If there is no hdf5 support, you should not be able to read it.

@traversaro
Copy link
Collaborator

I am not familiar with vpckg's manifest mode (I typically use it in classic mode), but at first glance it does not seems that you enabled the hdf5 feature of matio, can you try with something like (I did not double checked if this is the correct syntax):

{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json",
"name": "kit",
"version": "1.0.0",
"dependencies": [
"zlib",
"hdf5",
{
"name": "matio",
"features": ["hdf5"]
},
"visit-struct"
]
}

Actually reading better https://github.com/microsoft/vcpkg/blob/5d66a8994296bd141b9bf870edb2b4663975acf9/ports/matio/vcpkg.json#L37C6-L37C11 it seems that hdf5 is in default features, but mat73 no. So I guess you can try with something like:

{
    "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json",
    "name": "kit",
    "version": "1.0.0",
    "dependencies": [
        "zlib",
        "hdf5",
        {
            "name": "matio",
            "features": ["mat73"]
        },
        "visit-struct"
    ]
}

@zhengliuer
Copy link
Author

Wonderful! Adding "mat73" feature does work fine to me! Thanks a lot!

Best,
Zheng

@traversaro
Copy link
Collaborator

Thanks for opening the issue, I think the default settings of matio vcpkg port may be confusing, I opened microsoft/vcpkg#42103 upstream to discuss this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants