ScannerSyncMatlab - MRC CBU Imaging Wiki

Upload page content

You can upload content for the page named below. If you change the page name, you can also upload content for another page. If the page name is empty, we derive the page name from the file name.

File to load page content from
Page name
Comment
Type the odd characters out in each group: abz2a 125t7 HhHaHh year.s 5433r21 worl3d

Revision 2 as of 2009-02-25 09:58:44

location: ScannerSyncMatlab

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

}}