How to read .hdr files in Matlab?
조회 수: 13 (최근 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!