how to write multiple dicom files into a folder using 'dicomwrite' command
15 次查看(过去 30 天)
显示 更早的评论
using for loop, i can read all the 'k' dicom files present in the folder . After performing some operation on each slice, i need to save them into another folder .
Someone please help me
names=dir(fullfile('C:\matlab\*.dcm'));
for k=1:size(names, 1)
I(:,:,k)=dicomread(names(k).name);
P=I(:,:,k);
M(:,:,k) = foperation(P);
%figure(k)
% imshow(Mask(:,:,k))
dicomwrite(Mask(:,:,k),'mask_01.dcm') // what and how should i change this line to save all k files into another folder
end
0 个评论
回答(1 个)
Subhadeep Koley
2020-1-22
Hi, your code is almost correct. You only need to give different name to the 'k' different DICOM files. The below code might help!
names=dir(fullfile('C:\matlab\*.dcm'));
for k = 1:size(names, 1)
I(:,:,k) = dicomread(names(k).name);
P = I(:,:,k);
M(:,:,k) = foperation(P);
% figure(k);
% imshow(Mask(:,:,k));
dicomwrite(Mask(:,:,k),['putYourFolderPathHere\','mask_01_',num2str(k),'.dcm']);
end
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!