2.3.4 getTrials() - shunnnli/NeuroDAP GitHub Wiki
Overview
In some task, different behavior events will together comprises the start of a trial. For example, in random delivery of water/airpuff/tone/stim, each trial start is denoted by delivery of either of these events. Thus, this function temporally aligned these independent events, calculate the difference between them, and return the sample index indicating the start of each trial. The result will be used for generating trial table in getTrialTable().
Inputs and options
Required inputs
varargin: variable number of inputs. Input any events that will be the start of a trial.
Options
threshold: double, default is 2.5; determines shortest interval (in seconds) between two events to be considered as separate trial start.behaviorFs: double, default is 10000; determines the sampling frequency of the behavior acquisition system.
Outputs
allTrials: double, the sample at which each trial occurs.pairIdx: double, index where the function find two events closely occurs below the setthresholdand is considered as one trial. For example, in my task, stimulation and tone can occur simultaneously. Thus the index of these trials will be stored here.
Examples
toneON = [1171745 15342888 16258146 17928434 18198893 18713516 21151374];
optoCue = [1511732 1654337 3528355 5253493 10418538 10596074 15920237 19686140 21907126 23356956 25503894 25901813 27867487 29975263];
allTrial = getTrials(toneON, optoCue)