Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
183 changes: 138 additions & 45 deletions CanlabCore/@image_vector/hansen_neurotransmitter_maps.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
% Indicates group membership for each image as vector, categorical,
% or string array
%
% **mask**
% Followed by mask on path, default canlab gray matter mask
% Mask will be applied to both fmri_data_obj and hansen maps
%
% :Outputs:
%
% **stats:**
Expand Down Expand Up @@ -128,6 +132,8 @@
% this function, and debugged plotting for multiple groups in
% image_similarity_plot
%
% Lukas: Added mask option
%
% ..

% -------------------------------------------------------------------------
Expand All @@ -137,8 +143,9 @@
colors = [1 0 0];
dofigure = true;
doplot = true;
similarity_metric = 'corr';
similarity_metric = 'correlation';
dofixrange = [];
mask = which('gray_matter_mask.nii');

doAverage=0;
% -------------------------------------------------------------------------
Expand All @@ -150,7 +157,7 @@

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

keyword_inputs = {'noplot' 'nofigure' 'cosine_similarity' 'doAverage' 'compareGroups'};
keyword_inputs = {'noplot' 'nofigure' 'cosine_similarity' 'doAverage' 'compareGroups', 'mask'};

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

Expand Down Expand Up @@ -190,11 +197,22 @@
case 'compareGroups'
compareGroups = true;
group = varargin{i+1};

case 'mask'
mask = varargin{i+1};

end
end
end

% -------------------------------------------------------------------------
% INTIALIZE OUTPUT
% -------------------------------------------------------------------------
stats = struct();
[hh, hhfill] = deal(' ');
table_group = {};
multcomp_group = {};

% -------------------------------------------------------------------------
% MAIN FUNCTION
% -------------------------------------------------------------------------
Expand All @@ -204,69 +222,144 @@
ntmaps = reorder_and_add_metadata(ntmaps);

% These are already gray-matter masked in repo, but make sure:
ntmaps = apply_mask(ntmaps, which('gray_matter_mask.nii'));
ntmaps = apply_mask(ntmaps, mask);

% This may not be masked...so mask with gray matter:
fmri_data_obj = apply_mask(fmri_data_obj, which('gray_matter_mask.nii'));
fmri_data_obj = apply_mask(fmri_data_obj, mask);

% handle tags for figure(s)
if dofigure
tagname = ['Neurotransmitter polar plot ' similarity_metric];
old = findobj('Tag', tagname);
old = old( strcmp( get(old, 'Type'), 'figure' ) );

if dofigure
create_figure('Neurotransmitter polar plot')
if ~isempty(old) % Found existing figure window with this tag
create_figure([tagname ' ' num2str(length(old)+1)])
else
create_figure(tagname)
end
end

if doplot
if ~iscell(colors), colors = {colors}; end

switch similarity_metric

case 'cosine_similarity'

if doAverage==1
if isempty(dofixrange)

if exist('compareGroups','var') % added by Lukas: if we want to analyze & plot multiple groups

groupValues = unique(group, 'stable');
if size(colors,1) ~= size(groupValues,1)
colors = scn_standard_colors(length(groupValues))';
end

[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);

else

[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');
end

else

if exist('compareGroups','var') % % added by Lukas: if we want to analyze & plot multiple groups

groupValues = unique(group, 'stable');
if size(colors,1) ~= size(groupValues,1)
colors = scn_standard_colors(length(groupValues))';
end

[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);

else

[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');
end

if doAverage==1
if isempty(dofixrange)

if exist('compareGroups','var') % added by Lukas: if we want to analyze & plot multiple groups

groupValues = unique(group, 'stable');
if size(colors,1) ~= size(groupValues,1)
colors = scn_standard_colors(length(groupValues))';
end

[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);


else

[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');
if isempty(dofixrange)

[stats, hh, hhfill] = image_similarity_plot(fmri_data_obj, 'mapset', ntmaps, similarity_metric, 'plotstyle', 'polar', 'networknames', ntmaps.metadata_table.target, 'colors', colors, 'nofigure');

else % we have fixed range

[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);

end
end

case 'correlation'

else

if exist('compareGroups','var') % % added by Lukas: if we want to analyze & plot multiple groups

groupValues = unique(group, 'stable');
if size(colors,1) ~= size(groupValues,1)
colors = scn_standard_colors(length(groupValues))';
if doAverage==1
if isempty(dofixrange)

if exist('compareGroups','var') % added by Lukas: if we want to analyze & plot multiple groups

groupValues = unique(group, 'stable');
if size(colors,1) ~= size(groupValues,1)
colors = scn_standard_colors(length(groupValues))';
end

[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);

else

[stats, hh, hhfill] = image_similarity_plot(fmri_data_obj, 'mapset', ntmaps, 'plotstyle', 'polar', 'networknames', ntmaps.metadata_table.target, 'colors', colors, 'nofigure', 'average','Error_STD');
end

else

if exist('compareGroups','var') % % added by Lukas: if we want to analyze & plot multiple groups

groupValues = unique(group, 'stable');
if size(colors,1) ~= size(groupValues,1)
colors = scn_standard_colors(length(groupValues))';
end

[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);

else

[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');
end

end

[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);

else

[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');
if isempty(dofixrange)

[stats, hh, hhfill] = image_similarity_plot(fmri_data_obj, 'mapset', ntmaps, 'plotstyle', 'polar', 'networknames', ntmaps.metadata_table.target, 'colors', colors, 'nofigure');

else % we have fixed range

[stats, hh, hhfill] = image_similarity_plot(fmri_data_obj, 'mapset', ntmaps, 'plotstyle', 'polar', 'networknames', ntmaps.metadata_table.target, 'colors', colors, 'nofigure', 'dofixrange', dofixrange);

end
end

end

else
if isempty(dofixrange)

[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');

else % we have fixed range

[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);

end
end
end % switch similarity metric

else
[stats, hh, hhfill, table_group, multcomp_group] = image_similarity_plot(fmri_data_obj, 'mapset', ntmaps, similarity_metric, 'noplot');

switch similarity_metric

case 'cosine_similarity'

[stats, hh, hhfill] = image_similarity_plot(fmri_data_obj, 'mapset', ntmaps, similarity_metric, 'noplot');

case 'correlation'

[stats, hh, hhfill] = image_similarity_plot(fmri_data_obj, 'mapset', ntmaps, 'noplot');

end % switch similarity metric

end
end % if doplot

end % main function

Expand Down
Loading
Loading