using multiselect uigetfile with dicomread

3 visualizzazioni (ultimi 30 giorni)
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?!

Risposta accettata

Matt Kindig
Matt Kindig il 31 Lug 2013
Modificato: Matt Kindig il 31 Lug 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 Commento
KS
KS il 7 Giu 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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su DICOM Format in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by