-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmri_dcminfo.m
128 lines (100 loc) · 3.38 KB
/
mri_dcminfo.m
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
function I = mri_dcminfo(P)
% MRI acquisition parameters (Siemens Trio)
% FORMAT I = mri_dcminfo(P)
%
% P - path to dicom file
% (leave void to use file selector)
%
% TR - repetition time (ms)
% TE - echo time (ms)
% ES - effective echo spacing (s)
% RT - total readout time (s)
% FA - flip angle (degrees)
% FoV - field of view (mm2)
% Dim - image dimensions (voxels)
% Voxel - voxel size (mm)
% Nslices - number of slices
% Slicethick - slice thickness (mm)
% Tesla - field strength (Tesla)
% Acquisition - acquisition mode
% Order - slice order
% ___________________________________________________________
% Copyright (C) 2013-16 Martin Dietz, CFIN, Aarhus University
if ~nargin
P = spm_select(1,'any','Please select dicom file',[],[],'.dcm$');
end
if license('checkout','image_toolbox')
D = dicominfo(P);
S = D.Private_0029_1020;
n = numel(D.Private_0019_1029);
S = char(S');
j = strfind(S,'sSliceArray.ucMode');
[~, r] = strtok(S(j:j + 100), '=');
ucmode = strtok(strtok(r, '='));
% image dimensions
% -----------------------------------------
mtx = double(D.AcquisitionMatrix([1 4]))';
pxl = double(D.PixelSpacing)';
vxl = cat(2,pxl,D.SliceThickness);
% phase encoding
% -----------------------------------------
bpp = D.Private_0019_1028;
msp = sscanf(D.Private_0051_100b,'%d');
% store
% -----------------------------------------
I.TR = D.RepetitionTime;
I.TE = D.EchoTime;
I.FA = D.FlipAngle;
I.ES = 1/(bpp/msp);
I.RT = 1/bpp;
I.FoV = pxl.*mtx;
I.Dim = cat(2,mtx,n);
I.Voxel = vxl;
I.Nslices = n;
I.Slicethick = D.SliceThickness;
I.Tesla = D.MagneticFieldStrength;
switch(ucmode)
case '0x1'
I.Acquisition = 'ascending';
I.Order = 1:n;
case '0x2'
I.Acquisition = 'descending';
I.Order = n:-1:1;
case '0x4'
I.Acquisition = 'interleaved';
if isequal(fix(n/2),n/2)
I.Order = [2:2:n 1:2:n];
else
I.Order = [1:2:n 2:2:n];
end
otherwise
I.Acquisition = 'unknown';
I.Order = 'unknown';
end
elseif exist('spm.m','file')
D = spm_dicom_headers(P);
D = D{:};
% image dimensions
% -----------------------------------------
mtx = double(D.AcquisitionMatrix([1 4]));
pxl = double(D.PixelSpacing)';
vxl = cat(2,pxl,D.SliceThickness);
n = numel(D.Private_0019_1029);
% phase encoding
% -----------------------------------------
bpp = D.Private_0019_1028;
msp = sscanf(D.Private_0051_100b,'%d');
% store
% -----------------------------------------
I.TR = D.RepetitionTime;
I.TE = D.EchoTime;
I.FA = D.FlipAngle;
I.ES = 1/(bpp/msp);
I.RT = 1/bpp;
I.FoV = pxl.*mtx;
I.Dim = cat(2,mtx,n);
I.Voxel = vxl;
I.Nslices = n;
I.Slicethick = D.SliceThickness;
I.Tesla = D.MagneticFieldStrength;
end