From CNI Wiki
The CNI has facilities to present visual, auditory, olfactory, and gustatory stimuli. Details on the various stimulus delivery equipment can be found on the MR Hardware page.
CNI E-prime computer
Describe the e-prime laptop here.
Tutorial courtesy of Melissa Henry, Research Assistant, fMRI Project Coordinator, Psychology Department, Stanford. Eprime comprises a suite of applications that are installed on the Windows XP boxes. Applications include “E-‐Studio”, “E-‐Basic”, “E-‐Run”, or “E-‐Merge”. Selecting an Eprime script will start the relevant program.
Running the Scripts
Figure 1. From the desktop click on the “Users” shortcut folder to get to your lab’s E-‐Prime folder. After opening the “Users” folder, find and open your lab’s folder.
Figure 2. Each of the Users’ folders has differing contents or “Tasks”. Open the folder relating to the “Task” you wish to execute, in this case “COMO”. (Images courtesy Ian Gotlib lab).
Figure 3. Each task has several associated files. The .edat and .txt files are output from either the corresponding build .es (green building blocks) or run .ebs (purple running man) files.
Figure 4. **NOTE** If changes are made to your experiment in the .es file (green building blocks), It will need to be run to create a new run file. The experiment should be run from the newly created .ebs file (pink running man).
Figure 5. Once the file is open, select “Build” and select “Run”.
Figure 6. After “Run” is initiated, enter the “Subject Number” and select “OK”.
Figure 7. After “Subject” is entered, enter the “Session Number” and select “OK”.
Figure 8. At “Summary of Startup Info”, select “Yes”.
Figure 9. To end the experiment early, press “ctrl + shift + alt” simultaneously. The experiment will abort.
Figure 10. If the experiment is aborted, this screen will be displayed. This provides an opportunity to re-‐start the “Run” process after the appropriate file has been chosen: .es or ebs. files.
How to adapt Lucas Center ePrime files to CNI
Courtesy of Bob Dougherty & Jill Waring. 12/14/11
To adapt ePrime scripts that used SRbox for triggering (such as those from Lucas) to work at the CNI:
1) Make sure the CNI trigger device is configured and is set to COM port 1, 2, 3, or 4:
- Look in Settings --> System hardware --> Device manager.
- See COM port. If it is >4, change it so that it is 1, 2, 3, or 4. The CNI "EPrime Trigger" USB cord must be plugged into your computer in order to view the COM port (updated: 5/1/13)
2) In ePrime:
a) open script “sstart”.
b) Comment out (by adding ‘ before line) or delete all the existing lines, and add the following line:
c) Change stimulus response devices:
- Edit Menu --> Experiment --> Devices.
- Take out SRBox in the list of devices and add a serial device.
- Change the COM port so that it is the same as the CNI trigger device that you set in #1 above.
- Set bits per second = 57600.
- Other settings can be left at their default values.
Courtesy of Alexander Genevsky, Ph.D. student in Psychology, and the Knutson SPAN Lab.
Small amounts of E-Prime processing time can aggregate over trials and nudge your presentation paradigm out of sync with the scanner sequence. In order to counteract this ‘drift’ we use in-line scripts to dynamically adjust the timing of one feature of the trail on each iteration (typically the ITI).
There are three necessary steps:
- The user script must be modified to initialize the global variables used in the drift correction. Add this code to the global user script. You can get to the user script through View -> Script.
- dim Trigtime as Long
- dim DriftCorrect as Long
- dim TrigOuttime as Long
- The time when the scanner is triggered must be captured. Add this in-line code immediately after the trigger.
- ‘ get start time
- Trigtime = Clock.ReadMillisec
- c.SetAttrib "TrigTime", Trigtime
- The trial-by-trial drift must be calculated and subtracted from the duration of a trial element. In this example the ‘iti’ variable refers to the duration in milliseconds of the trial’s ITI object
- 'TRLength should be set to the number of msec used for a TR
- Dim TRLength as Integer
- 'Needed to possibly correct for undershoot. Probably don't play with ‘this.
- Dim MaxNegative as Integer
- 'Intermediate for calculations.
- Dim TotalTimeTemp as Long
- TRLength = 2000
- MaxNegative = 100
- 'Calculate how much time has elapsed since the magnet started, plus a ‘factor to make sure the results are positive in case of undershoot. This ‘factor is subtracted back out later.
- TotalTimeTemp = Fixation.OnsetTime - TrigTime + MaxNegative
- c.SetAttrib "DriftCorrection", (TotalTimeTemp Mod TRLength) - MaxNegative
- 'Take the drift out of the post-target delay
- c.SetAttrib "iti", c.GetAttrib("iti") - c.GetAttrib("DriftCorrection")
- 'Make sure the post-target delay doesn't end up <0. If so, allow ‘remainder of correction to be done next cycle.
- If c.GetAttrib("iti") < 0 Then c.SetAttrib "iti", 0
Psychopy is a nice open-source experiment control system. There is a GUI experiment builder (like e-prime), or you can write code using the Pschopy library calls (like Psych Toolbox). To trigger the scanner from Psychopy, add a code component with this in the "begin experiment" section:
And add this to the "begin routine" section:
device = '/dev/ttyACM0' # NOTE: replace this with your actual device! try: ser = serial.Serial(device, 115200, timeout=1) ser.write('[t]\n'); ser.close() except: pass
Note that you might need to change the "device=" line to reflect the actual location of your device. On linux, it will likely be /dev/ttyACM0. On OS-X, it will be something like '/dev/tty.usbmodem12345'. (See the MR Hardware page for more details.)