For the complete documentation index, see llms.txt. This page is also available as Markdown.

Running an Experiment in MATLAB

Using the Zapit API in MATLAB

The following example function presents 20 random stimuli using software timing.

function myStimPresenter
    
    % Get the API object from the base workspace
    hZP = zapit.utils.getObject;
    if isempty(hZP)
        return
    end

    if hZP.isReadyToStim == false
        fprintf('Zapit is not ready to stimulate.\n')
        return
    end

    % Present 20 random stimuli without waiting for a hardware trigger
    for ii = 1:20
        hZP.sendSamples('hardwareTriggered',false) % Starts right away
        pause(1) % Wait approx 1s 
        hZP.stopOptoStim
        pause(0.3) % Because of https://github.com/Zapit-Optostim/zapit/issues/102
    end

end

The following function presents 20 random stimuli using an external hardware trigger:

Last updated