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)
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.
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.
Thank you very much for pointing that out Jake. I have fixed the issue with checkExtension by using the built-in fileparts function.
checkExtension let .m slip through, recommend using dir's built-in filtering instead:
Fixed bug that caused .m files and other short extensions to be identified as dicoms.
RTStruct files will now be ignored. Fixed bug resulting in an error if filenames were shorter than 4 characters.
Added my contact information to the comments.