# Reading HDF5 files

**URL:** https://discourse.itk.org/t/reading-hdf5-files/2503
**Category:** Beginner Questions
**Created:** [December 10, 2019, 4:25pm UTC](https://discourse.itk.org/t/reading-hdf5-files/2503 "2019-12-10T16:25:11Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![rdsouza15](https://discourse.itk.org/letter_avatar_proxy/v4/letter/r/9f8e36/32.png) [@rdsouza15](https://discourse.itk.org/u/rdsouza15)
#### Post date: [December 10, 2019, 4:25pm UTC](https://discourse.itk.org/t/reading-hdf5-files/2503/1 "2019-12-10T16:25:11Z")

</div>

Hello,

Using the c++ API, I am trying to read in standard HDF5 files but am unable to (See errors below). I have followed the examples online, but to no avail.

Has anyone else had similar problems reading in these files, and is there an image file reader for this image specification? Any help is appreciated.

```auto
HDF5-DIAG: Error detected in HDF5 (1.8.17) thread 0:
  # 000: D:\a\1\sitk-build\ITK\Modules\ThirdParty\HDF5\src\itkhdf5\src\H5D.c line 358 in itk_H5Dopen2(): not found
    major: Dataset
    minor: Object not found
  # 001: D:\a\1\sitk-build\ITK\Modules\ThirdParty\HDF5\src\itkhdf5\src\H5Gloc.c line 430 in itk_H5G_loc_find(): can't find object
    major: Symbol table
    minor: Object not found

```

Thanks,  
Ryan

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [December 10, 2019, 4:38pm UTC](https://discourse.itk.org/t/reading-hdf5-files/2503/2 "2019-12-10T16:38:37Z")

</div>

ITK can only read HDF5 format images [written by itself](https://github.com/InsightSoftwareConsortium/ITK/blob/271e37f5e17f687827c3adc3568e234c0dae5170/Modules/IO/HDF5/src/itkHDF5ImageIO.cxx#L1032-L1033). It [checks](https://github.com/InsightSoftwareConsortium/ITK/blob/271e37f5e17f687827c3adc3568e234c0dae5170/Modules/IO/HDF5/src/itkHDF5ImageIO.cxx#L615-L621) for [group “/ITKImage”](https://github.com/InsightSoftwareConsortium/ITK/blob/271e37f5e17f687827c3adc3568e234c0dae5170/Modules/IO/HDF5/src/itkHDF5ImageIO.cxx#L66). ITK will not read a random HDF5 file.

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [December 10, 2019, 4:44pm UTC](https://discourse.itk.org/t/reading-hdf5-files/2503/3 "2019-12-10T16:44:17Z")

</div>

There is an HDF5 Image standard H5IM (so i’t not a random H5 file):

[https://support.hdfgroup.org/HDF5/doc/HL/RM\_H5IM.html](https://support.hdfgroup.org/HDF5/doc/HL/RM_H5IM.html)

Is anyone aware of an existing itk::ImagIO which support this format?

Our current “itk::HDF5ImageIO” name may be a little misleading, and it looks like it needs to be tough that is requires the “/ITKImage” group, and not try to read any file with an hd5f extension.

_edit_: corrected link

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [December 10, 2019, 10:24pm UTC](https://discourse.itk.org/t/reading-hdf5-files/2503/4 "2019-12-10T22:24:28Z")

</div>

The current SimpleITK master with ITKv5 give the following more reasonable error message:

```auto
sitk.ReadImage("ex_image2.h5")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "SimpleITK.py", line 9010, in ReadImage
    return _SimpleITK.ReadImage(*args)
RuntimeError: Exception thrown in SimpleITK ReadImage: sitkImageReaderBase.cxx:107:
sitk::ERROR: Unable to determine ImageIO reader for "ex_image2.h5"

```

In ITKv5 the `itk::HDF5ImageIO` correctly does not indicate that it can try to read the file. If the “HDF5ImageIO” is explicitly set then a similar error message it ITKv4 occurs. This behavior seems reasonable.
