1234567891011121314151617181920212223242526272829303132333435 |
- function [avLCl] = countConS(dataIn,seq,nTrials)
- % IDENTIFY consecutive standard responses
- % This function identifies consecutive standard responses in the oddball
- % paradigm. The number of responses is defined by nConS
- % define some variables
- nBlcks = size(dataIn,3);
- nFiles = size(dataIn,4);
- avLCl = zeros(nBlcks,nFiles);
- for f = 1:nFiles
- for b = 1:nBlcks
- % create std sequences
- seqStd = ~seq(1:nTrials(b,f),b,f)';
- vecClI = double(seqStd);
- % count appearances of consecutive standards in each cluster (code from forum)
- B = vecClI;
- d2 = [true,diff(B)~=0];
- r = find(d2);
- B(~d2) = 1;
- B(d2) = [1,1-diff(r)];
- B(1) = 1;
- B = cumsum(B);
- % identify number and size of accepted clusters
- bCl = diff([0,vecClI,0]); % vector that marks borders of clusters
- sCl = find(bCl==1); % starting points of clusters
- eCl = find(bCl==-1)-1; % ending points of clusters
- lCl = eCl-sCl+1; % size of clusters
- % calculate average length of clusters
- avLCl(b,f) = mean(lCl);
- end
- end
|