I use a script to make images match with an atlas. This script input is .raw
images organised in folders like:
imageFolder
-- folder1
---- image1.r
Feiten, you can use .visititems()
to recursively call a function (def) to export the data. You can query the object type and name. Group names will be your folder names and Dataset names will be your file names. Attached is a very simple example that shows how to use .visititems()
. It has some print statements (commented out) that output more info if you are unfamiliar with h5py and/or HDF5 structure. This should get you started.
import h5py
def print_grp_name(grp_name, object):
# print ('object = ' , object)
# print ('Group =', object.name)
try:
n_subgroups = len(object.keys())
#print ('Object is a Group')
except:
n_subgroups = 0
#print ('Object is a Dataset')
dataset_list.append (object.name)
# print ('# of subgroups = ', n_subgroups )
if __name__ == '__main__' :
with h5py.File(your-filename-here,'r') as h5f:
print ('visting group = ', h5f)
dataset_list = []
h5f.visititems(print_grp_name)
print (dataset_list)