Using a cell array as input for a for loop

조회 수: 1 (최근 30일)
Jasmine
Jasmine 2022년 6월 30일
댓글: Jasmine 2022년 7월 2일
Hello,
I am new to matlab and I am having issues using my cell array in a for loop. I have a cell array called "uni_path_list" (1x35) containing paths to folders where my image files are located. For each loop I am trying to convert the dicom files within a folder to the nifti format. When I run the code I receive no errors, but my image files do not convert. Instead I find that "hedr" is empty (0x0 cell), but "files" is, for example, a 34x72 character array containing image names within a specific folder.
for i = 1 : length(uni_path_list)
files = spm_select('List', uni_path_list{i});
hedr = spm_dicom_headers(files);
spm_dicom_convert(hedr);
end
%An example file path:
%/Users/SC/Desktop/Project/MR/Test/REMIND_001/MR_HEAD_20000213_172316_000000/3_PLANE_LOC
Thank you in advance!
  댓글 수: 1
Kshittiz Bhardwaj
Kshittiz Bhardwaj 2022년 7월 1일
Hello Jasmine,
Can you share the entire code here as it would help to understand the issue better?

댓글을 달려면 로그인하십시오.

답변 (1개)

yanqi liu
yanqi liu 2022년 7월 2일
yes,sir,may be check the file,such as
for i = 1 : length(uni_path_list)
files = spm_select('List', uni_path_list{i});
if exist(files, 'file')
hedr = spm_dicom_headers(files);
spm_dicom_convert(hedr);
else
disp(files);
disp(['can not find this file, please check it']);
end
end
%An example file path:
%/Users/SC/Desktop/Project/MR/Test/REMIND_001/MR_HEAD_20000213_172316_000000/3_PLANE_LOC
  댓글 수: 1
Jasmine
Jasmine 2022년 7월 2일
Thank you so much for your reply. When I run this code it does say that it cannot find the files. The folder and all of its subfolders are in the Matlab path, so how would I go about fixing this?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 DICOM Format에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by