Reading HDF5 files

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.

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

ITK can only read HDF5 format images written by itself. It checks for group “/ITKImage”. ITK will not read a random HDF5 file.

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

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

1 Like

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

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.