using multiselect uigetfile with dicomread

5 visualizaciones (últimos 30 días)
Catherine Scott
Catherine Scott el 31 de Jul. de 2013
Comentada: KS el 7 de Jun. de 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?!

Respuesta aceptada

Matt Kindig
Matt Kindig el 31 de Jul. de 2013
Editada: Matt Kindig el 31 de Jul. de 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 comentario
KS
KS el 7 de Jun. de 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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Geometric Transformation and Image Registration en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by