-
Notifications
You must be signed in to change notification settings - Fork 3
/
read_Philips_T1rho.m
95 lines (94 loc) · 2.52 KB
/
read_Philips_T1rho.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
%#######################################################################
%
% * READ PHILIPS T1rho Program *
%
% M-File which reads the T1rho values generated by Philips
% from the DICOM files. The T1rho values are scaled and saved to
% a MAT file.
%
% NOTES: 1. The T1rho DICOM files must be in the subdirectory
% v4\DICOM\.
%
% 2. The image size is assumed to be 512 pixels. See
% variable "npxp" on line 22.
%
% 04-Aug-2020 * Mack Gardner-Morse
%
%#######################################################################
%
% Number of Pixels
%
npxp = 512; % Number of pixels in each direction (symmetrical)
%
% Get Data Subdirectory and Filenames for the Four Series
%
dir_nam = fullfile('v4','DICOM');
fnamsp = dir(fullfile(dir_nam,'IM_*'));
fnamsp = {fnamsp.name}';
nfiles = size(fnamsp,1);
%
% Get Index to the Series Based on the Numbers in the File Names
%
a = [ ['['; repmat(' ',nfiles-1,1)] char(extractAfter(fnamsp,'_')) ...
[repmat(';',nfiles-1,1); ']'] ];
a = a';
a = a(:)';
fnums = eval(a); % Numbers in the filenames
fdif = diff(fnums);
id1p = find(fdif>1);
id1p = [1; id1p+1]; % Index to series
%
% Get Series Descriptions
%
ns = size(id1p,1);
id1p = [id1p; nfiles];
series_descp = cell(ns,1);
for k = 1:ns
idp = id1p(k);
info = dicominfo(fullfile(dir_nam,fnamsp{idp}));
series_descp{k} = info.SeriesDescription;
end
%
% Pick Series and Get Index to Files
%
idxp = menu('Pick a WIP Series',series_descp);
idp = id1p(idxp):id1p(idxp+1)-1; % Index to filenames
nfp = length(idp); % Number of files (slices)
%
% Get Series Description
%
fsp = series_descp{idxp};
fsp = extractAfter(fsp,'3DMAPPS'); % Short series description w/o WIP & 3DMAPPS
fsp = strtrim(fsp); % Series description
%
% Set Up Array for Loop
%
T1rhop = zeros(npxp,npxp,nfp,'single'); % Philips' time constants
%
% Loop through Files (Slices)
%
for k = 1:nfp
%
fnam = fnamsp{idp(k)}; % Filename for this slice
fnam = fullfile(dir_nam,fnam);
%
% Load and Scale Image
%
img = dicomread(fnam);
img = single(img);
%
info = dicominfo(fnam);
sl = single(info.RescaleSlope);
offst = single(info.RescaleIntercept); % Usually zero
T1rhop(:,:,k) = sl*img+offst;
%
end
%
% Save MAT File
%
mnam = ['T1rhop_' fsp '.mat'];
%
save(mnam,'idp','id1p','idxp','fnamsp','fsp','nfp','npxp','T1rhop', ...
'series_descp');
%
return