How to read .hdr files in Matlab?
14 次查看(过去 30 天)
显示 更早的评论
All the volumes(image 3D) location are stored in a variable called Fulfilename as
Fulfilename 178*1 cell
'D:\Oasis\Database\disc1\OAS1_0001_MR1\PROCESSED\MPRAGE\T88_111\OAS1_0001_MR1_mpr_n4_anon_111_t88_masked_gfc.hdr '
'D:\Oasis\Database\disc1\OAS1_0003_MR1\PROCESSED\MPRAGE\T88_111\OAS1_0003_MR1_mpr_n4_anon_111_t88_masked_gfc.hdr '
'D:\Oasis\Database\disc1\OAS1_0010_MR1\PROCESSED\MPRAGE\T88_111\OAS1_0010_MR1_mpr_n4_anon_111_t88_masked_gfc.hdr '
'D:\Oasis\Database\disc1\OAS1_0013_MR1\PROCESSED\MPRAGE\T88_111\OAS1_0013_MR1_mpr_n4_anon_111_t88_masked_gfc.hdr ' etc
I need to read all the images in Matlab. I tired with some code. It doesnt help me. Any help is appreciated. My code is the following:-
load Fulfilename;
for p=1:178
V= hdr_read_volume('Fulfilename{p}');
end
0 个评论
采纳的回答
Walter Roberson
2015-9-20
load Fulfilename;
for p = 1 : length(Fulfilename)
V{p} = hdr_read_volume(Fulfilename{p});
end
2 个评论
Walter Roberson
2015-9-20
Your filename list has trailing blanks on each of the strings. Code that accounts for that is
load Fulfilename;
Fulfilename = strtrim(Fulfilename);
for p = 1 : length(Fulfilename)
V{p} = hdr_read_volume(Fulfilename{p});
end
更多回答(1 个)
Image Analyst
2015-9-20
Fulfilename{p} is already a string. So then you're surrounding a string with quotes, but this actually does not evaluate Fulfilename{p} but just puts Fulfilename{p} into the string as a literal. So 'Fulfilename{p}' will be laterally that -- it will not be 'D:\Oasis\Database\disc1\OAS1_0001_MR1\PROCESSED\MPRAGE\T88_111\OAS1_0001_MR1_mpr_n4_anon_111_t88_masked_gfc.hdr'
There you will find out how to use braces and parentheses and quotes. You'd learn that you're supposed to do
V = hdr_read_volume(Fulfilename{p});
because Fulfilename{p} is already a string and you should not put it into quotes.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!