Skip to content
Snippets Groups Projects

Replace sendEvent.m

Merged Tobias Otto requested to merge klareacj-master-patch-20085 into master
1 file
+ 14
6
Compare changes
  • Side-by-side
  • Inline
+ 14
6
@@ -95,6 +95,8 @@ function [tme, decEvents] = sendEvent(stdEvents, extraEvents, camEvents)
% SETUP.events.setup = 'Deuteron'; (with the neural recording system in use)
% SETUP.events.lastPin = 1; (in order to accommodate to the Deuteron system)
% 12.04.2022, Aylin: - changed specification of ephys setup
% 02.05.2022, Aylin: - corrected sending of event codes for Intan system
% & Lukas
%% Init variables
global SETUP
@@ -102,7 +104,7 @@ global SETUP
if(nargin == 1)
extraEvents = 0;
camEvents = false;
elseif nargin == 2
elseif nargin==2
camEvents = false;
end
@@ -111,7 +113,7 @@ if(strcmpi(stdEvents, 'trlmtch'))
% Events 1 to 7 are defined standard events, events 8 to 15 are used for trial match
% Only if we have at least 4 bits available
stdEvents = randperm(8,1)+7;
binVec = rem(floor((stdEvents+extraEvents) ./ SETUP.events.powersOf2),2) & SETUP.events.pinsLen > 3;
binVec = rem(floor((stdEvents+extraEvents) ./ SETUP.events.powersOf2),2) & SETUP.events.pinsLen > 3;
elseif(strcmpi(stdEvents, 'reset'))
% make sure all pins are off before the trial starts
@@ -123,13 +125,14 @@ end
%% Set event
if strcmpi(SETUP.ephysSetup,'Deuteron') && ~strcmpi(stdEvents, 'itiOn')
% turn pin on + off for deuteron logger to detect rising edge
% turn pin on + off for deuteron to detect rising edge
if SETUP.events.lastPin == 4
bIO(SETUP.events.pins(mod(SETUP.events.lastPin,4) + 2),1);
else
bIO(SETUP.events.pins(SETUP.events.lastPin+1),1);
end
bIO(SETUP.events.pins(SETUP.events.lastPin),0);
% update which pin was modified last
if SETUP.events.lastPin == 4
SETUP.events.lastPin = mod(SETUP.events.lastPin,4) + 2;
@@ -138,11 +141,16 @@ if strcmpi(SETUP.ephysSetup,'Deuteron') && ~strcmpi(stdEvents, 'itiOn')
end
elseif strcmpi(SETUP.ephysSetup,'Deuteron') && strcmpi(stdEvents, 'itiOn')
bIO(SETUP.events.pins, binVec(1:length(SETUP.events.pins))); % same as previous event code architecture
bIO(SETUP.events.pins, binVec(1:length(SETUP.events.pins)));% same as previous event code architecture
SETUP.events.lastPin = 1;
else % for any system except deuteron, i.e. intan
% bIO(SETUP.events.pins, binVec(1:length(SETUP.events.pins)));% same as previous event code architecture - OLD
else % for any other ephys system, i.e. intan
bIO(SETUP.events.pins, binVec(1:length(SETUP.events.pins))); % same as previous event code architecture
% corrected for new Intan system:
pinsToChange = SETUP.events.pins(logical(binVec)); % which pins need to be turned on/off
bIO(pinsToChange,ones(1,length(pinsToChange))) % turn pins on
pause(0.002) % wait dur
bIO(pinsToChange,zeros(1,length(pinsToChange))) % turn pins off
end
%% generate the output
Loading