Diff for "ScannerSyncMatlab" - MRC CBU Imaging Wiki
location: Diff for "ScannerSyncMatlab"
Differences between revisions 3 and 4
Revision 3 as of 2009-02-25 09:59:01
Size: 1972
Editor: RhodriCusack
Revision 4 as of 2009-02-25 09:59:43
Size: 1982
Editor: RhodriCusack
Deletions are marked like this. Additions are marked like this.
Line 20: Line 20:
{{ {{{
Line 23: Line 23:
}} }}}
Line 26: Line 26:
{{ {{{
Line 34: Line 34:
}} }}}
Line 37: Line 37:
{{ {{{
Line 39: Line 39:
}} }}}
Line 42: Line 42:
{{ {{{
Line 48: Line 48:
}} }}}
Line 51: Line 51:
{{ {{{
Line 53: Line 53:
}} }}}

Using ScannerSync from Matlab

Make sure you have the ScannerSync control installed.

Somewhere near the top of your code, set up ScannerSync & initialise communication with the input-output board (will not work if you're using a machine without the board, e.g., not the mimic or stim delivery machines).

TR=1000; % TR in ms

% Create & initialise scanner sync object
objSS=actxserver('MRISync.ScannerSync');  %Create a scanner object
invoke(objSS,'Initialize','') %Initialise the Keithley board and object
invoke(objSS,'SetMSPerSample',2); %Set StartExperiment routines’ sampling 

Now, wait for first pulse from scanner. Also, tell ScannerSync the approximate TR.

% ScannerSync - waits for the first pulse, resets timer to 0, sets TR
invoke(objSS,'StartExperiment', double(TR));

Wait for dummies (one less as StartExperiment command above will already have heard a pulse)

for countdown=(numdummies-1):-1:1
    count_text=sprintf('%d', countdown);
  % uncomment the next two if you're using the PsychToolbox
%    DrawFormattedText(window, count_text, 'center', 'center', white);
%    Screen(window, 'Flip');
    invoke(objSS,'SynchroniseExperiment',1,0); %  1= force wait for actual pulse; 0=return this many ms after pulse

In your trial loop, you'll need to spend some of the time listening for pulses

    invoke(objSS,'CheckPulseSynchronyForTime', double(500)); % spend 500 ms listening for any pulses

You should dump out the timing of critical events and the measured TR


% ...add your own code to write these to your output file

Also, for some designs you may want to occasionally synchronise your trials to the scanner

    invoke(objSS,'SynchroniseExperiment',1,0); %  1= force wait for actual pulse; 0=return this many ms after pulse

CbuImaging: ScannerSyncMatlab (last edited 2015-08-28 14:58:08 by RussellThompson)