Index in position 1 exceeds array bounds. Index must not exceed 1.
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Gulfam Saju
le 17 Mar 2022
Commenté : Walter Roberson
le 17 Mar 2022
While I am trying to convert H5 file to mat file I got this error. The code is below:
close all; clear all;
addpath(genpath('.\'));
file_name_data = 'file_brain_AXFLAIR_200_6002425.h5';
info = h5info(file_name_data);
h5disp(file_name_data,'/');
struct_data = h5read(file_name_data,'/kspace');
raw_data = complex(struct_data(1:1:20,:,:,:),struct_data(1:1:20,:,:,:));
raw_data_xyz = fftshift(ifft(raw_data, 640, 4),4);
image_data_xyz = ifft(ifft(ifft(raw_data_xyz,640,4),320,3),20,2);
% figure,imshow(abs(squeeze(raw_data_xfft(6,100,:,:))),[]);
figure,imshow(abs(squeeze(image_data_xyz(6,100,:,:))),[]);
save(strcat(file_name_data,'.mat'),'raw_data_xyz');
output is below:
HDF5 file_brain_AXFLAIR_200_6002425.h5
Group '/'
Attributes:
'norm': 0.091318
'max': 0.000427
'patient_id': 'dcfc3e70496246a709dab23831262b60589f4383d6e05bf5559731ea8d80bb1f'
'acquisition': 'AXFLAIR'
Dataset 'ismrmrd_header'
Size: scalar
Datatype: H5T_STRING
String Length: variable
Padding: H5T_STR_NULLTERM
Character Set: H5T_CSET_ASCII
Character Type: H5T_C_S1
ChunkSize: []
Filters: none
Dataset 'kspace'
Size: 320x640x20x16
MaxSize: 320x640x20x16
Datatype: H5T_COMPOUND
Member 'r': H5T_IEEE_F32LE (single)
Member 'i': H5T_IEEE_F32LE (single)
ChunkSize: []
Filters: none
FillValue: H5T_COMPOUND
Dataset 'reconstruction_rss'
Size: 320x320x16
MaxSize: 320x320x16
Datatype: H5T_IEEE_F32LE (single)
ChunkSize: []
Filters: none
FillValue: 0.000000
Index in position 1 exceeds array bounds. Index must not exceed 1.
Error in h5_to_mat (line 8)
raw_data = complex(struct_data(1:1:20,:,:,:),struct_data(1:1:20,:,:,:));
5 commentaires
Geoff Hayes
le 17 Mar 2022
@Gulfam Saju - according to the above, struct_data is a 1x1 struct. You are treating it as if it had 3 dimensions. I suspect there is a field/member of that struct which has the data you want.
Réponse acceptée
Walter Roberson
le 17 Mar 2022
Dataset 'kspace'
Size: 320x640x20x16
MaxSize: 320x640x20x16
Datatype: H5T_COMPOUND
Member 'r': H5T_IEEE_F32LE (single)
Member 'i': H5T_IEEE_F32LE (single)
ChunkSize: []
Filters: none
FillValue: H5T_COMPOUND
Notice that it says it is a structure!
You probably need
raw_data = complex(struct_data.r(1:1:20,:,:,:), struct_data.i(1:1:20,:,:,:));
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Structures dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!