File Exchange

image thumbnail


version (10.6 KB) by Laszlo Balkay
Select dicom series under a directory or CD using the DICOMDIR file.


Updated 05 Oct 2011

View License

dcmSeries = loaddcmdir(directoryname)

LOADDICOMDIR reads metadata from DICOMDIR file and shows a list of the different DICOM SERIES in a Pop-up menus. After selecting a dicom
series the program creates the dcmSeries structure containig the related file names and path.

The zip file also contains the loaddcm.m program which enable to generate the relating 3D image array using the names of dicom slices.


Reading DICOMDIR folder using the directory browser GUI:
dcmSeries = loaddcmdir;

Generating 3D array by selecting a dicom series:
[imaVOL, scaninfo, dcminfo] = loaddcm(loaddcmdir);

To preview the 3D array you can use the orthogonalslicer tool: (


To check the dicom header:

Cite As

Laszlo Balkay (2020). DICOMDIR Reader (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (32)


You should write in the description that the function saves a "dicomdir.mat" file!

I also got the following error:
Undefined function or variable "StudyDescription".
Error in loaddcmdir (line 229)

I just changed line 229 to the following and it works now:
SeriesList{SeriesListNum} = [Pname,', ',Modality,', SeriesDesc: ', SeriesDescription, ', Number of Images: ',NumOfImages];


You have done a very great piece of work.Still I have an error it is giving me
?? function [dcmSeries] = loaddcmdir(directoryname)
Error: Function definitions are not permitted at the prompt or in scripts.
Some how I will work on this but my problem lies when I need to calculate the Hounfied density for each pixel Please let me know how am i suppose to get the hounsfield density for each and every pixel value.

Matt Thorpe

Good work - thank you.

Our protocol tends to store images in a series across multiple directories, so I changed line 102 ( ...
ImageNames{CurrentImage,1} = dcmfname ; )

... = CurrentItem.ReferencedFileID;

And adjusted accompanying load m-files accordingly.

This keeps each image associated with the correct path.


Matt Thorpe

Laszlo Balkay

comment to Cristina Suárez-Varela:
Send your CT dicom series (or one instace from the series) directly to my email:

Cristina Suárez-Varela

I've tryed this dicomdir read, and it's ok but I've a problem with CT images. I must find the Hounsfield unit of each pixel to fix the window and I´ve find that the expresion is:
hu = pixel * RescaleSlope + RescaleIntercept
But I don't find these fields in the metadata info.
Could you help me?

Laszlo Balkay

Comment to Pratik Chhatbar: This means matlab cannot find the 'dicominfo' function. It seems the Image Processing Toolbox is not installed in your PC, or the version is fairly old.

Pratik Chhatbar

anyone had this error?

Undefined function or method dicominfo' for input arguments of type 'char'

ani shiv


sujeet poudyal


Laszlo Balkay

Comment to Daniel Polders: The cause of your problem may be the version of your Img.Proc toolbox. See the link:

I hope this help,

Daniel Polders

Good initiative!
I'm trying to read a dicomdir generated by a Philips Achieva MR system, but I get the following error:

??? Operands to the || and && operators must be convertible to logical scalar values.
Error in ==> loaddcmdir at 64 (dcmhdr = dicominfo(dcmdir_path);)

Any suggestions?

Laszlo Balkay

Comments to Kalyani Mallela: DICOMDIR is a "catalog" file in the DICOM CD. This is a well known "standard" in this field. If you only want to read dicom series (including 250 slices or whatever you want) you may use the "loaddcm.m" script from the package. I hope this help. LAszlo

Kalyani Mallela

I am still unclear on what your DICOMDIR is in the file "loaddcmdir". I have a folder say,data, that has 250 slices of CT. Each of the .dcm file has some name tag. Now, from this if I want to generate a 3D, can you tell me what should my DICOMDIR be. Thank you

pedro aguiar

no coment

Balaji Pillai

mohamed KHAFAGY


mohammed ashour

nice program

osae qafeas


Laszlo Balkay

Comments to "pin press":
As far as I know, officialy there is no different type of dicomdir files. Nevertheless I have gone into problem with Philips type dicomdir file. The only think I could suggest you, send me your dicomdir file directly to my email address to check your specific the problem.


pin press

Does this only work for specific type of dicomdir? I tried read that from a Philips generate dicomdir, and it reports error:

>> dcmseries=loaddcmdir(fn);

ErrorOnDicomOpening =

Error using ==> struct
Field name must be a string vector.

hamdi issa

Orkopoulos Anestis

George Enrique Figueras Benítez

how can i modifier a especific field in a dicomdir header

zee hai

Joel Dunn

Could not open DICOMDIR from Phillips MRI scanner (tho readable on another program).
Error msg below...

ErrorOnDicomOpening =

Error using ==> medformats\private\dicom_read_attr>read_elt
Error using ==> medformats\private\dicom_read_attr>find_attr_details
Attribute (0070,0000) was not found in the data dictionary.

gabriel berindei

nicu gavanescu


Bob Alvarez

Also could not get it to work. Line 49 is definitely weird. I have used dicominfo many times and never for a directory.

Ravi Seethamraju

There is a bug in the script. The field PatientName should be replaced with PatientsName in order for the script to work

Vihang Patil

The program does not work. You have specified "dcmhdr = dicominfo(dcmdir_path);"
It is not applicable as dicominfo cannot read the directory. It only reads the dicom images. PLease let me know how to make it run




Fixed the bugs that were reported on comments list previously.

MATLAB Release Compatibility
Created with R14
Compatible with any release
Platform Compatibility
Windows macOS Linux