function l = ctxgroup(data) % function l = ctxgroup(data) % % data The incoming data should be a list generated by ctx2mat (or in the % same format). % % This function does some very basic processing of trial information. % Only "valid/successful" trials are included in the output. % The output is a list with the following format: % % l{i}{j} == data for condition i, (successful) presentation j % % The contents of l{i}{j} are the same as the incoming data. % This code relies on the Cortex header containing the proper flag % as to whether the trial was successful or not. This must be explicitly % done during the running of a Cortex program. % % Version 1.0 % For additional code, updated versions, questions or comments, please refer % to the Active Perception Lab home page % http://www.cnbc.cmu.edu/~tai/lab.html % Copyright 1998-1999 % Rick Romero % rickr+@cmu.edu % Permission to use and modify is granted, % but not to redistribute original or modified code. len = length(data); maxCnd = 0; trialCounts = []; for i=1:len header = data{i}{1}; if (header(12) == 0) % successful trial, get the info cndNum = header(1) + 1; if (length(trialCounts) < cndNum) trialCounts(cndNum) = 0; end trialCounts(cndNum) = trialCounts(cndNum) + 1; maxCnd = max([maxCnd; cndNum]); end end l = cell(maxCnd, 1); for i=1:len header = data{i}{1}; if (header(12) == 0) cndNum = header(1) + 1; if (isempty(l{cndNum})) l{cndNum} = cell(trialCounts(cndNum),1); trialCounts(cndNum) = 0; end trialCounts(cndNum) = trialCounts(cndNum) + 1; l{cndNum}{trialCounts(cndNum)} = data{i}; end end