Cognitive Neurophysiology Laboratory

CNL Wiki

Docs: Card Matching Game Sleep Study

Updated on August 24, 2023

Running the Card Matching Game Sleep Study



And …/CODE/Utilities/eyeTrackerUtilities

Run Screening

  1. Patient questionnaire
  2. Find images that cater to patient interests
  3. Crop images as squares and size to 400×400
  4. Add to …/PARADIGMS/GM/code/stimuli/new_pics_to_add_to_new_lib
  5. Run prepgm_ver1_2
  6. Copy newly renamed images into …/PARADIGMS/GM/code/stimuli/toScale and then scale all to 160 pixels and save as .bmp (Emily has a bmp160 action in photoshop; copy the newly scaled images into …/PARADIGMS/GM/code/stimuli/bmp160)
  7. Run selectScreeningImages or move images into trial1 folder (along with others from the finished gallery to have ~100 images)
  8. Run gm_serial

Look for selective cells

  1. Unpack data via database
  2. Spike sort and verify spikes
  3. Run screeningRasters
  4. Run makeListOfScreeningImages
  5. If you find images with cells that are selective to them, save a list of filenames associated to those images (You can copy the file screeningImageList.txt that was made in the last step and delete all the files that aren’t part of it)

Get images ready for Card Matching

  1. Create a folder for this patient inside the …PARADIGMS/CARDMATCHING/PatientData folder
  2. Copy the trial1 folder into the patient’s folder. Resize the images to 160 x 160 and convert to .bmp

Run the card matching game

  1. Don’t forget to bring into patient room
    1. Bluetooth speakers – pair with computer and make sure computer plays sounds on the speakers, then restart matlab (or maybe just clear mex) so that psych toolbox knows to use these speakers
    2. Bluetooth mouse
    3. Eyetracker
  2. launchCardMatchingGame(patientNumber,debugMode)
    1. If this is the first time running with this patient, you will have to set a variety of parameters and locate the places where stimuli are stored.
      1. Images are the 160×160 bmp images you made
      2. Card backgrounds are in …/STIMULI/CardMatchingStimuli/ cardbacks/cardbacks_160bmp
      3. Sounds are in …/STIMULI/CardMatchingStimuli/sounds
    2. If this is not the first time running with this patient and you are running on a new computer, you might want to open the patientParameters.mat file and make sure all paths are correct.
    3. If this is not the first time running with this patient, you will be asked whether you want to use pre-existing games or generate new ones. If you are starting the game again after something crashed, use pre-existing. If you are doing a new experiment, choose generate new.
    4. Enter daq, serial, stim, and eyetracker. If eyetracker is running, set daq to 0. (Though we may be able to debug having them both running at the same time, it crashed when I tried.)
    5. Press ok when recording; test TTLs; play the game
    6. Instructions for the patient:
  3. You will choose two cards, then the computer will choose two cards.
  4. If you find a match, you get points and the cards will be removed.
  5. The computer has good memory within a game, so it might be tough to beat on the first try, but it doesn’t have good memory across games, so you will beat it if you can remember from one game to the next
  6. You will alternate between two game boards, but games with the same card backs have the same images and arrangement.
  7. You will keep playing until you beat the computer 3 times in a row on each board.
    1. After patient reaches criterion, game will ask if you are recording. This is the sign that it has automatically moved into the memory test phase.
    2. Instructions for the patient
      1. For each image, click on the TWO places where the image was presented during the game.
      2. Remember, we are mixing images from both boards, so it’s okay if you remember two different images as having been in the same place!


  1. Make sure cables give patient slack to sleep comfortably. Tape securely to bed. Remind patient to be very careful with sudden movements.
  2. Leave phone number for nurse. Ask nurse to contact you if s/he needs to move patient so that you can help disconnect.
  3. Wait for patient to enter “deep sleep”. If you don’t see slow waves on the EEG, wait for about an hour after patient appears to fall asleep.
  4. Run playWhiteNoiseWithCue(rewardOrMusic, daq, cereal, stim, debugMode, loopLength). The first argument should be a string, ‘reward’ or ‘music’. loopLength should be 60. It’s probably a good idea to run in debugMode (as long as you clear mex before running the next morning!).
  5. Make sure volume on speakers and computer is turned down!
  6. Press space to start playing. Gradually increase the volume to audible but not loud enough to disrupt sleep.
  7. Pressing space pauses/resumes the sound loop. Pressing escape cancels. Be sure to press escape before disconnecting the computer or psych toolbox will freak out.
  8. Let the sound run for ~2 hours, then stop the paradigm and disconnect the blue cables. Tape or Velcro them so that they can be managed by the patient if s/he needs to get out of bed.

Morning After

  1. Set up eyetracker again. Turn volume back up.
  2. Start recording audio. Ask patient about dreams (note whether they mention anything without you even prompting them, so far both patients have!). Also ask if they were aware of the sounds overnight or if they disrupted their sleep. I usually tell them in advance that I will be playing white noise, but I don’t tell them that it will have meaningful noises embedded in it. Don’t ask directly about that, but ask if they noticed anything about the sounds.
  3. Run beginCardMatchingMemoryTest([],daq,cereal,stim, debugMode,[],eyetracker,rewardOrMusic)
    The arguments above that are blank should be left blank. rewardOrMusic should be the same one you chose for the overnight sound.
  4. You will be prompted to find the param history file for the patient. It will be in the patient’s data folder. The filename starts matchHistory_ followed by a date. Choose the most recent matchHistory file. The same memory test that was presented the night before will be given. Again, patient should click on the two locations within the game board where each image was shown as part of the game.
  5. After the spatial memory test is over, the paradigm will automatically move into an associative memory test.
  6. Instructions for the patient:
    1. For each image shown, it will be paired with a card back or a sound from the games you played last night. Your job is to decide whether that image was part of the game with that card back or that reward sound and say yes or no.
    2. Press left for no. Right for yes. (At some point, I will code this for game pad, but for now, have the patient say yes or no, and you press the arrow keys.)
    3. This is very hard! Don’t think too hard, this is just a gut-reaction test. We don’t expect you to do very well on this, we just want to see if your brain remembers something that you might not even be aware of, so answer quickly.

If you and patient are feeling really ambitious, patient can play the card matching game once more. launchCardMatchingGame(patientNum). Use pre-existing games. If you just ran the second experiment, enter ‘3 4’ when it asks which games to use. Press escape after patient has played each gameboard once – no need to re-train to criterion.

Woohoo! You’re done. That wasn’t SOOOO bad, was it?