-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFindPipelineCombinations.m
180 lines (146 loc) · 6.32 KB
/
FindPipelineCombinations.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
function [ORDERED_INDS,ORDERED_MATRIX,LABELS] = FindPipelineCombinations(TYPE,ORDER,EXCLUDE)
% This function will pull out the index or indices of a desired pipeline
% INPUTS:
% Required
% TYPE = a 1*7 vector indicating which pipeline/s with a particular
% parameter you want to extract the index/indices of. The position of each
% value indicates the processing step and the value at that position
% indicates which specific step to extract. A value of zero indicates to
% not extract pipelines based on that processing step. See below for an
% explanation of how to use
%
% Optional
% ORDER = a 1*7 vector specifying the order in which to arrange the indices
% (if extracting a single pipeline this has no effect). The first value
% indicates by which processing step to order pipelines by, the second
% value indicates which processing step to further order pipelines after
% the first ordering, the third indicates which to use for ordering after
% the second etc etc.
% EXCLUDE = a binary value of 1 or 0. If set to 1, any processing step for
% which only a single value is being extracted will be removed from
% ORDERED_MATRIX and LABELS
%
% OUTPUTS:
% ORDERED_INDS = the index/indicies of the desired pipelines, ordering
% according to what is specified by ORDER
% ORDERED_MATRIX = a 7*N matrix, where N is the number of pipelines
% extracted. Each column corresponds to a pipeline and each row is a
% processing step. Each row correponds corresponds to a processing step
% (and the ordering of these rows is determined by ORDER), and the value
% indicates the specific algorithm/method being used.
% LABELS = a cell indicating what the values in each row of ORDERED_MATRIX
% correspond to. This is set up so if you do imagesc(ORDERED_MATRIX) and
% yticklabels(LABELS) it will format it as per the paper
%
% HOW TO USE:
% TYPE = [DistCorr TractAlgor SptlCons Seeding TractWei EdgeWei Parc]
%
% DistCorr = 1, EDDY1
% DistCorr = 2, EDDY2
%
% TractAlgor = 1, FACT
% TractAlgor = 2, iFOD2
%
% SptlCons = 1, ACT
% SptlCons = 2, GWM
%
% Seeding = 1, dyn
% Seeding = 2, WM
% Seeding = 3, GMWMI
%
% TractWei = 1, None
% TractWei = 2, SIFT2
%
% EdgeWei = 1, SSW
% EdgeWei = 2, FA
%
% Parc = 1, 82 Node
% Parc = 2, 220 Node
% Parc = 3, 380 Node
%
% So TYPE = [1 1 2 3 1 1 3] would extract the index of the pipeline that
% used EDDY1, FACT, ACT, GMWMI seeding, no filtering, SSW edge weighting
% and the 380 node parcellation.
%
% TYPE = [1 0 0 0 0 0 2] would extract the indicies of all pipelines using
% the 220 node parcellation, TYPE = [1 0 0 0 0 0 2] would extract all
% pipelines using EDDY1 and the 220 node parcellation etc.
%
% ORDER = [7 1 6 2 4 3 5] extracts indices in the order of first being
% sorted by 'Parcellation', then 'DistCorr', then 'EdgeWei', then
% 'TractAlgor', then 'SptlCons', then 'Seeding', and then by 'TractWei'.
% In other words, pipelines are primarily ordered by the type of
% parcellation they used, then within that ordering they are order by the
% type of motion corretion used etc etc
%
% if TYPE = [0 0 1 0 0 0 0], ORDER = [7 1 6 2 4 3 5] and EXCLUDED = 0, then
% ORDERED_MATRIX(1,:) and LABELS{1} will correspond to the values of
% 'EdgeWei', ORDERED_MATRIX(2,:) and LABELS{2} will correspond to the
% values of 'SptlCons' etc etc. If EXCLUDED = 1, then ORDERED_MATRIX(1,:),
% LABELS{1} will correspond to the values of 'EdgeWei', ORDERED_MATRIX(2,:),
% LABELS{2} will correspond to the values of 'Seeding' etc etc
if nargin < 2
% Default ordering
ORDER = [7 1 6 2 4 3 5];
end
if nargin < 3
EXCLUDE = 0;
end
load('COMBINATIONS_MATRIX.mat')
EXTRACT_INDS = find(TYPE);
N_TYPES_TO_EXTRACT = length(EXTRACT_INDS);
if N_TYPES_TO_EXTRACT == 0
INDS = 1:size(COMBINATIONS,1);
elseif N_TYPES_TO_EXTRACT == 1
INDS = find(COMBINATIONS(:,EXTRACT_INDS) == TYPE(EXTRACT_INDS));
else
for i = 1:N_TYPES_TO_EXTRACT
EXTRACT_IND = EXTRACT_INDS(i);
INDStemp = find(COMBINATIONS(:,EXTRACT_IND) == TYPE(EXTRACT_IND));
if i > 1
INDS = intersect(INDS,INDStemp);
else
INDS = INDStemp;
end
end
end
% I flip the order so that the first processing step pipelines are ordered
% by is the last position in the labels naming convection
ORDER_FLIP = flip(ORDER);
% Because COMBINATION contains a row with values of 1 and 3 instead of 1
% and 3, we turn that 3 into a 2
%COMBINATIONS((COMBINATIONS(:,6)==3),6) = 2;
% Extract values of COMBINATION according to the desired pipeline INDCIES
% that wish to be found. Subtract 1 to make all values in the range 0-2
ORDERED_MATRIX = COMBINATIONS(INDS,:)' -1;
ORDERED_MATRIX = ORDERED_MATRIX(ORDER_FLIP,:);
orderIND = cell(1,7);
for i = 1:7
[~,orderIND{i}] = sort(ORDERED_MATRIX(i,:));
ORDERED_MATRIX = ORDERED_MATRIX(:,orderIND{i});
end
order = orderIND{6}(orderIND{7});
for i = 5:-1:1
order = orderIND{i}(order);
end
ORDERED_INDS = INDS(order);
Color1 = [186,186,186]./255;
Color2 = [64,64,64]./255;
Color3 = [244,165,130]./255;
Color4 = [171,217,233]./255;
Color5 = [69,117,180]./255;
Color6 = [49,54,149]./255;
LABELS = cell(7,1);
LABELS{(ORDER_FLIP==1)} = [sprintf('DistCorr:{\\color[rgb]{%f,%f,%f}EDDY1}/',Color1),sprintf('\\color[rgb]{%f,%f,%f}EDDY2',Color2)];
LABELS{(ORDER_FLIP==6)} = [sprintf('EdgeWei:{\\color[rgb]{%f,%f,%f}SSW}/',Color1),sprintf('\\color[rgb]{%f,%f,%f}FA',Color2)];
LABELS{(ORDER_FLIP==2)} = [sprintf('TractAlgor:{\\color[rgb]{%f,%f,%f}FACT}/',Color1),sprintf('\\color[rgb]{%f,%f,%f}iFOD2',Color2)];
LABELS{(ORDER_FLIP==4)} = [sprintf('Seed:{\\color[rgb]{%f,%f,%f}dynamic}/',Color1),sprintf('{\\color[rgb]{%f,%f,%f}WM}/',Color2),sprintf('{\\color[rgb]{%f,%f,%f}GMWMI}',Color3)];
LABELS{(ORDER_FLIP==3)} = [sprintf('SptlCons:{\\color[rgb]{%f,%f,%f}ACT}/',Color1),sprintf('\\color[rgb]{%f,%f,%f}GWM',Color2)];
LABELS{(ORDER_FLIP==5)} = [sprintf('TractWei:{\\color[rgb]{%f,%f,%f}None}/',Color1),sprintf('\\color[rgb]{%f,%f,%f}SIFT2',Color2)];
LABELS{(ORDER_FLIP==7)} = [sprintf('Parc:{\\color[rgb]{%f,%f,%f}82}/',Color1),sprintf('{\\color[rgb]{%f,%f,%f}R220}/',Color2),sprintf('{\\color[rgb]{%f,%f,%f}HCP}',Color3)...
,sprintf('Parc:{\\color[rgb]{%f,%f,%f}R520}/',Color4),sprintf('Parc:{\\color[rgb]{%f,%f,%f}S220}/',Color5),sprintf('Parc:{\\color[rgb]{%f,%f,%f}S520}/',Color6)];
if EXCLUDE
EXCLUDE_INDS = TYPE~=0;
LABELS(EXCLUDE_INDS) = [];
ORDERED_MATRIX(EXCLUDE_INDS,:) = [];
end