sortBlck.m 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. function [outDev,outStd,nDevAcc,nStdAcc] = sortBlck(inData,seqAcc,nTrialsAcc,AfrqI,BfrqI,runType)
  2. %SORTBLCK Divides blocks into deviant and standard responses
  3. % Detailed explanation goes here
  4. % define some variables
  5. pSmpl = size(inData,1);
  6. nTrials = size(inData,2);
  7. nBlcks = size(inData,3);
  8. nFiles = size(inData,4);
  9. nFilt = size(inData,5);
  10. % apply sequence on each block
  11. nDevAcc = zeros(nBlcks,nFiles); % preallocate
  12. nStdAcc = zeros(nBlcks,nFiles); % preallocate
  13. outDev = zeros(pSmpl,nTrials,nBlcks,nFiles,nFilt); % preallocate
  14. outStd = zeros(pSmpl,nTrials,nBlcks,nFiles,nFilt); % preallocate
  15. for f = 1:nFiles
  16. for b = 1:nBlcks
  17. % create sequences
  18. switch runType
  19. case {1,2}
  20. seqDev = logical(seqAcc(1:nTrialsAcc(b,f),b,f));
  21. seqStd = ~seqAcc(1:nTrialsAcc(b,f),b,f);
  22. case 3
  23. seqDev = seqAcc(1:nTrialsAcc(b,f),b,f)==AfrqI;
  24. seqStd = seqAcc(1:nTrialsAcc(b,f),b,f)==BfrqI;
  25. end
  26. nDevAcc(b,f) = sum(seqDev);
  27. nStdAcc(b,f) = sum(seqStd);
  28. % apply sequences on data
  29. outDev(:,1:nDevAcc(b,f),b,f,:) = inData(:,seqDev,b,f,:);
  30. outStd(:,1:nStdAcc(b,f),b,f,:) = inData(:,seqStd,b,f,:);
  31. end
  32. end
  33. end