Home > database > ensemble_processStims.m

ensemble_processStims

PURPOSE ^

Wrapper script that applies a given function to a given set of stims.

SYNOPSIS ^

function outData = ensemble_processStims(inData,params)

DESCRIPTION ^

 Wrapper script that applies a given function to a given set of stims.

 This is a general wrapper script that cycles through all 
 the stims that are passed in the
 stimulus_metadata structure. Processes to be run on the stims are
 passed in as strings that specify function handles.
 parameters such as stimulus_id,artist,song_name,location are
 automatically passed to the child function.

 July 24, 2007 - Stefan Tomic

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function outData = ensemble_processStims(inData,params)
0002 % Wrapper script that applies a given function to a given set of stims.
0003 %
0004 % This is a general wrapper script that cycles through all
0005 % the stims that are passed in the
0006 % stimulus_metadata structure. Processes to be run on the stims are
0007 % passed in as strings that specify function handles.
0008 % parameters such as stimulus_id,artist,song_name,location are
0009 % automatically passed to the child function.
0010 %
0011 % July 24, 2007 - Stefan Tomic
0012 
0013 
0014 %placing inData into a cell. This facilitates the following
0015 %analysis search, which currently is not necessary, but will be
0016 %useful if this function later supports other input data structures
0017 %(e.g. stimulus_x_attribute_metadata)
0018 if(~iscell(inData))
0019   inData = {inData};
0020 end
0021 
0022 clear searchCrit;
0023 searchCrit.type = 'stimulus_metadata';
0024 findIdx = ensemble_find_analysis_struct(inData,searchCrit);
0025 stimMetaData = inData{findIdx};
0026 stimMetaDataCols = set_var_col_const(stimMetaData.vars);
0027 
0028 if(isfield(params,'filt'))
0029   stimMetaData = ensemble_filter(stimMetaData,params.filt);
0030 end
0031 
0032 nStims = length(stimMetaData.data{stimMetaDataCols.stimulus_id});
0033 
0034 if(~isfield(params,'startStim'))
0035   params.startStim = 1;
0036 end
0037 
0038 for iStim = params.startStim:nStims
0039 
0040   funcParams = params.funcParams;
0041   
0042   thisStimID = ...
0043       stimMetaData.data{stimMetaDataCols.stimulus_id}(iStim);
0044   funcParams.stimulus_id= thisStimID;
0045   fprintf('Processing Stim %d, ID %d\n',iStim,thisStimID);
0046   
0047   funcParams.artist = stimMetaData.data{stimMetaDataCols.artist}{iStim};
0048   funcParams.song_name = stimMetaData.data{stimMetaDataCols.name}{iStim};
0049   funcParams.location = stimMetaData.data{stimMetaDataCols.location}{iStim};
0050   
0051   funcH = str2func(params.funcName);
0052   
0053   outData{iStim} = funcH(inData,funcParams);
0054     
0055 end

Generated on Sun 19-May-2019 04:00:51 by m2html © 2003