sortBlck.m 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. function [outDev,outStd,nDevAcc,nStdAcc] = sortBlck(inData,seqAcc,nTrialsAcc,AfrqI,BfrqI,daSeI,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 daSeI
  19. case 1
  20. seqDev = logical(seqAcc(1:nTrialsAcc(b,f),b,f));
  21. seqStd = ~seqAcc(1:nTrialsAcc(b,f),b,f);
  22. case 2
  23. switch runType
  24. case {1,2}
  25. seqDev = logical(seqAcc(1:nTrialsAcc(b,f),b,f));
  26. seqStd = ~seqAcc(1:nTrialsAcc(b,f),b,f);
  27. case 3
  28. seqDev = seqAcc(1:nTrialsAcc(b,f),b,f)==AfrqI;
  29. seqStd = seqAcc(1:nTrialsAcc(b,f),b,f)==BfrqI;
  30. end
  31. end
  32. nDevAcc(b,f) = sum(seqDev);
  33. nStdAcc(b,f) = sum(seqStd);
  34. % apply sequences on data
  35. outDev(:,1:nDevAcc(b,f),b,f,:) = inData(:,seqDev,b,f,:);
  36. outStd(:,1:nStdAcc(b,f),b,f,:) = inData(:,seqStd,b,f,:);
  37. end
  38. end
  39. end