using multiselect uigetfile with dicomread

2 vues (au cours des 30 derniers jours)
Catherine Scott
Catherine Scott le 31 Juil 2013
Commenté : KS le 7 Juin 2017
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?!

Réponse acceptée

Matt Kindig
Matt Kindig le 31 Juil 2013
Modifié(e) : Matt Kindig le 31 Juil 2013
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 commentaire
KS
KS le 7 Juin 2017
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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Geometric Transformation and Image Registration dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by