Home > functions > internal > dsCollectVariedParams.m

dsCollectVariedParams

PURPOSE ^

COLLECTVARIEDPARAMS - Gathers info on parameters that have been varied in a batch

SYNOPSIS ^

function [param_mat,varied,param_cell] = dsCollectVariedParams(data, varargin)

DESCRIPTION ^

COLLECTVARIEDPARAMS - Gathers info on parameters that have been varied in a batch

 Usage: [deprecated?]
   [all_values,param_names,unique_values]=dsCollectVariedParams(data)

 Inputs:
   - data: DynaSim data structure

 Outputs:
   - all_values: [num_sets x num_params_varied], values used for each data set
   - param_names: list of names of varied parameters
   - unique_values: cell array of unique values used for each varied  parameter
 
 Author: Jason Sherfey, PhD <jssherfey@gmail.com>
 Copyright (C) 2016 Jason Sherfey, Boston University, USA

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [param_mat,varied,param_cell] = dsCollectVariedParams(data, varargin)
0002 %COLLECTVARIEDPARAMS - Gathers info on parameters that have been varied in a batch
0003 %
0004 % Usage: [deprecated?]
0005 %   [all_values,param_names,unique_values]=dsCollectVariedParams(data)
0006 %
0007 % Inputs:
0008 %   - data: DynaSim data structure
0009 %
0010 % Outputs:
0011 %   - all_values: [num_sets x num_params_varied], values used for each data set
0012 %   - param_names: list of names of varied parameters
0013 %   - unique_values: cell array of unique values used for each varied  parameter
0014 %
0015 % Author: Jason Sherfey, PhD <jssherfey@gmail.com>
0016 % Copyright (C) 2016 Jason Sherfey, Boston University, USA
0017 
0018 % Check inputs
0019 %% auto_gen_test_data_flag argin
0020 options = dsCheckOptions(varargin,{'auto_gen_test_data_flag',0,{0,1}},false);
0021 if options.auto_gen_test_data_flag
0022   varargs = varargin;
0023   varargs{find(strcmp(varargs, 'auto_gen_test_data_flag'))+1} = 0;
0024   varargs(end+1:end+2) = {'unit_test_flag',1};
0025   argin = [{data}, varargs]; % specific to this function
0026 end
0027 
0028 if ~isstruct(data)
0029   fprintf('input must be a structure...exiting dsCollectVariedParams.\n');
0030   return;
0031 end
0032 if ~isfield(data,'varied')
0033   fprintf('no varied info in data.\n');
0034   return;
0035 end
0036 
0037 % collect info on parameters varied
0038 varied=data(1).varied;
0039 num_varied=length(varied); % number of model components varied across simulations
0040 num_sims=length(data); % number of data sets (one per simulation)
0041 
0042 % collect info on parameters varied
0043 param_mat=zeros(num_sims,num_varied); % values for each simulation
0044 param_cell=cell(1,num_varied); % unique values for each parameter
0045 
0046 % loop over varied components and collect values
0047 for j=1:num_varied
0048   if isnumeric(data(1).(varied{j}))
0049     param_mat(:,j)=[data.(varied{j})]; % values for each simulation
0050     param_cell{j}=unique([data.(varied{j})]); % unique values for each parameter
0051   else
0052     % TODO: handle sims varying non-numeric model components
0053     % (eg, mechanisms) (also in dsPlotFR and dsSelect)
0054   end
0055 end
0056 
0057 %% auto_gen_test_data_flag argout
0058 if options.auto_gen_test_data_flag
0059   argout = {param_mat, varied, param_cell}; % specific to this function
0060   
0061   dsUnitSaveAutoGenTestData(argin, argout);
0062 end

Generated on Tue 12-Dec-2017 11:32:10 by m2html © 2005