Home > database > make_exp_sublist.m

make_exp_sublist

PURPOSE ^

Generates a list of unique subject ids for a given experiment.

SYNOPSIS ^

function sublist = make_exp_sublist(expname,varargin)

DESCRIPTION ^

 Generates a list of unique subject ids for a given experiment.
 sublist = make_exp_sublist(expname,varargin);

 Generates a list of all unique subject IDs contained in the repsonse table of
 the experiment specified in expname.

  'conn_id' - database connection ID to use during the query
 
 Optional arguments:
  'exclude_subs' - list of subjects to remove from the list

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function sublist = make_exp_sublist(expname,varargin)
0002 % Generates a list of unique subject ids for a given experiment.
0003 % sublist = make_exp_sublist(expname,varargin);
0004 %
0005 % Generates a list of all unique subject IDs contained in the repsonse table of
0006 % the experiment specified in expname.
0007 %
0008 %  'conn_id' - database connection ID to use during the query
0009 %
0010 % Optional arguments:
0011 %  'exclude_subs' - list of subjects to remove from the list
0012 
0013 % 06/15/10 PJ - sanitized mysql_make_conn
0014 
0015 conn_id = [];
0016 exclude_subs = {};
0017 
0018 % Parse the input arguments
0019 narg = length(varargin);
0020 for iarg = 1:2:narg
0021 
0022   switch varargin{iarg}
0023     case {'exclude_subs'}
0024       exclude_subs = check_cell(varargin{iarg+1});
0025          
0026     case 'conn_id'
0027       conn_id = varargin{iarg+1};
0028       
0029     otherwise
0030       fprintf('make_exp_sublist: Unknown parameter: %s\', varargin{iarg});
0031   end % switch
0032 end % iarg
0033 
0034 if ~exist('conn_id','var') || isempty(conn_id)
0035   error('%s: Do not have a valid connection ID', mfilename);
0036 end
0037 
0038 % Get the experiment info
0039 expinfo = mysql_get_expinfo(expname,'','',conn_id);
0040 
0041 sublist = expinfo.subs.ids;
0042   
0043 % Remove subjects on exclusion list
0044 if ~isempty(exclude_subs)
0045   [sublist] = setdiff(sublist,exclude_subs);
0046   sublist = sublist';
0047 end
0048 
0049 % Close the connection if necessary
0050 if ~conn_id
0051   mysql(conn_id,'close')
0052 end
0053 
0054 end
0055 
0056 function var = check_cell(var)
0057   if ~iscell(var)
0058     var = {var};
0059   end
0060 end

Generated on Wed 20-Mar-2019 04:00:51 by m2html © 2003