OS (e.g. Win10): Windows 10 (testing PC, scanner PC TBD)
PsychoPy version (e.g. 1.84.x): 2021.2.3
Standard Standalone? (y/n) : yes
What are you trying to achieve?: non-slip timing, consistent trial syncing with scanner signals (in our case, a keypress of “5”)
Hi all, any help you can provide is much appreciated!
We have a working Builder script (with a few code components inserted) that we want to use for an fMRI experiment. We have the launchScan function set to sync with the scanner’s trigger pulse (a keypress of “5”) at the beginning of the trials. When I test this on my office PC, the nonslip timing works perfectly. The image stimulus that is meant to be triggered by the scanner pulse appears around .25s after the pulse and then stays consistent within a range of about .15 to .33s after the scanner pulse throughout the trials.
Yesterday, we ran our first participant at the MRI scanner. The PC there is older but I don’t have its information handy. I will check on it and post an update later this afternoon in case this is important. We noticed as the experiment went on that the final item on each trial (a single word) was staying on the screen for longer than intended (it is meant to appear for 1s). The length of each run was also noticeably longer than expected. This morning I took a look at the trial timing in the data files. I have attached the data files from our first participant’s first run here. The .log file shows that the first “5” keypress (scanner syncing signal) occurred at 644.725 and our first image stimulus (the beginning of the trial) appeared at 645.188. This is a lag of 0.46 which is longer than we found in prior tests but workable if it stayed consistent throughout the run. Unfortunately, the lag between a scanner pulse and the beginning of each subsequent trial increased by approximately 0.1s. By the 13th trial, the syncing was 1.88s off. The scanner pulses occur at 2s intervals, so at that point the syncing is back on track but then gets gradually offset again over the next trials. (I added columns FY, FZ, and GA in the .csv data file to highlight the trial start time, scanner pulse time for that trial, and the difference between those two times.)
I’m attaching a truncated version of our Builder script here. The images required to make it run are 2 to 4MB a piece so I haven’t included them. As you can see, the “Trials” and “variable_ISI” routines are green, indicating that they should run with non-slip timing. The only other item in the trial loop is “distractor_code1” which is a set of code components with no stimulus presentation. Given that it is blue, I’m wondering if that is creating the delay, even though the code doesn’t actually print anything to the screen?
To facilitate examination of those code components, I have pasted them here. Note that the last bit of code is the launchScan function, which has to be included in order to sync to the scanner. Is there any other way to incorporate it without breaking the nonslip timing? (If that is what is happening here.) All of these bits of code are in the “Begin Routine” tab:
new_dir = _thisDir + "/cmd/" + str(int(expInfo['participant'])) + "/study1.csv" new_conds = pd.read_csv(new_dir, index_col = False) isi_cond = pd.DataFrame(new_conds, columns = ['TrialNum', 'objectname', 'reps', 'Dist_type']) if trials1.thisN == 0: first_target_image = isi_cond.objectname.iloc[trials1.thisN] target_image.setImage(first_target_image) if isi_cond.Dist_type.iloc[trials1.thisN] == 2: words = _thisDir + "/dist2.csv" else: words = _thisDir + "/dist1.csv" thisISI = str(isi_cond.reps.iloc[trials1.thisN]) get = sample(range(70), int(thisISI)) if trials1.thisN == 0: vol = launchScan(win, MR_settings, globalClock=globalClock, mode='Scan', log=True)
Many many thanks if you can help us. I’m going to continue attempting to troubleshoot, including testing on the scanner PC this afternoon and will update if I learn anything new.