Changing Output File Names

2 views (last 30 days)
Naomi Gaggi
Naomi Gaggi on 15 Oct 2018
Commented: Naomi Gaggi on 15 Oct 2018
I wrote the program:
a = {'path1'};
b = {'path2'};
c = {'path3'};
s_out = {'/Users/Desktop/output'};
for i = [a,b,c]
kk = 1:length(i);
t = spm_select('FPList', i(kk), '.*');
hdr = spm_dicom_headers(t);
spm_dicom_convert(hdr, 'all', 'flat', 'nii', char(s_out));
end
The output files are coming out as the same and overwriting each other, so I am only seeing 1 file in the output folder. I want three files to be put into the output directory with three different names, including 1, 2, 3, etc. I have been trying to solve this for a while, but can't seem to figure out how to write this command. Thanks!

Answers (1)

KSSV
KSSV on 15 Oct 2018
a = {'path1'};
b = {'path2'};
c = {'path3'};
s_out = {'/Users/Desktop/output'};
s = [a,b,c] ;
for kk = 1:length(s)
t = spm_select('FPList', s(kk), '.*');
hdr = spm_dicom_headers(t);
spm_dicom_convert(hdr, 'all', 'flat', 'nii', char(s_out));
end
  1 Comment
Naomi Gaggi
Naomi Gaggi on 15 Oct 2018
Hi, thanks! I still am only receiving one output file. I would like to add in a command in which each output file is named differently with each iteration of the loop.

Sign in to comment.

Categories

Find more on Graph and Network Algorithms in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!