File Exchange

image thumbnail

dicomfolder

version 1.6.0.0 (3.96 KB) by Dylan O'Connell
Reads all dicom files in a directory and returns one or more 3D images and corresponding metadata.

6 Downloads

Updated 07 Jul 2016

View Version History

View License

3D CT and MRI images in dicom format are saved by writing a separate file for every slice rather than storing the entire image in a single large file. This function reads all dicom files in a directory and returns one or more 3D matrices containing the image data as well as cell arrays with the corresponding dicom header information.
dicomfolder: imports dicom images.
[image, headers] = dicomfolder(folderName)
Input:
folderName: Name of folder containing dicom images. Image files must have extenstion .dcm, .ima, or no extension. If no argument is passed to the function the user will be prompted to choose a folder.
Output:
image: 3D matrix containing the image data. If more than one image is found, a cell array containing an entry for each image is returned. Slices are sorted according to the Z coordinate of the ImagePositionPatient tag.
headers: Cell array with the metadata for each image. If multiple images are found, headers will be a cell array of cell arrays.

Cite As

Dylan O'Connell (2021). dicomfolder (https://www.mathworks.com/matlabcentral/fileexchange/52390-dicomfolder), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (7)

Rashedur Rahman

Yonatan Chatzinoff

Yu Gao

John Ginn

Dylan O'Connell

Thank you very much for pointing that out Jake. I have fixed the issue with checkExtension by using the built-in fileparts function.

Jake Shea

checkExtension let .m slip through, recommend using dir's built-in filtering instead:

dcmFilenames=dir(fullfile(folderName,'*.dcm'));

hengheng

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

Community Treasure Hunt

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

Start Hunting!