Sort and Rename dicom files without losing dicominfo

조회 수: 2 (최근 30일)
Hugo
Hugo 2013년 12월 3일
Hi all,
I have got several sets of dicom images i'm trying to order and rename. I have written a fine working algorithm, but unfortunately i doesn't work when i'm implementing dicominfo in the dicomwrite line. I need to use the SliceThickness and PixelSpacing later on, so i need to store this info. Can anybody explain why --> dicomwrite(A,(fname), info); doesn't work. And does anybody has a suggestion about the way to implement this?
if true
% uiwait(msgbox('Select directory to load files'))
fpath = uigetdir;
fstruct = dir('fpath\*.dcm');
dicomlist = dir(fullfile(fpath,fstruct','*.dcm'));
uiwait(msgbox('Select directory to save files'))
fpath1 = uigetdir;
cd(fpath1);
hWaitBar = waitbar(0,'Renaming DICOM files');
for i=length(dicomlist):-1:1;
A = dicomread(fullfile(fpath,fstruct,dicomlist(i).name));
info = dicominfo(fullfile(fpath,fstruct,dicomlist(i).name));
B = info.InstanceNumber;
if B <= 9;
fname = ['ADNI_MRI_00', num2str(B), '.dcm'];
elseif B <= 99;
fname = ['ADNI_MRI_0' num2str(B), '.dcm'];
else
fname = ['ADNI_MRI_', num2str(B), '.dcm'];
end
dicomwrite(A,(fname));
waitbar((length(dicomlist)-i)/length(dicomlist))
end
delete(hWaitBar)
end

답변 (0개)

카테고리

Help CenterFile Exchange에서 Read and Write Image Data from Files에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by