| Reference | Downloads | Github

Issue with globalClock timing and launchScan

Hi there,

I am creating an fMRI experiment where I want to present visual stimuli (15 conditions) in the scanner. I am having an issue with syncing the timing of my script with the scanner trigger. To test my paradigm I am using the ‘Test’ mode within the launchScan function, with the following MR settings:

#import function for launchScan
from psychopy.hardware.emulator import launchScan

#outline scanner settings for trigger; default sync key=5
MR_settings = {
    'TR': 1.45,     # duration (sec) per whole-brain volume
    'volumes': 385,    # number of whole-brain 3D volumes per scanning run
    'skip': 5 #number of volumes to skip at the beginning of the scan

I then launch my scan, after skipping the first 5 volumes, with the following syntax:

#launch scan
vol=launchScan(win,MR_settings,globalClock=globalClock,mode='Test',wait_msg='waiting for the scanner...')

duration = MR_settings['volumes'] * MR_settings['TR']

#start scan
while globalClock.getTime() < duration:
    allKeys = event.getKeys()
    for key in allKeys:
        if key == MR_settings['sync']:
            onset = globalClock.getTime()
            # code for paradigm and visual presentation of stimuli follows below here

However, when I test this my script skips the first condition (a fixation cross of 9 seconds; it now presents the cross for 1-2 seconds) and goes straight to my second condition (a visual presentation of an object). When looking at the log file which records the timing of the presentation of my fixation cross it reads that it is first presented between 14-16 seconds into the experiment.

I’m not sure why this is occurring? From reading the documentation of the launchScan function it should reset my globalClock to 0 when the scan is launched on the first trigger (after skipping the first 5 volumes as defined by ‘skip’ in my MR settings), however, I have a feeling that it is actually starting the timing from the first volume (which should be discarded), and so it only presents the fixation cross for 1-2 seconds as the script ‘thinks’ it has already been presented for some time (which is not the case).

I would appreciate any insight/help with the above as I can’'t seem to figure it out! Thank you in advance.