function [Behavior]=analyzeRT(RTc,RTe)
%
% analyzeRT :: Function that computes statistics of reaction time as a
% function of motion coherence for correct and error trials in the
% reaction time task
%
%% Output variable
% Behavior :: 2D matrix where rows correspond to coherence levels and the six columns
% correspond as follows: First column -> num(correct trials); Second column -> num(error trials);
% Third column -> Correct trial reaction time mean; Fourth column -> Correct trial reaction time SEM;
% Fifth column -> Error trial reaction time mean; Sixth column -> Error trial reaction time SEM
%
%% Reference
% Grossberg, S. and Pilly, P. K. (2008). Temporal dyanamics of decision-making during motion perception in the visual cortex. Vision Research, 48(12), 1345-1373.
%
%% Author
% Praveen K. Pilly (advaitp@gmail.com)
%
%% License policy
% Written by Praveen K. Pilly, Department of Cognitive and Neural Systems, Boston University
% Copyright 2009, Trustees of Boston University
%
% Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted
% without fee, provided that the above copyright notice and this permission notice appear in all copies, derivative works and
% associated documentation, and that neither the name of Boston University nor that of the author(s) be used in advertising or
% publicity pertaining to the distribution or sale of the software without specific, prior written permission. Neither Boston
% University nor its agents make any representations about the suitability of this software for any purpose. It is provided "as
% is" without warranty of any kind, either express or implied. Neither Boston University nor the author indemnify any
% infringement of copyright, patent, trademark, or trade secret resulting from the use, modification, distribution or sale of
% this software.
%
%% Last modified
% June 25, 2009
%%
cohL=size(RTc,2); % number of coherence levels
% Initialize
Behavior=zeros(cohL,6);
% Main loop
for coh=1:cohL
nzRTc=nonzeros(RTc(:,coh));
nzRTe=nonzeros(RTe(:,coh));
Behavior(coh,3)=mean(nzRTc);
Behavior(coh,5)=mean(nzRTe);
Behavior(coh,1)=size(nzRTc,1);
Behavior(coh,2)=size(nzRTe,1);
Behavior(coh,4)=std(nzRTc)/sqrt(size(nzRTc,1));
Behavior(coh,6)=std(nzRTe)/sqrt(size(nzRTe,1));
end
return