ScannerSynch

ScannerSynch provides an interface for National Instruments PCI 6503 card used to capture all pulses (scanner synch pulse and button pulses from both the Lumitouch and the NATA boxes alike) when using MATLAB.

For more information, type in MATLAB

help ScannerSynchClass

:!: N.B.: National Instruments PCI 6503 card does not monitor pulses in the background, so you have to make sure that you wait for any pulse before it comes! :!:

Any problems, report them to Tibor Auer.

ScannerSynch is available on all relevant PCs (StimPCs, 'clone' PC). You can check out a local version for testing from our github repo.

Example script is also available here.

Initialise

  • Default. Use only if device (scanner, pulse emulator) is connected (only in StimPCs and 'clone' PC)!
    SSO = ScannerSynchClass;
  • Emulations:
    SSO = ScannerSynchClass(1);   % emulate scanner synch pulse
    SSO = ScannerSynchClass(0,1); % emulate button box
    SSO = ScannerSynchClass(1,1); % emulate scanner synch pulse and button box

Close

ScannerSynch has a destructor, which is automatically triggered if the object is deleted (e.g. clear, returning function). If you use a script, however, it does not perform any auto-clear, so you have to destroy the object manually:

Capture scanner synch pulse

  • Simple case
    SSO.SetSynchReadoutTime(0.5); % make sure that you do not detect the same pule twice
    SSO.TR = 2;                   % allows detecting missing pulses
    while SSO.SynchCount < 10     % polls 10 pulses
        SSO.WaitForSynch;
        fprintf('Pulse %d: %2.3f. Measured TR = %2.3fs\n',...
            SSO.SynchCount,...
            SSO.TimeOfLastPulse,...
            SSO.MeasuredTR);
    end
  • Chance for missing pulse
    SSO.SetSynchReadoutTime(0.5);  % make sure that you do not detect the same pule twice
    SSO.TR = 2;                    % allows detecting missing pulses
    while SSO.SynchCount < 10      % until 10 pulses
        WaitSecs(Randi(100)/1000); % in every 0-100 ms ...
        if SSO.CheckSynch(0.01)    % ... waits for 10 ms for a pulse
            fprintf('Pulse %d: %2.3f. Measured TR = %2.3fs. %d synch pulses has/have been missed\n',...
                SSO.SynchCount,...
                SSO.TimeOfLastPulse,...
                SSO.MeasuredTR,...
                SSO.MissedSynch);
        end
    end

Capture button presses

  • The interface can monitor both the Lumitouch and the NATA response boxes (even when used together!).
    • Lumitouch button presses return 1-4.
    • NATA button presses return 5-14
  • SSO.SetButtonReadoutTime(0.5);      % block individual buttons for 0.5s after button press so we will not detect the same button press twice
    % SSO.SetButtonBoxReadoutTime(0.5); % block the whole buttonbox for 0.5s after button press 
    % SSO.Keys = {'f1','f2','f3','f4'}; % emulation Buttons #1-#4 with F1-F4
    n = 0;
    % SSO.BBoxTimeout = 1.5;            % Wait for button press for 1.5s
    % SSO.BBoxTimeout = -1.5;           % Wait for button press for 1.5s even in case of response
    SSO.ResetClock;
    while n ~= 10                       % polls 10 button presses
        SSO.WaitForButtonPress;         % Wait for any button to be pressed
        % SSO.WaitForButtonRelease;       % Wait for any button to be released
        % SSO.WaitForButtonPress([],5); % Wait for Button #5
        % SSO.WaitForButtonPress(2);    % Wait for any button for 2s (overrides SSO.BBoxTimeout only for this event)
        % SSO.WaitForButtonPress(-2);   % Wait for any (number of) button(s) for 2s even in case of response (overrides SSO.BBoxTimeout only for this event)
        % SSO.WaitForButtonPress(2,5);  % Wait for Button #5 for 2s (overrides SSO.BBoxTimeout only for this event)
        % SSO.WaitForButtonPress(-2,5); % Wait for (any number of presses of) Button #5 for 2s even in case of response (overrides SSO.BBoxTimeout only for this event)
        n = n + 1;
        for b = 1:numel(SSO.ButtonPresses)
            fprintf('#%d Button %d ',b,SSO.ButtonPresses(b));
            fprintf('pressed at %2.3fs\n',SSO.TimeOfButtonPresses(b));
        end
        fprintf('Last: Button %d ',SSO.LastButtonPress);
        fprintf('pressed at %2.3fs\n\n',SSO.TimeOfLastButtonPress);
    end

Top