Loading an HDF dataset into python, but it's recognized as empty

Viewed 352

I am trying to load a large 400x300x60x28 dataset from Matlab (.mat file) into Python as an HDF file, but every time I try to see what's in the file it says it is empty.

Some things I've tried so far:

INPUT:

    f=h5py.File(r'D:\Natalie\Research\Vascular Hand\output.mat','r')
    print(f)

OUTPUT:

    <HDF5 file "output.mat" (mode r+)>

INPUT:

    store=pd.HDFStore(r'D:\Natalie\Research\Vascular Hand\output.mat')
    print(store)

OUTPUT:

    <class 'pandas.io.pytables.HDFStore'>
    File path: D:\Natalie\Research\Vascular Hand\output.mat
    Empty

INPUT:

    f = pd.read_hdf(r'D:\Natalie\Research\Vascular Hand\output.mat')

OUTPUT:

    ValueError: No dataset in HDF5 file.

It's saying there is no dataset, but I just opened the same file in Matlab and it has over 500,000 elements. Just to give some context, it is a variable of type 4-D single in Matlab and it is time-of-arrival data from blood circulation tracked through MRI scans.

1 Answers

To read .mat files one might use scipy.io.loadmat

data = scipy.io.loadmat("example.mat")
Related