How to replace a dataset with different dimensions in an .H5 file - hdf5lib2 error
Show older comments
I have a dataset comprising a cube of images, with dimension 256x320x151. I need tu cut it down to a dataset with dimension 256x320x10, while keeping all the other attributes invariate, as they have useful information on the data acquisition parameters.
I have tried the code:
h5disp('PCA_cube - Copia.h5')
fileattrib('PCA_cube - Copia.h5','+w');
fid = H5F.open('PCA_cube - Copia.h5','H5F_ACC_RDWR','H5P_DEFAULT');
dset_id = H5D.open(fid,'/Cube/Images');
H5D.set_extent(dset_id,[320,256,10]); % C-style indexing
H5D.close(dset_id);
H5F.close(fid);
h5read(PCA_cube - Copia.h5', '/Cube/Images')
However I get the error message: "Error using hdf5lib2 : The HDF5 library encountered an error and produced the following stack trace information:H5D__set_extent dataset has contiguous storage"
I'm adding also some information on the file structure:

Any help or suggestion is much welcome!
Accepted Answer
More Answers (0)
Categories
Find more on HDF5 in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!