12345678910111213141516171819202122232425262728293031323334 |
- function [outDev,outStd,nTrialsSub] = subsample(inDev,inStd,seqAcc,nTrialsAcc)
- %SUBSAMPLE Extracts deviants after standards and standards before deviants
- % Detailed explanation goes here
- % define some variables
- pSmpl = size(inDev,1);
- nTrials = size(inDev,2)*0.2;
- nBlcks = size(inDev,3);
- nFiles = size(inDev,4);
- nFilt = size(inDev,5);
- % perform the subsampling
- nTrialsSub = zeros(nBlcks,nFiles); % preallocate
- outDev = zeros(pSmpl,nTrials,nBlcks,nFiles,nFilt); % preallocate
- outStd = zeros(pSmpl,nTrials,nBlcks,nFiles,nFilt); % preallocate
- for f = 1:nFiles
- for b = 1:nBlcks
- % create sequences
- seqDev = logical(seqAcc(1:nTrialsAcc(b,f),b,f));
- seqStd = ~seqAcc(1:nTrialsAcc(b,f),b,f);
-
- % shift dev and std sequence by one point and index into it with original std and dev sequence to obtain stds before devs and devs after stds
- seqDev_as = logical([zeros(1,1);seqStd(1:nTrialsAcc(b,f)-1)]); % shift original std sequences by 1 point (backwards)
- seqDev_as = seqDev_as(seqDev); % index into shifted standard sequences with original dev sequences to obtain dev after stds
- seqStd_bd = logical([seqDev(2:nTrialsAcc(b,f));zeros(1,1)]); % shift original dev sequences by 1 point (forwards)
- seqStd_bd = seqStd_bd(seqStd); % index into shifted deviant sequences with original std sequences to obtain stds before devs
- nTrialsSub(b,f) = sum(seqStd_bd);
- % apply newly generated sequences on dev and std datasets
- outDev(:,1:nTrialsSub(b,f),b,f,:) = inDev(:,seqDev_as,b,f,:);
- outStd(:,1:nTrialsSub(b,f),b,f,:) = inStd(:,seqStd_bd,b,f,:);
- end
- end
- end
|