Create a gist now

Instantly share code, notes, and snippets.

@cafarm /SingleSpot.m Secret
Last active Jun 1, 2016

Embed
What would you like to do?
classdef SingleSpot < io.github.stage_vss.protocols.StageProtocol
properties
amp = 'Amp' % Output amplifier
preTime = 500 % Spot leading duration (ms)
stimTime = 1000 % Spot duration (ms)
tailTime = 500 % Spot trailing duration (ms)
spotIntensity = 1.0 % Spot light intensity (0-1)
spotDiameter = 300 % Spot diameter size (pixels)
backgroundIntensity = 0.5 % Background light intensity (0-1)
centerOffset = [0, 0] % Spot [x, y] center offset (pixels)
numberOfAverages = uint16(5) % Number of epochs
end
methods
function prepareRun(obj)
prepareRun@io.github.stage_vss.protocols.StageProtocol(obj);
device = obj.rig.getDevice(obj.amp);
obj.showFigure('symphonyui.builtin.figures.ResponseFigure', device);
obj.showFigure('symphonyui.builtin.figures.MeanResponseFigure', device);
end
function p = createPresentation(obj)
canvasSize = obj.rig.getDevice('Stage').getCanvasSize();
p = stage.core.Presentation((obj.preTime + obj.stimTime + obj.tailTime) * 1e-3);
p.setBackgroundColor(obj.backgroundIntensity);
spot = stage.builtin.stimuli.Ellipse();
spot.color = obj.spotIntensity;
spot.radiusX = obj.spotDiameter/2;
spot.radiusY = obj.spotDiameter/2;
spot.position = canvasSize/2 + obj.centerOffset;
p.addStimulus(spot);
spotVisible = stage.builtin.controllers.PropertyController(spot, 'visible', ...
@(state)state.time >= obj.preTime * 1e-3 && state.time < (obj.preTime + obj.stimTime) * 1e-3);
p.addController(spotVisible);
end
function prepareEpoch(obj, epoch)
prepareEpoch@io.github.stage_vss.protocols.StageProtocol(obj, epoch);
device = obj.rig.getDevice(obj.amp);
duration = (obj.preTime + obj.stimTime + obj.tailTime) / 1e3;
epoch.addDirectCurrentStimulus(device, device.background, duration, obj.sampleRate);
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