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

7 views (last 30 days)
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 Comments
Gulfam Saju
Gulfam Saju on 17 Mar 2022
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 on 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.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 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,:,:,:));
  2 Comments
Gulfam Saju
Gulfam Saju on 17 Mar 2022
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.

Sign in to comment.

More Answers (0)

Categories

Find more on Structures in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!