deepmr.io.read_hdf5

Contents

deepmr.io.read_hdf5#

deepmr.io.read_hdf5(filepath)[source]#

Read HDF5 file as a Python dictionary

Parameters:

filepath (str) – Path to file on disk.

Returns:

Deserialized HDF5 file.

Return type:

dict

Example

Define an exemplary dictionary and save to file:

>>> import os
>>> import numpy as np
>>> import deepmr.io
>>> pydict = {'headerstr': 'someinfo', 'testdouble': np.ones(3, dtype=np.float32)}
>>> filepath = os.path.realpath('.')
>>> deepmr.io.write_hdf5(filepath)

Load from disk:

>>> loaded_dict = deepmr.io.read_hdf5(filepath)

Result is the same dictionary created before:

>>> loaded_dict.keys()
['headerstr', 'testdouble']
>>> matfile['testdouble']
array([1.0, 1.0, 1.0])
>>> matfile['headerstr']
'someinfo'