extractdatapb.m 730 B

123456789101112131415161718192021222324
  1. function data=extractdatapb(data,Fs,t)
  2. % Extract segements of binned point process data between t(1) and t(2)
  3. % Usage: data=extractdatapb(data,Fs,t)
  4. %
  5. % Input:
  6. % data: binned point process data in the form samples x channels or single
  7. % vector
  8. % Fs: sampling frequency
  9. % t : time as a 2d vector [t(1) t(2)]
  10. % Note that sampling frequency and t have to be in consistent units
  11. % Output:
  12. % data: data between t(1) and t(2)
  13. if nargin < 3;
  14. error('need all three arguments');
  15. end;
  16. if t(1) < 0 || t(2)<=t(1);
  17. error('times cannot be negative and t(2) has to be greater than t(1)');
  18. end;
  19. data=change_row_to_column(data);
  20. N=size(data,1);
  21. tt=(0:N-1)/Fs;
  22. indx=find(tt>=t(1) & tt<=t(2));
  23. data=data(indx,:);