Functions | Variables

unlock/analysis/andres/Code/trimEpochs.m File Reference

Functions

else if unlockInfo epoch
fromEnd If epochs extracted
from decodedTrial 
trigger (at end of trial) and%moving backwards(trigger is at end of trial but last samples might be from next epoch) trigPos
else If epochs extracted from first sample (end of trial spills over next trial, first samples might be from previous epoch) trimStart
id dcdTgt ()
last trigger from leftOver data if length (trigPos) >
end trimDcdTgt val (end)
 tmpDcdTgt (end,:)

Variables

 function [trimmedEpochs, trimDcdTgt, epochDcdTgt, unlockInfo]
 trimStart = round(unlockInfo.epoch.startGap*unlockInfo.main.Fs)
 trimEnd = trigPos - round(unlockInfo.epoch.endGap*unlockInfo.main.Fs)
 trimDcdTgt = dcdTgt
trimDcdTgt val = circshift(dcdTgt.val,-ones(1,unlockInfo.epoch.nEpochs))
shifting to previous epoch the
trigger values Last decoder
trigger 
trigPos = unique(dcdTgt.leftOvers.dcdTgt)
else lastTrig = trigPos(1)
end end Trim epochs trimmedEpochs = unlockEpochs(trimStart:trimEnd,:,:,:)
 tmpDcdTgt = epochDcdTgt(trimStart:trimEnd,:)
 epochDcdTgt = tmpDcdTgt
Changing values in info
structure unlockInfo epoch 
trialSampLen = trimEnd - trimStart + 1
unlockInfo epoch changedTrialLen = true

Function Documentation

id dcdTgt (  )  [virtual]
last trigger from leftOver data if length ( trigPos   ) 
else If epochs extracted from first sample ( end of trial spills over next  trial,
first samples might be from previous  epoch 
)
tmpDcdTgt ( end  ,
 
)
else if unlockInfo epoch fromEnd If epochs extracted from decodedTrial trigger ( at end of  trial  ) 
end trimDcdTgt val ( end   ) 

Variable Documentation

epochDcdTgt = tmpDcdTgt
Initial value:
 trimEpochs(unlockEpochs,unlockInfo,epochDcdTgt,dcdTgt) 
% function [trimmedEpochs,trimDcdTgt,epochDcdTgt,unlockInfo] = trimEpochs(unlockEpochs,unlockInfo,epochDcdTgt,dcdTgt)
%
% Trims the epochs to include only data from that trial. Useful when not
% sure boundaries of epoch are from same trial or from previous or next
% one. 
%
% boundaries from both sides are removed based on location of the decoded
% trial end trigger and epoch extraction method (fromEnd or not) and location
% 
%
%
% Andres. v1.1      02 Jan 2014
% Last modified:    02 Jan 2014

%% Getting trimming boundaries
if unlockInfo.main.triggeredData
    trigPos = unique(dcdTgt.samp)
else lastTrig = trigPos(1)
tmpDcdTgt = epochDcdTgt(trimStart:trimEnd,:)
Changing values in info structure unlockInfo epoch trialSampLen = trimEnd - trimStart + 1
shifting to previous epoch the trigger values Last decoder trigger trigPos = unique(dcdTgt.leftOvers.dcdTgt)
trimDcdTgt = dcdTgt
trimEnd = trigPos - round(unlockInfo.epoch.endGap*unlockInfo.main.Fs)
end end Trim epochs trimmedEpochs = unlockEpochs(trimStart:trimEnd,:,:,:)
trimDcdTgt val = circshift(dcdTgt.val,-ones(1,unlockInfo.epoch.nEpochs))