Home > data-vis > visualize_basic_stats_per_object.m

visualize_basic_stats_per_object

PURPOSE ^

subexpIDs - array of experiments IDs or subject IDs

SYNOPSIS ^

function visualize_basic_stats_per_object(subexpIDs, varname, savefilename, args)

DESCRIPTION ^

 subexpIDs - array of experiments IDs or subject IDs
 varname - string indicating
 args.colormap - type 'doc colormap' for more information, here are
 recommended options
   'hot'
   'gray'
   'jet'

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function visualize_basic_stats_per_object(subexpIDs, varname, savefilename, args)
0002 % subexpIDs - array of experiments IDs or subject IDs
0003 % varname - string indicating
0004 % args.colormap - type 'doc colormap' for more information, here are
0005 % recommended options
0006 %   'hot'
0007 %   'gray'
0008 %   'jet'
0009 
0010 if ~exist('args', 'var') || isempty(args)
0011     args = struct();
0012 end
0013 
0014 if ~isfield(args, 'colormap') || isempty(args.colormap)
0015     args.colormap = 'gray';
0016 end
0017 
0018 if ~isfield(args, 'categories') || isempty(args.categories)
0019     args.categories = 1:4;
0020 end
0021 
0022 [subs, parttable] = cIDs(subexpIDs);
0023 
0024 if ismember(12, parttable(:,2))
0025     args.categories = 1:25;
0026 end
0027 
0028 args.persubject = 1;
0029 ex = extract_multi_measures(varname, subs, '', args);
0030 
0031 measures = {'prop', 'mean_dur', 'freq'};
0032 lenargs = length(args.categories);
0033 index_on = 4:lenargs:lenargs*numel(measures);
0034 index_off = index_on + lenargs - 1;
0035 if ~isempty(ex)
0036     for m = 1:numel(measures)
0037         data = ex(:,(index_on(m):index_off(m)));
0038         subs = ex(:,1);
0039         rankeddata = sort(vertcat(data(:)));
0040         rankeddata(isnan(rankeddata)) = [];
0041         val_min = min(rankeddata);
0042         rankeddata(rankeddata==val_min) = [];
0043         idx_90 = floor(.9 * length(rankeddata));
0044         val_max = rankeddata(idx_90);
0045         
0046         if length(args.categories) > 5
0047             f = figure('position', [100 100 1280 720]);
0048         else
0049             f = figure('position', [100 100 320 1280]);
0050         end
0051         colormap(args.colormap)
0052         a = axes;
0053         
0054         im = imagesc(data, [val_min, val_max]);
0055         cb = colorbar;
0056         title(strrep(measures{m},'_','\_'));
0057         a.YTick = 1:length(subs);
0058         a.YTickLabel = subs;
0059         
0060         a.XTick = 1:length(args.categories);
0061         a.XTickLabel = args.categories;
0062         
0063         if exist('savefilename', 'var') && ~isempty(savefilename)
0064             export_fig(f, [savefilename '_' measures{m} '_unsorted.png'], '-png');
0065             headers = 'subid';
0066             for l = 1:size(data,2)
0067                 headers = cat(2, headers, sprintf(',cat-%d', l));
0068             end
0069             write2csv([subs data], [savefilename '_', measures{m} '_unsorted.csv'], headers);
0070         end
0071         
0072         [data_sorted,I] = sort(data, 2, 'descend');
0073         im.CData = data_sorted;
0074         for r = 1:size(data_sorted,1)
0075             for c = 1:size(data_sorted,2)
0076                 text(c,r,sprintf('%d',I(r,c)), 'color', 'r');
0077             end
0078         end
0079         
0080         if exist('savefilename', 'var') && ~isempty(savefilename)
0081             export_fig(f, [savefilename '_' measures{m} '_sorted.png'], '-png');
0082             close(f);
0083         end
0084     end
0085 end
0086 end
0087

Generated on Tue 23-May-2017 20:00:55 by m2html © 2005