MRI Setup: Difference between revisions

From CCN Wiki
Jump to navigation Jump to search
 
(24 intermediate revisions by 3 users not shown)
Line 5: Line 5:
*Contact information for all participants for that day
*Contact information for all participants for that day
*100% certainty about what experiment you are running that day (it is possible that multiple fMRI experiments will be going on in the lab at any given time)
*100% certainty about what experiment you are running that day (it is possible that multiple fMRI experiments will be going on in the lab at any given time)
== Travel to CTRC ==
Be sure to leave enough time to get yourself to the CTRC lobby, including time required to find a parking spot and walk to the building. Aim to be at the CTRC at least 45 minutes before the scheduled start of scan. A summary of local parking options can be found at [http://www.bnmc.org/parking-bnmc/ http://www.bnmc.org/parking-bnmc]. Not mentioned on this page are some more distant free options West of Main Street, if you don't mind a brisk 5-minute walk. You can probably find street parking on several of the streets off of North Street, including Linwood, Franklin, N Pearl and others.


== Upon Arrival ==
== Upon Arrival ==
Empty your pockets of anything metallic
Empty your pockets of anything metallic


== Test the Experiment Script ==
== Experimenter Laptop Setup ==
Before we check that the buttons and AV display should be working fine, we should do a dry run of the experiment script to make sure that you are familiar with running it. We wish to avoid having participants waiting uncomfortably in the scanner while we troubleshoot our scripts!
The laptop connects via USB to the Lumina console and via an HDMI video cable to the SensaVue controller box. The SensaVue box redirects video to the scanner bore display. The Lumina console masquerades as an external USB keypad and sends participant keypresses and scanner trigger events to the laptop.


Open a terminal window (if one is not already open) and navigate to the directory containing the script to be run that day. The script is likely to be found in a subdirectory under <code>/home/Experimenter/Documents/MATLAB/</code>
=== Connect the HDMI cable to the laptop ===
cd /home/experimenter/Documents/MATLAB/<projectname>
This step can happen later, but you may as well do it now.
For example, we are currently developing the protocols for a lexical decision task (LDT). Those files are in ~/Experimenter/Documents/MATLAB/LDT/
#Locate the Amazon-branded HDMI cable
#Plug it into the one-and-only HDMI port on the back of the laptop.
#Confirm with the scanner technician that the SensaVue controller box is turned on and is using the correct settings
#*If there is nothing showing on the fMRI scanner bore display when your laptop is running, then it is likely that either:
##The SensaVue box is not turned on, or is using an incorrect setting
##Your laptop is not using a mirrored display. Unless told otherwise, your laptop needs to be using a mirrored display. PsychToolbox does not work nicely with extended displays.
#Participants will typically be looking at stimuli presented on a display positioned at the head of the scanner
#After the laptop has booted up, ensure that the fMRI scanner bore display is using the correct orientation
#*Because they are looking through a mirror, the image will have to be flipped horizontally
#*Depending on the mirror attached to the head coil, the image may also need to be flipped vertically
#*The SensaView display control box has a series of 4 toggle buttons that control the display
#*The most likely orientation is marked with a piece of tape on the SensaVue control box. Double-check with the scanner technician to confirm
#**The 16-channel head coil requires the image to be LR flipped; the 32-channel coil requires the image to be LR and TB flipped


Launch MATLAB
=== Boot up the laptop ===
ptb3-matlab
#Boot Ubuntu 14.04 (This is the default)
#Log in as the experimenter on the laptop


Run the script, using a dummy subject ID (e.g., 9999)
>>LDT(9999);
Our fMRI experiments usually listen for events from the external keypad. If the external USB keyboard has not yet been connected, the scripts will default to listening to the laptop keyboard. We can simulate the scanner room events by pressing the laptop keyboard buttons:
*A laptop keypress of '6' simulates a scanner trigger (the experiments often wait for this trigger signal to synchronize the experiment with the scanner)
*Keypresses of 1, 2, 3 or 4 simulate the participant button box responses (see below), which you might need to do if the experiment script waits on participant responses
== Experimenter Laptop Setup ==
The laptop connects via USB to the Lumina console. The console masquerades as an external USB keypad and sends participant keypresses and scanner trigger events to the laptop.
=== Connect the Lumina console to the laptop ===
=== Connect the Lumina console to the laptop ===
#Locate the white USB cable in the back of the Lumina console
#Locate the white USB cable in the back of the Lumina console
#Plug the other end into a USB port in the laptop
#Plug the other end into a USB port in the laptop
 
=== Configure Lumina console settings ===
=== Check that the keypad is sending signals to the laptop ===
'''Before you enter the Magnet area, ensure that you are metal free!'''
#Set the Lumina controller to send the expected signals
#Set the Lumina controller to send the expected signals
#*The '''Controller Mode''' should be set "As Keyboard"
#*The '''Controller Mode''' should be set "As Keyboard"
#*Toggle the '''Using''' to ''E-Prime''
#*Toggle the '''Using''' to ''E-Prime''
=== Check that the keypad is sending signals to the laptop ===
'''Before you enter the Magnet area, ensure that you are metal free!'''
#Find the two 2-button response boxes are in the scanner room
#Find the two 2-button response boxes are in the scanner room
#*They are likely to be found attached to the wheeled display mount stand
#*They are likely to be found attached to the wheeled display mount stand
#*If they are not attached, ask the technician for help setting them up
#*If they are not attached, ask the technician for help setting them up
#*Examine the button boxes closely. You will see they are labeled '''L''' (blue/yellow) and '''R''' (red/green)
#*Examine the button boxes closely. You will see they are labeled '''L''' (blue/yellow) and '''R''' (red/green)
#Log in as the experimenter on the laptop
#Launch the text editor to provide some sort of environment in which you can type with the external keypad
#Open a terminal window
#Click the button box keys
#Navigate to the directory containing the Keyboard test script
#*If the Lumina controller is set correctly, you should see a series of 1's to 4's, depending on which buttons you push
#Launch MATLAB
=== Launch MATLAB with PsychToolBox ===
#Open a terminal
#Navigate to ~/Documents/MATLAB/'''''Experiment_Name'''''
#Launch MATLAB with the ptb3-matlab script:
  ptb3-matlab
  ptb3-matlab
== Obsolete Steps ==
When starting out, we had extra steps to check to make sure that the laptop was receiving the correct signals and that MATLAB was listening for them. For established MATLAB scripts, the steps below aren't really needed anymore. Still, they're recorded for posterity.
#Run the keyboard test script
#Run the keyboard test script
  >>keyboard_info
  >>keyboard_info
#*The script will give you a number of potential keyboards to test out. Select ''Cedrus Corporation Lumina Keyboard''
#*The script will give you a number of potential keyboards to test out. Select ''Cedrus Corporation Lumina Keyboard'' (see troubleshooting section below if there are more than one matching keyboards)
#*One of the experimenters should press each of the keypad buttons while the other monitors that the button presses are registering in MATLAB
#*One of the experimenters should press each of the keypad buttons while the other monitors that the button presses are registering in MATLAB
#*Even more clever: if the SensaVue display is already routing video to the scanner bore display, you can push the keypad buttons and see the display for yourself (albeit in a mirror-image). This method only requires one person, and less shouting.
#*If the Lumina box is configured correctly to send E-Prime signals, the key-presses should be showing up as the numbers 1 to 4 (the scanner trigger will register as a '''^6''')
#*If the Lumina box is configured correctly to send E-Prime signals, the key-presses should be showing up as the numbers 1 to 4 (the scanner trigger will register as a '''^6''')
#Troubleshoot if necessary, because running the experiment will absolutely depend on the external USB keyboard being configured
#Troubleshoot if necessary, because running the experiment will absolutely depend on the external USB keyboard being configured (see the next section)
 
== Keyboard Troubleshooting ==
Our fMRI experiments usually listen for events from the external keypad. However the laptop has a built-in keyboard as well, but the software only wants to listen to one of them at a time.
 
If the external USB keyboard has not yet been connected, the scripts will default to listening to the laptop keyboard. We can simulate the scanner room events by pressing the laptop keyboard buttons:
*A laptop keypress of '6' simulates a scanner trigger (the experiments often wait for this trigger signal to synchronize the experiment with the scanner)
*Keypresses of 1, 2, 3 or 4 simulate the participant button box responses (see below), which you might need to do if the experiment script waits on participant responses
 
==== Keyboard Voodoo ====
I'm not 100% sure about what, if any, rules govern how PsychToolbox + MATLAB + Linux juggle their keyboards. The problem is that the scanner triggers and the participant button boxes appear as an external keypad, but the laptop has it's own internal keyboard that's critical for being able to type useful commands. PsychToolbox only wants to listen to one at a time, and there was some mystery about how you would force it to listen to the right keyboard at any particular point in time.
 
I've tried a couple experiments, changing the sequence of when the external keyboard should be plugged into the experimenter laptop. I haven't seen any documentation about this, which is why I call this section Voodoo, however the following procedure seems to work:
 
# Boot up the laptop up with the external keyboard '''disconnected'''
# Log in as the experimenter
# Plug in the external keyboard
# Launch ptb3-matlab


=== Display Setup ===
Now the keyboard should have been assigned a device number, and MATLAB should be able to detect it. This sequence of actions is the basis for the steps described above in this document.
#An HDMI cable (Amazon.com branded) should be poking up through the desk. Connect it to the HDMI port on the laptop (there is only one port that this cable can possibly fit into)
 
#Participants will typically be looking at stimuli presented on a display positioned at the head of the scanner
==== Other Potential Problems ====
#Ensure that the stimuli are projected in the correct orientation
One thing I ran into (which may not be an issue with the input device used at the scanner), but my external keyboard had '''2''' entries when I ran the keyboard_info script. Moreover, when I tested both of those keyboard device IDs using the keyboard_info script, only ONE of them sent keystrokes. By chance, on one occasion, it was the device with the higher ID. However if there are multiple keyboards with the same name the experiment script might accidentally tune into the device that doesn't send any key strokes (this happened on one of my tests). When I unplugged/plugged in the keyboard and restarted MATLAB, new device IDs were assigned, and this time it worked okay. The moral of the story is to make sure that you have only one matching external keyboard, but if you don't (for some reason), to check that the entry with the smaller device ID gives you input when you run the keyboard_info script. If not, quit Matlab, unplug, plug in, and restart until the problem is resolved.
#**Because they are looking through a mirror, the image will have to be flipped horizontally
#**Depending on the mirror attached to the head coil, the image may also need to be flipped vertically
#**The SensaView display control box has a series of 4 toggle buttons that control the display
#**The most likely orientation is marked with a piece of tape on the SensaVue control box. Double-check with the scanner technician to confirm
#***The 16-channel head coil requires the image to be LR flipped; the 32-channel coil requires the image to be LR and TB flipped


=== Audio Setup ===
=== Audio Setup ===
Line 69: Line 96:
**If you are finding that the keyboard check script is not detecting the external USB keypad, relaunch MATLAB, ensuring that the USB keypad is plugged in when MATLAB is launched
**If you are finding that the keyboard check script is not detecting the external USB keypad, relaunch MATLAB, ensuring that the USB keypad is plugged in when MATLAB is launched
*If all else fails, reboot the laptop
*If all else fails, reboot the laptop
*Its helpful to have important experimental parameters specified in an external configuration file, rather than hard coded in a script. This approach is employed in the LDT experiment. Apparently, the getExperimentConfig.m function requires that this file is edited in a text editor like gedit, rather than using the MATLAB editor. Changes made using the MATLAB editor will cause a parsing error.

Latest revision as of 22:02, 26 July 2016

Checklist

Before leaving for the MRI Center, ensure you have the following:

  • Experimenter Laptop (check that you know its whereabouts prior to the scan date!)
  • Physical experimental stimuli (if any)
  • Contact information for all participants for that day
  • 100% certainty about what experiment you are running that day (it is possible that multiple fMRI experiments will be going on in the lab at any given time)

Travel to CTRC

Be sure to leave enough time to get yourself to the CTRC lobby, including time required to find a parking spot and walk to the building. Aim to be at the CTRC at least 45 minutes before the scheduled start of scan. A summary of local parking options can be found at http://www.bnmc.org/parking-bnmc. Not mentioned on this page are some more distant free options West of Main Street, if you don't mind a brisk 5-minute walk. You can probably find street parking on several of the streets off of North Street, including Linwood, Franklin, N Pearl and others.

Upon Arrival

Empty your pockets of anything metallic

Experimenter Laptop Setup

The laptop connects via USB to the Lumina console and via an HDMI video cable to the SensaVue controller box. The SensaVue box redirects video to the scanner bore display. The Lumina console masquerades as an external USB keypad and sends participant keypresses and scanner trigger events to the laptop.

Connect the HDMI cable to the laptop

This step can happen later, but you may as well do it now.

  1. Locate the Amazon-branded HDMI cable
  2. Plug it into the one-and-only HDMI port on the back of the laptop.
  3. Confirm with the scanner technician that the SensaVue controller box is turned on and is using the correct settings
    • If there is nothing showing on the fMRI scanner bore display when your laptop is running, then it is likely that either:
    1. The SensaVue box is not turned on, or is using an incorrect setting
    2. Your laptop is not using a mirrored display. Unless told otherwise, your laptop needs to be using a mirrored display. PsychToolbox does not work nicely with extended displays.
  4. Participants will typically be looking at stimuli presented on a display positioned at the head of the scanner
  5. After the laptop has booted up, ensure that the fMRI scanner bore display is using the correct orientation
    • Because they are looking through a mirror, the image will have to be flipped horizontally
    • Depending on the mirror attached to the head coil, the image may also need to be flipped vertically
    • The SensaView display control box has a series of 4 toggle buttons that control the display
    • The most likely orientation is marked with a piece of tape on the SensaVue control box. Double-check with the scanner technician to confirm
      • The 16-channel head coil requires the image to be LR flipped; the 32-channel coil requires the image to be LR and TB flipped

Boot up the laptop

  1. Boot Ubuntu 14.04 (This is the default)
  2. Log in as the experimenter on the laptop

Connect the Lumina console to the laptop

  1. Locate the white USB cable in the back of the Lumina console
  2. Plug the other end into a USB port in the laptop

Configure Lumina console settings

  1. Set the Lumina controller to send the expected signals
    • The Controller Mode should be set "As Keyboard"
    • Toggle the Using to E-Prime

Check that the keypad is sending signals to the laptop

Before you enter the Magnet area, ensure that you are metal free!

  1. Find the two 2-button response boxes are in the scanner room
    • They are likely to be found attached to the wheeled display mount stand
    • If they are not attached, ask the technician for help setting them up
    • Examine the button boxes closely. You will see they are labeled L (blue/yellow) and R (red/green)
  2. Launch the text editor to provide some sort of environment in which you can type with the external keypad
  3. Click the button box keys
    • If the Lumina controller is set correctly, you should see a series of 1's to 4's, depending on which buttons you push

Launch MATLAB with PsychToolBox

  1. Open a terminal
  2. Navigate to ~/Documents/MATLAB/Experiment_Name
  3. Launch MATLAB with the ptb3-matlab script:
ptb3-matlab

Obsolete Steps

When starting out, we had extra steps to check to make sure that the laptop was receiving the correct signals and that MATLAB was listening for them. For established MATLAB scripts, the steps below aren't really needed anymore. Still, they're recorded for posterity.

  1. Run the keyboard test script
>>keyboard_info
    • The script will give you a number of potential keyboards to test out. Select Cedrus Corporation Lumina Keyboard (see troubleshooting section below if there are more than one matching keyboards)
    • One of the experimenters should press each of the keypad buttons while the other monitors that the button presses are registering in MATLAB
    • Even more clever: if the SensaVue display is already routing video to the scanner bore display, you can push the keypad buttons and see the display for yourself (albeit in a mirror-image). This method only requires one person, and less shouting.
    • If the Lumina box is configured correctly to send E-Prime signals, the key-presses should be showing up as the numbers 1 to 4 (the scanner trigger will register as a ^6)
  1. Troubleshoot if necessary, because running the experiment will absolutely depend on the external USB keyboard being configured (see the next section)

Keyboard Troubleshooting

Our fMRI experiments usually listen for events from the external keypad. However the laptop has a built-in keyboard as well, but the software only wants to listen to one of them at a time.

If the external USB keyboard has not yet been connected, the scripts will default to listening to the laptop keyboard. We can simulate the scanner room events by pressing the laptop keyboard buttons:

  • A laptop keypress of '6' simulates a scanner trigger (the experiments often wait for this trigger signal to synchronize the experiment with the scanner)
  • Keypresses of 1, 2, 3 or 4 simulate the participant button box responses (see below), which you might need to do if the experiment script waits on participant responses

Keyboard Voodoo

I'm not 100% sure about what, if any, rules govern how PsychToolbox + MATLAB + Linux juggle their keyboards. The problem is that the scanner triggers and the participant button boxes appear as an external keypad, but the laptop has it's own internal keyboard that's critical for being able to type useful commands. PsychToolbox only wants to listen to one at a time, and there was some mystery about how you would force it to listen to the right keyboard at any particular point in time.

I've tried a couple experiments, changing the sequence of when the external keyboard should be plugged into the experimenter laptop. I haven't seen any documentation about this, which is why I call this section Voodoo, however the following procedure seems to work:

  1. Boot up the laptop up with the external keyboard disconnected
  2. Log in as the experimenter
  3. Plug in the external keyboard
  4. Launch ptb3-matlab

Now the keyboard should have been assigned a device number, and MATLAB should be able to detect it. This sequence of actions is the basis for the steps described above in this document.

Other Potential Problems

One thing I ran into (which may not be an issue with the input device used at the scanner), but my external keyboard had 2 entries when I ran the keyboard_info script. Moreover, when I tested both of those keyboard device IDs using the keyboard_info script, only ONE of them sent keystrokes. By chance, on one occasion, it was the device with the higher ID. However if there are multiple keyboards with the same name the experiment script might accidentally tune into the device that doesn't send any key strokes (this happened on one of my tests). When I unplugged/plugged in the keyboard and restarted MATLAB, new device IDs were assigned, and this time it worked okay. The moral of the story is to make sure that you have only one matching external keyboard, but if you don't (for some reason), to check that the entry with the smaller device ID gives you input when you run the keyboard_info script. If not, quit Matlab, unplug, plug in, and restart until the problem is resolved.

Audio Setup

We have not yet run an experiment with auditory stimuli, so this is not yet sorted. However a sketch of the procedure will entail playing a test script that presents some auditory items, and having one of the scan team listen over the MRI headphones while the other runs the script.

Troubleshooting

  • Whether or not the external keyboard is plugged in at the time that you launch MATLAB seems to dictate whether or not MATLAB will see it
    • If you are finding that the keyboard check script is not detecting the external USB keypad, relaunch MATLAB, ensuring that the USB keypad is plugged in when MATLAB is launched
  • If all else fails, reboot the laptop
  • Its helpful to have important experimental parameters specified in an external configuration file, rather than hard coded in a script. This approach is employed in the LDT experiment. Apparently, the getExperimentConfig.m function requires that this file is edited in a text editor like gedit, rather than using the MATLAB editor. Changes made using the MATLAB editor will cause a parsing error.