I have a dicom file that contains 110 images and their names are random. I am trying to rename them according to their SliceLocations (n) and rewrite them with the dcm extension, i.e., n(1).dcm, n(2).dcm, …
Any suggestions would be appreciated.
I tried
image_list=dir('*.dcm');
for i=1:110
img=dicomread(image_list);
imgHdr = dicominfo(image_list(i).name);
for j = size(img,4);
dicomwrite(img(:,:,:,j),['n(' int2str(j) ').dcm'],imgHdr,'CreateMode','Copy');
end
end