matlab - Rename dicom images -


i have 110 ct dicom images, , names randoms, when display them using dicom viewer, displayed randomly. trying rename these dicom images according image number (0020,0013) or slice location (0020,1041). have started write script

image_list=dir('*.dcm');  i=1:25     img=dicomread(image_list(i).name);     imghdr = dicominfo(image_list(i).name);  dicomwrite(img, ['t' num2str(i) '.dcm'], imghdr,'createmode','copy') end 

but don't know how tell check instancenumber , use in new name ?

the instancenumber accessible element of dicominfo output struct:

instancenumber = imghdr.instancenumber; 

and construct filename using sprintf

outputfilename = sprintf('t%04d', instancenumber); 

there many formats sprintf mirroring c++'s printf, ones used above print integer (the 'd') 4 digits (the '4'), 0 padded (the '0'). automatic sorting file managers. if need different format check docs here.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -