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

NotImplementedError: Please use HDF reader for matlab v7.3 files #161

Open
soichih opened this issue Sep 3, 2017 · 8 comments
Open

NotImplementedError: Please use HDF reader for matlab v7.3 files #161

soichih opened this issue Sep 3, 2017 · 8 comments

Comments

@soichih
Copy link

soichih commented Sep 3, 2017

Hello.

I am trying to run afqbrowser-assemble on my AFQ output (output.mat) and I am seeing following error message.

$ ~/git/AFQ-Browser/bin/afqbrowser-assemble output.mat 
Traceback (most recent call last):
  File "/N/u/brlife/Karst/git/AFQ-Browser/bin/afqbrowser-assemble", line 19, in <module>
    afqb.assemble(args.source, args.target)
  File "/N/u/brlife/Karst/.local/lib/python2.7/site-packages/afqbrowser/browser.py", line 150, in assemble
    out_path=op.join(site_dir, 'client', 'data'))
  File "/N/u/brlife/Karst/.local/lib/python2.7/site-packages/afqbrowser/browser.py", line 43, in mat2tables
    afq = sio.loadmat(mat_file_name, squeeze_me=True)['afq']
  File "/N/soft/rhel6/python/2.7.3/lib/python2.7/site-packages/scipy/io/matlab/mio.py", line 135, in loadmat
    MR = mat_reader_factory(file_name, appendmat, **kwargs)
  File "/N/soft/rhel6/python/2.7.3/lib/python2.7/site-packages/scipy/io/matlab/mio.py", line 65, in mat_reader_factory
    raise NotImplementedError('Please use HDF reader for matlab v7.3 files')
NotImplementedError: Please use HDF reader for matlab v7.3 files

I am saving the AFQ output like following.

https://github.com/brain-life/app-tractclassification/blob/master/main.m#L66

save('output.mat','fg_classified','classification','-v7.3');    

I am not exactly sure why we are using "-v7.3" option to save it, but will it not work if I have it?

@arokem
Copy link
Collaborator

arokem commented Sep 3, 2017

Might not. Scipy's mat-file reader only reads certain versions of mat files. This shouldn't be too hard to fix with something like h5py, and we should do that. It might take us a little while, though. I'm leaving this open for now, so that we remember to do that.

For the time being, does it work for you if you don't save the mat file explicitly as v7.3? What version of Matlab are you working with?

@soichih
Copy link
Author

soichih commented Sep 3, 2017

We are starting to use 2017a, but I believe most of our apps still runs on 2016a. I will find out we can start storing our AFQ output in HDF5 format.

@skjerns
Copy link

skjerns commented Jan 11, 2020

I've implemented a library that can read the mat 7.3 files, have a look here:

mat 7.3

or install via pip pip install mat73 and load with

import mat73
data_dict = mat73.loadmat('data.mat')

@arokem
Copy link
Collaborator

arokem commented Jan 12, 2020

That is cool! Have you considered contributing this upstream to scipy?

@skjerns
Copy link

skjerns commented Jan 12, 2020

Mhh, I'll consider it.

However, it introduces a dependency on h5py, not sure how happy they would be about that.

@siri-ius
Copy link

siri-ius commented Sep 10, 2020

I've implemented a library that can read the mat 7.3 files, have a look here:

mat 7.3

or install via pip pip install mat73 and load with

import mat73
data_dict = mat73.loadmat('data.mat')

this worked for me

@NYcleaner
Copy link

#if matlab save data use ‘-v7.3’,scipy.io.loadmat api load may lead mistake ,thus can use like:

import h5py
f = h5py.File('http.mat', 'r')
print(f.keys()) # <KeysViewHDF5 ['X', 'y']>  
print(f['X'][:]) 

@ghost
Copy link

ghost commented Jan 25, 2021

I've implemented a library that can read the mat 7.3 files, have a look here:

It worked for me, thanks

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

5 participants