forked from noxtoby/TADPOLE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
extractSalientColumns.m
53 lines (47 loc) · 2.05 KB
/
extractSalientColumns.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
function [ADAS13_Col, Ventricles_Col, ICV_Col, Ventricles_ICV_Col, ...
CLIN_STAT_Col, RID_Col, ExamMonth_Col, AGE_Bl_Col, Viscode_Col, D2_col] = extractSalientColumns(TADPOLE_Table)
%* Copy numeric target variables into arrays. Missing data is encoded as -1
% ADAS13 scores
ADAS13_Col = TADPOLE_Table.ADAS13;
ADAS13_Col(isnan(ADAS13_Col)) = -1;
% Ventricles volumes, normalised by intracranial volume
Ventricles_Col = TADPOLE_Table.Ventricles;
Ventricles_Col(isnan(Ventricles_Col)) = -1;
ICV_Col = TADPOLE_Table.ICV_bl;
ICV_Col(Ventricles_Col==-1) = 1;
Ventricles_ICV_Col = Ventricles_Col./ICV_Col;
%* Create an array containing the clinical status (current diagnosis DX)
%* column from the spreadsheet
DXCHANGE = TADPOLE_Table.DX; % 'NL to MCI', 'MCI to Dementia', etc. = '[previous DX] to [current DX]'
DX = DXCHANGE; % Note: missing data encoded as empty string
%* Convert DXCHANGE to current DX, i.e., the final
for kr=1:length(DXCHANGE)
spaces = strfind(DXCHANGE{kr},' '); % find the spaces in DXCHANGE
if not(isempty(spaces))
DX{kr} = DXCHANGE{kr}((spaces(end)+1):end); % extract current DX
end
end
CLIN_STAT_Col = DX;
%* Copy the subject ID column from the spreadsheet into an array.
RID_Col = TADPOLE_Table.RID;
RID_Col(isnan(RID_Col)) = -1; % missing data encoded as -1
%* Compute months since Jan 2000 for each exam date
%EXAMDATE = cell2mat(TADPOLE_Table.EXAMDATE);
ExamMonth_Col = zeros(length(TADPOLE_Table.EXAMDATE),1);
for i=1:length(TADPOLE_Table.EXAMDATE)
% ExamMonth_Col(i) = (str2num(TADPOLE_Table.EXAMDATE{i}(1:4))-2000)*12 + str2num(TADPOLE_Table.EXAMDATE{i}(6:7));
ExamMonth_Col(i) = (year(TADPOLE_Table.EXAMDATE(i))-2000)*12 + month(TADPOLE_Table.EXAMDATE(i));
end
AGE_Bl_Col = TADPOLE_Table.AGE;
AGE_Bl_Col(isnan(AGE_Bl_Col)) = -1;
Viscode_Col = TADPOLE_Table.VISCODE;
%* Copy the column specifying membership of D2 into an array.
if ismember('D2', TADPOLE_Table.Properties.VariableNames)
if iscell(TADPOLE_Table.D2)
D2_col = str2num(cell2mat(TADPOLE_Table.D2));
else
D2_col = TADPOLE_Table.D2;
end
else
D2_col = nan;
end