Index in position 1 exceeds array bounds. Index must not exceed 1.

7 次查看(过去 30 天)
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 个评论
Gulfam Saju
Gulfam Saju 2022-3-17
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
Name Size Bytes Class Attributes
file_name_data 1x33 66 char
info 1x1 20340 struct
struct_data 1x1 524288336 struct
Geoff Hayes
Geoff Hayes 2022-3-17
@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.

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2022-3-17
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,:,:,:));
  2 个评论
Gulfam Saju
Gulfam Saju 2022-3-17
Index in position 2 exceeds array bounds. Index must not exceed 20.
Error in h5_to_mat (line 13)
figure,imshow(abs(squeeze(image_data_xyz(6,100,:,:))),[]);
I got this error.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Structures 的更多信息

产品


版本

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by