Skip to content

Commit d670d82

Browse files
lukasvo76viveksgr
andauthored
Same pull request (#81)
* bug fixes to canlab scripts, and completely revamped searchlight_disti * finished searchlight_disti_Lukas function --------- Co-authored-by: Vivek Sagar <VivekSagar2016@u.northwestern.edu>
1 parent f0a78aa commit d670d82

5 files changed

Lines changed: 617 additions & 822 deletions

File tree

CanlabCore/@image_vector/hansen_neurotransmitter_maps.m

Lines changed: 138 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
% Indicates group membership for each image as vector, categorical,
4242
% or string array
4343
%
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+
%
4448
% :Outputs:
4549
%
4650
% **stats:**
@@ -128,6 +132,8 @@
128132
% this function, and debugged plotting for multiple groups in
129133
% image_similarity_plot
130134
%
135+
% Lukas: Added mask option
136+
%
131137
% ..
132138

133139
% -------------------------------------------------------------------------
@@ -137,8 +143,9 @@
137143
colors = [1 0 0];
138144
dofigure = true;
139145
doplot = true;
140-
similarity_metric = 'corr';
146+
similarity_metric = 'correlation';
141147
dofixrange = [];
148+
mask = which('gray_matter_mask.nii');
142149

143150
doAverage=0;
144151
% -------------------------------------------------------------------------
@@ -150,7 +157,7 @@
150157

151158
allowable_inputs = {'colors' 'doplot' 'similarity_metric' 'dofixrange'};
152159

153-
keyword_inputs = {'noplot' 'nofigure' 'cosine_similarity' 'doAverage' 'compareGroups'};
160+
keyword_inputs = {'noplot' 'nofigure' 'cosine_similarity' 'doAverage' 'compareGroups', 'mask'};
154161

155162
% optional inputs with default values - each keyword entered will create a variable of the same name
156163

@@ -190,11 +197,22 @@
190197
case 'compareGroups'
191198
compareGroups = true;
192199
group = varargin{i+1};
200+
201+
case 'mask'
202+
mask = varargin{i+1};
193203

194204
end
195205
end
196206
end
197207

208+
% -------------------------------------------------------------------------
209+
% INTIALIZE OUTPUT
210+
% -------------------------------------------------------------------------
211+
stats = struct();
212+
[hh, hhfill] = deal(' ');
213+
table_group = {};
214+
multcomp_group = {};
215+
198216
% -------------------------------------------------------------------------
199217
% MAIN FUNCTION
200218
% -------------------------------------------------------------------------
@@ -204,69 +222,144 @@
204222
ntmaps = reorder_and_add_metadata(ntmaps);
205223

206224
% 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);
208226

209227
% 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' ) );
211235

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
214241
end
215242

216243
if doplot
217244
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
218282

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))';
227283
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+
231285
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
234295
end
296+
297+
case 'correlation'
235298

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+
243332
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);
246333

247334
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
250344
end
251345

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
265347

266348
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
268361

269-
end
362+
end % if doplot
270363

271364
end % main function
272365

0 commit comments

Comments
 (0)