How to retrieve meta-data of HDF5 Dataset?

Hello,

I have a 3D brain image (MR) in .mat format. I have used the following code to access the image data.

import SimpleITK as sitk
import numpy as np
import h5py

f = h5py.File('MR.mat','r')
data_value = f['Data1_anatomical_reference']
data_value=np.array(data_value)

I can access the pixel values with this code. However, I cannot retrieve the original meta-data (pixel spacing, origin and direction cosine matrix) of the .mat file. Is there a way to retrieve these values?

Hello @debapriya,

Your question is not about ITK or SimpleITK, so this is the wrong forum to ask it in.

Having said that, it appears that the file is an hdf5 file so you should be able to browse the groups and attributes contained in the file using the hdfview program. Once you identify the relevant group’s or attribute’s key you can read the information just like you did with the bulk pixel information using the Data1_anatomical_reference key. The h5py quick start guide may also be of interest.

2 Likes