using multiselect uigetfile with dicomread

3 次查看(过去 30 天)
I have been using uigetfile to select dicom images which I then want to read with the dicomread command (I am using the image processing toolbox and Matlab version R2012b). If I select a single file then my code works fine:
[name, pathname] = uigetfile('*.dcm', 'Select a reference DICOM file...', 'MultiSelect', 'on') ;
for count = 1 : numel(name)
imageref{count} = dicomread(name(count));
end
but for multiple files I get the error:
Error using dicomread>newDicomread (line 164)
The first input argument must be a filename or DICOM info struct.
Error in dicomread (line 80)
[X, map, alpha, overlays] = newDicomread(msgname, frames);
Error in register_CT (line 13)
imageref{count} = dicomread(name(count));
I know that for multiple selections on uigetfile the filenames are cell strings, but if I convert them to character strings using the following code:
imageref{count} = dicomread(char(name(count))) ;
Then I get the error:
Error using dicomread>getFileDetails (line 1378)
File "IM-0001-0001.dcm" not found.
Error in dicomread>newDicomread (line 173)
fileDetails = getFileDetails(filename);
Error in dicomread (line 80)
[X, map, alpha, overlays] = newDicomread(msgname, frames);
Error in register_CT (line 13)
imageref{count} = dicomread(char(name(count))) ;
Where am I going wrong?!

采纳的回答

Matt Kindig
Matt Kindig 2013-7-31
编辑:Matt Kindig 2013-7-31
You probably need to pass in the full path to your DICOM file to dicomread(). Try this:
for count = 1:numel(name)
imageref{count} = dicomread( fullfile(pathname, name{count}) );
end
  1 个评论
KS
KS 2017-6-7
I also need to select multiple images and I have tried to used your code. Surprisingly, it works as I want.
So let say I select and read three images. How to calculate the average of these images?
Thank you.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Geometric Transformation and Image Registration 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by