How can I selectively extract multidimensional data from an HDF5 file?
Mostrar comentarios más antiguos
I'm new to manipulating HDF5 files on a low level, and I recently tried making a script to get some 3D data out of an HDF5 file. My HDF5 file dataset (x,y,z) is 14 x 29783 x 494 uint16. I'm trying to extract a 14 x 7001 x 494 portion of this, starting at y=89 (one-based index)and stopping at y=7089. Going off of examples in the low-level function documentation, here is my code:
plist='H5P_DEFAULT';
fid=H5F.open(imname);
dset_id=H5D.open(fid,'/Image');
dims=fliplr([14 7001 494]); % get from data separation
mem_space_id=H5S.create_simple(3,dims,[]); % create cropped dataspace
file_space_id=H5D.get_space(dset_id);
offset = fliplr([0 88 0]); % Start at 89th column?
block = fliplr([14 7001 494]);
H5S.select_hyperslab(file_space_id,'H5S_SELECT_SET',offset,[],[],block);
data = H5D.read(dset_id,'H5ML_DEFAULT',mem_space_id,file_space_id,plist);
H5D.close(dset_id);
H5F.close(fid);
I get the following error at the H5D.read() statement: Error using hdf5lib2: The HDF5 library encountered an error during execution of the "H5Dread" function, "selection+offset not within extent". What am I doing wrong?
Respuestas (1)
per isakson
el 5 de Abr. de 2013
0 votos
I found them useful when I tried to use the low level support of HDF5 in Matlab. However, in my case the extra functionality of the low level api was not worth the trouble.
Categorías
Más información sobre HDF5 en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!