Skip to content

Elements: Unique Trial Numbers

czuba edited this page Mar 9, 2020 · 1 revision

From: pldapsDefaultTrial.m > trialPrepare

%%% START OF TRIAL TIMING %%
%-------------------------------------------------------------------------%
% record start of trial in Datapixx, PLDAPS & Plexon
% each device has a separate clock

% At the beginning of each trial, strobe a unique number to plexon
% through the Datapixx to identify each trial. Often the Stimulus display
% will be running for many trials before the recording begins so this lets
% the plexon rig sync up its first trial with whatever trial number is on
% for stimulus display.
% SYNC clocks

% Construct a unique trial number based on:
%   6 element clock time: [year, month, day, 24hour, minute, second]
unique_number = fix(clock); 
% 	substitute year with trial number (i.e. something actually relevant on the scale of an experimental session)
unique_number(1) = p.trial.pldaps.iTrial; 
%   shift unique numbers into the upper half of our 15-bit strobed word range
unique_number = unique_number + 2^14;
%  ...leaving the lower 16,383 values for easily identifiable event values (p.trial.event).

if p.trial.datapixx.use
    % Strobe unique_number via datapixx
    for i = 1:numel(unique_number)
        p.trial.datapixx.unique_number_time(i,:) = pds.datapixx.strobe(unique_number(i));
    end
end
p.trial.unique_number = unique_number;    % trial identifier
Clone this wiki locally