Home > demos > demo_vis_hist.m

demo_vis_hist

PURPOSE ^

Outputs a histogram of durations for a particular cevent variable

SYNOPSIS ^

function demo_vis_hist(option)

DESCRIPTION ^

 Outputs a histogram of durations for a particular cevent variable

 Loops through subjects in 'subexpIDs' and loads data specified by 'varname'.
 Uses 'histc' function to bin the data according the user input 'edges'.
 The output will be saved in the input directory as a csv. Additionally,
 if 'flag_savefig' is set to 1, visual figures will also be saved for each
 subject in this same directory.

 subexpIDs : array of subject IDs or experiment IDs

 varname : string name of cevent variable

 edges : 1xN double array that specifies the bin edges.
 The upper bound is always Inf, meaning, 0:1:10 becomes [0:1:10 Inf]. This
 combines all durations that are greater than 10 into the last bin.
 
 directory : full or relative path to the directory where results are
 saved

 nametag : a short, unique string to help name the files

 flag_savefig : boolean indicating whether to save figures in addition to
 .csv. Setting this to 0 can speed up the runtime of this function, if you
 don't need the individual images.

 example results

 binedges    7002    7003
 0          6         29
 0.25        19         27
 0.5        11         23
 0.75         5         15
 1             5        5

 Note, first row means 0 to 0.25 and last row means 1 to Infinity.

 Output files
   1 .csv file containing all histogram data for all subjects.
   2 .jpg file with the full histogram for all subjects (normalized)
   3 folder containing .jpg files, one for each individual subject

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function demo_vis_hist(option)
0002 % Outputs a histogram of durations for a particular cevent variable
0003 %
0004 % Loops through subjects in 'subexpIDs' and loads data specified by 'varname'.
0005 % Uses 'histc' function to bin the data according the user input 'edges'.
0006 % The output will be saved in the input directory as a csv. Additionally,
0007 % if 'flag_savefig' is set to 1, visual figures will also be saved for each
0008 % subject in this same directory.
0009 %
0010 % subexpIDs : array of subject IDs or experiment IDs
0011 %
0012 % varname : string name of cevent variable
0013 %
0014 % edges : 1xN double array that specifies the bin edges.
0015 % The upper bound is always Inf, meaning, 0:1:10 becomes [0:1:10 Inf]. This
0016 % combines all durations that are greater than 10 into the last bin.
0017 %
0018 % directory : full or relative path to the directory where results are
0019 % saved
0020 %
0021 % nametag : a short, unique string to help name the files
0022 %
0023 % flag_savefig : boolean indicating whether to save figures in addition to
0024 % .csv. Setting this to 0 can speed up the runtime of this function, if you
0025 % don't need the individual images.
0026 %
0027 % example results
0028 %
0029 % binedges    7002    7003
0030 % 0          6         29
0031 % 0.25        19         27
0032 % 0.5        11         23
0033 % 0.75         5         15
0034 % 1             5        5
0035 %
0036 % Note, first row means 0 to 0.25 and last row means 1 to Infinity.
0037 %
0038 % Output files
0039 %   1 .csv file containing all histogram data for all subjects.
0040 %   2 .jpg file with the full histogram for all subjects (normalized)
0041 %   3 folder containing .jpg files, one for each individual subject
0042 
0043 switch option
0044     case 1
0045         % categorical data (cevent)
0046         subexpIDs = 72;
0047         varname = 'cevent_eye_roi_child';
0048         nametag = 'child_eye';
0049         directory = '/scratch/multimaster/demo_results/vis_hist/case1';
0050         edges = 0:.25:10;
0051         flag_savefig = 1;
0052         vis_hist(subexpIDs, varname, edges, directory, nametag, flag_savefig);
0053 
0054         
0055     case 2
0056         % continous data
0057         subexpIDs = 72;
0058         varname = 'cont_motion_pos-speed_right-hand_child';
0059         nametag = 'child_r_hand_speed';
0060         directory = '/scratch/multimaster/demo_results/vis_hist/case2';
0061         edges = 0:50:500;
0062         flag_savefig = 1;
0063         vis_hist(subexpIDs, varname, edges, directory, nametag, flag_savefig);  
0064 end

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