slidingStat.m 897 B

12345678910111213141516171819202122232425262728293031323334
  1. function [val, valci, pval, cx]=slidingStat(func, stim, nostim, varargin)
  2. % [auc]=slidingROC(stim, nostim, wndw, step)
  3. % takes 2 matrices , stim & nostim, of equal number of columns.
  4. % uses window and step to generate two distributions that are compared
  5. % using ROC analysis (see dprime.m)
  6. % returns a vector whose length is the column width of stim
  7. % # of columns must be equal
  8. if size(stim,2) ~= size(nostim,2)
  9. error('must be equal # of columns')
  10. end
  11. wndw=0;
  12. pairs={'wndw', 3;...
  13. 'step_z', 1;...
  14. };
  15. parseargs(varargin,pairs,{},1);
  16. cx=1:step_z:(size(stim,2)-wndw+1);
  17. val=zeros(length(cx),1);
  18. pval=val+1;
  19. valci=[val val];
  20. for k = 1:length(cx)
  21. t_stim=sum(stim(:,cx(k):cx(k)+wndw-1),2);
  22. t_nostim=sum(nostim(:,cx(k):cx(k)+wndw-1),2);
  23. t_stim=t_stim(~isnan(t_stim));
  24. t_nostim=t_nostim(~isnan(t_nostim));
  25. [val(k),pval(k),valci(k,:)]=feval(func,t_stim, t_nostim);
  26. end