# How to retrieve meta-data of HDF5 Dataset?

**URL:** https://discourse.itk.org/t/how-to-retrieve-meta-data-of-hdf5-dataset/6619
**Category:** Beginner Questions
**Tags:** python, simpleitk
**Created:** [May 7, 2024, 1:28pm UTC](https://discourse.itk.org/t/how-to-retrieve-meta-data-of-hdf5-dataset/6619 "2024-05-07T13:28:19Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![debapriya](https://discourse.itk.org/letter_avatar_proxy/v4/letter/d/bc79bd/32.png) [@debapriya](https://discourse.itk.org/u/debapriya)
#### Post date: [May 7, 2024, 1:28pm UTC](https://discourse.itk.org/t/how-to-retrieve-meta-data-of-hdf5-dataset/6619/1 "2024-05-07T13:28:19Z")

</div>

Hello,

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

```auto
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?

---

<div class="post-metadata">

### Author: ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)
#### Post date: [May 7, 2024, 7:41pm UTC](https://discourse.itk.org/t/how-to-retrieve-meta-data-of-hdf5-dataset/6619/2 "2024-05-07T19:41:10Z")

</div>

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](https://www.hdfgroup.org/solutions/hdf5/) so you should be able to browse the groups and attributes contained in the file using the [hdfview program](https://www.hdfgroup.org/downloads/hdfview/). 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](https://docs.h5py.org/en/stable/quick.html) may also be of interest.
