-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathReadDICOM.m
More file actions
27 lines (20 loc) · 733 Bytes
/
Copy pathReadDICOM.m
File metadata and controls
27 lines (20 loc) · 733 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function [ct3d, DICOM_INFO] = ReadDICOM(sFolder)
% ct3d is the mat-file that contains all the DICOM information in one file
if ispc, sS='\'; else sS='/'; end;
SFolder = dir(sFolder);
SFiles = SFolder(~[SFolder.isdir]);
cNames = {SFiles(:).name};
lInd = cellfun(@(x) any(strcmpi(x(end-3:end),{'.ima','.dcm'})), cNames); % skip unwanted files
SFiles = SFiles(lInd);
img = dicomread(fullfile(sFolder, SFiles(1).name));
DICOM_INFO = dicominfo([sFolder, sS, SFiles(1).name]);
siz_img = size(img);
N = length(SFiles);
% create result matrix:
ct3d = NaN([siz_img N]);
% load all images and put them in the matrix
for ii=1:N
strfile = sprintf(SFiles(ii).name);
ct3d(:,:,ii)= dicomread(fullfile(sFolder, strfile));
end
end