Diff for "ScannerSyncMatlab" - MRC CBU Imaging Wiki
location: Diff for "ScannerSyncMatlab"
Differences between revisions 1 and 3 (spanning 2 versions)
Revision 1 as of 2009-02-25 09:58:32
Size: 1976
Editor: RhodriCusack
Comment:
Revision 3 as of 2009-02-25 09:59:01
Size: 1972
Editor: RhodriCusack
Comment:
Deletions are marked like this. Additions are marked like this.
Line 7: Line 7:
{{ {{{
Line 15: Line 15:
invoke(objSS,'SetMSPerSample',2); %Set StartExperiment routines’ sampling
}}
invoke(objSS,'SetMSPerSample',2); %Set StartExperiment routines’ sampling
}}}

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).

%% SCANNERSYNC
TR=1000; % TR in ms
numdummies=8; 

% 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);

% 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

end; }}

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

}}

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

  • picstarttime=invoke(objSS,'SSGetTimer'); measuredTR=invoke(objSS,'GetMeasuredTR');

% ...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)