Skip to content

Instantly share code, notes, and snippets.

@cafarm

cafarm/Pulse.m Secret

Last active April 5, 2019 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cafarm/0ad2661c46829cbc727fbdbf345d2a7c to your computer and use it in GitHub Desktop.
Save cafarm/0ad2661c46829cbc727fbdbf345d2a7c to your computer and use it in GitHub Desktop.
classdef Pulse < symphonyui.core.Protocol
properties
amp = 'Amp' % Output amplifier
preTime = 50 % Pulse leading duration (ms)
stimTime = 500 % Pulse duration (ms)
tailTime = 50 % Pulse trailing duration (ms)
pulseAmplitude = 100 % Pulse amplitude (mV)
numberOfAverages = 5 % Number of epochs
end
methods
function prepareRun(obj)
prepareRun@symphonyui.core.Protocol(obj);
device = obj.rig.getDevice(obj.amp);
obj.showFigure('symphonyui.builtin.figures.ResponseFigure', device);
obj.showFigure('symphonyui.builtin.figures.MeanResponseFigure', device);
end
function prepareEpoch(obj, epoch)
prepareEpoch@symphonyui.core.Protocol(obj, epoch);
gen = symphonyui.builtin.stimuli.PulseGenerator();
gen.preTime = obj.preTime;
gen.stimTime = obj.stimTime;
gen.tailTime = obj.tailTime;
gen.amplitude = obj.pulseAmplitude;
gen.mean = 0;
gen.sampleRate = obj.sampleRate;
gen.units = 'mV';
stimulus = gen.generate();
device = obj.rig.getDevice(obj.amp);
epoch.addStimulus(device, stimulus);
epoch.addResponse(device);
end
function tf = shouldContinuePreparingEpochs(obj)
tf = obj.numEpochsPrepared < obj.numberOfAverages;
end
function tf = shouldContinueRun(obj)
tf = obj.numEpochsCompleted < obj.numberOfAverages;
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment