|
41 | 41 | % Indicates group membership for each image as vector, categorical, |
42 | 42 | % or string array |
43 | 43 | % |
| 44 | +% **mask** |
| 45 | +% Followed by mask on path, default canlab gray matter mask |
| 46 | +% Mask will be applied to both fmri_data_obj and hansen maps |
| 47 | +% |
44 | 48 | % :Outputs: |
45 | 49 | % |
46 | 50 | % **stats:** |
|
128 | 132 | % this function, and debugged plotting for multiple groups in |
129 | 133 | % image_similarity_plot |
130 | 134 | % |
| 135 | +% Lukas: Added mask option |
| 136 | +% |
131 | 137 | % .. |
132 | 138 |
|
133 | 139 | % ------------------------------------------------------------------------- |
|
137 | 143 | colors = [1 0 0]; |
138 | 144 | dofigure = true; |
139 | 145 | doplot = true; |
140 | | -similarity_metric = 'corr'; |
| 146 | +similarity_metric = 'correlation'; |
141 | 147 | dofixrange = []; |
| 148 | +mask = which('gray_matter_mask.nii'); |
142 | 149 |
|
143 | 150 | doAverage=0; |
144 | 151 | % ------------------------------------------------------------------------- |
|
150 | 157 |
|
151 | 158 | allowable_inputs = {'colors' 'doplot' 'similarity_metric' 'dofixrange'}; |
152 | 159 |
|
153 | | -keyword_inputs = {'noplot' 'nofigure' 'cosine_similarity' 'doAverage' 'compareGroups'}; |
| 160 | +keyword_inputs = {'noplot' 'nofigure' 'cosine_similarity' 'doAverage' 'compareGroups', 'mask'}; |
154 | 161 |
|
155 | 162 | % optional inputs with default values - each keyword entered will create a variable of the same name |
156 | 163 |
|
|
190 | 197 | case 'compareGroups' |
191 | 198 | compareGroups = true; |
192 | 199 | group = varargin{i+1}; |
| 200 | + |
| 201 | + case 'mask' |
| 202 | + mask = varargin{i+1}; |
193 | 203 |
|
194 | 204 | end |
195 | 205 | end |
196 | 206 | end |
197 | 207 |
|
| 208 | +% ------------------------------------------------------------------------- |
| 209 | +% INTIALIZE OUTPUT |
| 210 | +% ------------------------------------------------------------------------- |
| 211 | +stats = struct(); |
| 212 | +[hh, hhfill] = deal(' '); |
| 213 | +table_group = {}; |
| 214 | +multcomp_group = {}; |
| 215 | + |
198 | 216 | % ------------------------------------------------------------------------- |
199 | 217 | % MAIN FUNCTION |
200 | 218 | % ------------------------------------------------------------------------- |
|
204 | 222 | ntmaps = reorder_and_add_metadata(ntmaps); |
205 | 223 |
|
206 | 224 | % These are already gray-matter masked in repo, but make sure: |
207 | | -ntmaps = apply_mask(ntmaps, which('gray_matter_mask.nii')); |
| 225 | +ntmaps = apply_mask(ntmaps, mask); |
208 | 226 |
|
209 | 227 | % This may not be masked...so mask with gray matter: |
210 | | -fmri_data_obj = apply_mask(fmri_data_obj, which('gray_matter_mask.nii')); |
| 228 | +fmri_data_obj = apply_mask(fmri_data_obj, mask); |
| 229 | + |
| 230 | +% handle tags for figure(s) |
| 231 | +if dofigure |
| 232 | + tagname = ['Neurotransmitter polar plot ' similarity_metric]; |
| 233 | + old = findobj('Tag', tagname); |
| 234 | + old = old( strcmp( get(old, 'Type'), 'figure' ) ); |
211 | 235 |
|
212 | | -if dofigure |
213 | | - create_figure('Neurotransmitter polar plot') |
| 236 | + if ~isempty(old) % Found existing figure window with this tag |
| 237 | + create_figure([tagname ' ' num2str(length(old)+1)]) |
| 238 | + else |
| 239 | + create_figure(tagname) |
| 240 | + end |
214 | 241 | end |
215 | 242 |
|
216 | 243 | if doplot |
217 | 244 | if ~iscell(colors), colors = {colors}; end |
| 245 | + |
| 246 | + switch similarity_metric |
| 247 | + |
| 248 | + case 'cosine_similarity' |
| 249 | + |
| 250 | + if doAverage==1 |
| 251 | + if isempty(dofixrange) |
| 252 | + |
| 253 | + if exist('compareGroups','var') % added by Lukas: if we want to analyze & plot multiple groups |
| 254 | + |
| 255 | + groupValues = unique(group, 'stable'); |
| 256 | + if size(colors,1) ~= size(groupValues,1) |
| 257 | + colors = scn_standard_colors(length(groupValues))'; |
| 258 | + end |
| 259 | + |
| 260 | + [stats, hh, hhfill, table_group, multcomp_group] = image_similarity_plot(fmri_data_obj, 'mapset', ntmaps, similarity_metric, 'plotstyle', 'polar', 'networknames', ntmaps.metadata_table.target, 'colors', colors, 'nofigure', 'average','compareGroups', group); |
| 261 | + |
| 262 | + else |
| 263 | + |
| 264 | + [stats, hh, hhfill] = image_similarity_plot(fmri_data_obj, 'mapset', ntmaps, similarity_metric, 'plotstyle', 'polar', 'networknames', ntmaps.metadata_table.target, 'colors', colors, 'nofigure', 'average','Error_STD'); |
| 265 | + end |
| 266 | + |
| 267 | + else |
| 268 | + |
| 269 | + if exist('compareGroups','var') % % added by Lukas: if we want to analyze & plot multiple groups |
| 270 | + |
| 271 | + groupValues = unique(group, 'stable'); |
| 272 | + if size(colors,1) ~= size(groupValues,1) |
| 273 | + colors = scn_standard_colors(length(groupValues))'; |
| 274 | + end |
| 275 | + |
| 276 | + [stats, hh, hhfill, table_group, multcomp_group] = image_similarity_plot(fmri_data_obj, 'mapset', ntmaps, similarity_metric, 'plotstyle', 'polar', 'networknames', ntmaps.metadata_table.target, 'colors', colors, 'nofigure', 'dofixrange', dofixrange, 'average', 'compareGroups', group); |
| 277 | + |
| 278 | + else |
| 279 | + |
| 280 | + [stats, hh, hhfill] = image_similarity_plot(fmri_data_obj, 'mapset', ntmaps, similarity_metric, 'plotstyle', 'polar', 'networknames', ntmaps.metadata_table.target, 'colors', colors, 'nofigure', 'dofixrange', dofixrange,'average','Error_STD'); |
| 281 | + end |
218 | 282 |
|
219 | | - if doAverage==1 |
220 | | - if isempty(dofixrange) |
221 | | - |
222 | | - if exist('compareGroups','var') % added by Lukas: if we want to analyze & plot multiple groups |
223 | | - |
224 | | - groupValues = unique(group, 'stable'); |
225 | | - if size(colors,1) ~= size(groupValues,1) |
226 | | - colors = scn_standard_colors(length(groupValues))'; |
227 | 283 | end |
228 | | - |
229 | | - [stats, hh, hhfill, table_group, multcomp_group] = image_similarity_plot(fmri_data_obj, 'mapset', ntmaps, similarity_metric, 'plotstyle', 'polar', 'networknames', ntmaps.metadata_table.target, 'colors', colors, 'nofigure', 'average','compareGroups', group); |
230 | | - |
| 284 | + |
231 | 285 | else |
232 | | - |
233 | | - [stats, hh, hhfill, table_group, multcomp_group] = image_similarity_plot(fmri_data_obj, 'mapset', ntmaps, similarity_metric, 'plotstyle', 'polar', 'networknames', ntmaps.metadata_table.target, 'colors', colors, 'nofigure', 'average','Error_STD'); |
| 286 | + if isempty(dofixrange) |
| 287 | + |
| 288 | + [stats, hh, hhfill] = image_similarity_plot(fmri_data_obj, 'mapset', ntmaps, similarity_metric, 'plotstyle', 'polar', 'networknames', ntmaps.metadata_table.target, 'colors', colors, 'nofigure'); |
| 289 | + |
| 290 | + else % we have fixed range |
| 291 | + |
| 292 | + [stats, hh, hhfill] = image_similarity_plot(fmri_data_obj, 'mapset', ntmaps, similarity_metric, 'plotstyle', 'polar', 'networknames', ntmaps.metadata_table.target, 'colors', colors, 'nofigure', 'dofixrange', dofixrange); |
| 293 | + |
| 294 | + end |
234 | 295 | end |
| 296 | + |
| 297 | + case 'correlation' |
235 | 298 |
|
236 | | - else |
237 | | - |
238 | | - if exist('compareGroups','var') % % added by Lukas: if we want to analyze & plot multiple groups |
239 | | - |
240 | | - groupValues = unique(group, 'stable'); |
241 | | - if size(colors,1) ~= size(groupValues,1) |
242 | | - colors = scn_standard_colors(length(groupValues))'; |
| 299 | + if doAverage==1 |
| 300 | + if isempty(dofixrange) |
| 301 | + |
| 302 | + if exist('compareGroups','var') % added by Lukas: if we want to analyze & plot multiple groups |
| 303 | + |
| 304 | + groupValues = unique(group, 'stable'); |
| 305 | + if size(colors,1) ~= size(groupValues,1) |
| 306 | + colors = scn_standard_colors(length(groupValues))'; |
| 307 | + end |
| 308 | + |
| 309 | + [stats, hh, hhfill, table_group, multcomp_group] = image_similarity_plot(fmri_data_obj, 'mapset', ntmaps, 'plotstyle', 'polar', 'networknames', ntmaps.metadata_table.target, 'colors', colors, 'nofigure', 'average','compareGroups', group); |
| 310 | + |
| 311 | + else |
| 312 | + |
| 313 | + [stats, hh, hhfill] = image_similarity_plot(fmri_data_obj, 'mapset', ntmaps, 'plotstyle', 'polar', 'networknames', ntmaps.metadata_table.target, 'colors', colors, 'nofigure', 'average','Error_STD'); |
| 314 | + end |
| 315 | + |
| 316 | + else |
| 317 | + |
| 318 | + if exist('compareGroups','var') % % added by Lukas: if we want to analyze & plot multiple groups |
| 319 | + |
| 320 | + groupValues = unique(group, 'stable'); |
| 321 | + if size(colors,1) ~= size(groupValues,1) |
| 322 | + colors = scn_standard_colors(length(groupValues))'; |
| 323 | + end |
| 324 | + |
| 325 | + [stats, hh, hhfill, table_group, multcomp_group] = image_similarity_plot(fmri_data_obj, 'mapset', ntmaps, 'plotstyle', 'polar', 'networknames', ntmaps.metadata_table.target, 'colors', colors, 'nofigure', 'dofixrange', dofixrange, 'average', 'compareGroups', group); |
| 326 | + |
| 327 | + else |
| 328 | + |
| 329 | + [stats, hh, hhfill] = image_similarity_plot(fmri_data_obj, 'mapset', ntmaps, 'plotstyle', 'polar', 'networknames', ntmaps.metadata_table.target, 'colors', colors, 'nofigure', 'dofixrange', dofixrange,'average','Error_STD'); |
| 330 | + end |
| 331 | + |
243 | 332 | end |
244 | | - |
245 | | - [stats, hh, hhfill, table_group, multcomp_group] = image_similarity_plot(fmri_data_obj, 'mapset', ntmaps, similarity_metric, 'plotstyle', 'polar', 'networknames', ntmaps.metadata_table.target, 'colors', colors, 'nofigure', 'dofixrange', dofixrange, 'average', 'compareGroups', group); |
246 | 333 |
|
247 | 334 | else |
248 | | - |
249 | | - [stats, hh, hhfill, table_group, multcomp_group] = image_similarity_plot(fmri_data_obj, 'mapset', ntmaps, similarity_metric, 'plotstyle', 'polar', 'networknames', ntmaps.metadata_table.target, 'colors', colors, 'nofigure', 'dofixrange', dofixrange,'average','Error_STD'); |
| 335 | + if isempty(dofixrange) |
| 336 | + |
| 337 | + [stats, hh, hhfill] = image_similarity_plot(fmri_data_obj, 'mapset', ntmaps, 'plotstyle', 'polar', 'networknames', ntmaps.metadata_table.target, 'colors', colors, 'nofigure'); |
| 338 | + |
| 339 | + else % we have fixed range |
| 340 | + |
| 341 | + [stats, hh, hhfill] = image_similarity_plot(fmri_data_obj, 'mapset', ntmaps, 'plotstyle', 'polar', 'networknames', ntmaps.metadata_table.target, 'colors', colors, 'nofigure', 'dofixrange', dofixrange); |
| 342 | + |
| 343 | + end |
250 | 344 | end |
251 | 345 |
|
252 | | - end |
253 | | - |
254 | | - else |
255 | | - if isempty(dofixrange) |
256 | | - |
257 | | - [stats, hh, hhfill, table_group, multcomp_group] = image_similarity_plot(fmri_data_obj, 'mapset', ntmaps, similarity_metric, 'plotstyle', 'polar', 'networknames', ntmaps.metadata_table.target, 'colors', colors, 'nofigure'); |
258 | | - |
259 | | - else % we have fixed range |
260 | | - |
261 | | - [stats, hh, hhfill, table_group, multcomp_group] = image_similarity_plot(fmri_data_obj, 'mapset', ntmaps, similarity_metric, 'plotstyle', 'polar', 'networknames', ntmaps.metadata_table.target, 'colors', colors, 'nofigure', 'dofixrange', dofixrange); |
262 | | - |
263 | | - end |
264 | | - end |
| 346 | + end % switch similarity metric |
265 | 347 |
|
266 | 348 | else |
267 | | - [stats, hh, hhfill, table_group, multcomp_group] = image_similarity_plot(fmri_data_obj, 'mapset', ntmaps, similarity_metric, 'noplot'); |
| 349 | + |
| 350 | + switch similarity_metric |
| 351 | + |
| 352 | + case 'cosine_similarity' |
| 353 | + |
| 354 | + [stats, hh, hhfill] = image_similarity_plot(fmri_data_obj, 'mapset', ntmaps, similarity_metric, 'noplot'); |
| 355 | + |
| 356 | + case 'correlation' |
| 357 | + |
| 358 | + [stats, hh, hhfill] = image_similarity_plot(fmri_data_obj, 'mapset', ntmaps, 'noplot'); |
| 359 | + |
| 360 | + end % switch similarity metric |
268 | 361 |
|
269 | | -end |
| 362 | +end % if doplot |
270 | 363 |
|
271 | 364 | end % main function |
272 | 365 |
|
|
0 commit comments