Monitors and stimulus view settings - bgur123/PyStim GitHub Wiki

An important aspect of stimulation is to make sure that the stimulus we generated is presented (projected in our case) correctly in terms of it's position and size on the screen. Furthermore, to use degrees(°) of visual angle while defining our stimuli, we need to tell PsychoPy some necessary information. Also our Dlp pixels are not squares so we need to tell this to PsychoPy.

  • First of all we need to create a "monitor" in PsychoPy in order to configure our settings: explained here
  • Stimulus image should fit perfectly to the screen. To do this we need to change the size and position of the projected image.
  • PsychoPy needs some information to calculate the visual angle. More on how to do this here.
  • Tell PsychoPy that our pixels are not squares: scale the stimulus.
  • Check all parameters while running PyStim: run parameters.

Monitors

  1. Open the PsychoPy desktop app.
  2. Go to Monitor Center (Tools menu)
  3. Create a monitor, this should be the one that DLP will use to present images.

Centering the stimulus

  1. Go to "view_settings.txt" under PyStim>stimuli
  2. Change the stim_pos_x or stim_pox_y to center the stimulus
  3. Adjust the size if necessary (here)
  4. Repeat until the stimulus image fills the entire screen

Pixel sizes

We want the projected image to fit perfectly on the screen. To achieve this you need to project a stimulus on the screen and change the pixel sizes of X and Y dimensions so that the stimulus fits perfectly on the screen. The steps required for this are:

  1. Project any non-dark stimulus using Dlp to the screen (not dark so you can actually see the edges where the stimulus image ends)
  2. If the projected stimulus doesn't completely fill the screen, increase the corresponding dimension's pixel size via: go to the PsychoPy Monitor Center (Tools menu in the app) -> select the monitor that is used (This has to correspond to the Dlp) -> change the pixel sizes (width or height)
  3. If the projected stimulus is bigger than the screen, then decrease the corresponding dimension's pixel size.
  4. Repeat this until you reach the perfect pixel sizes that fills the screen completely. Note for this process: You might need to adjust the positions simultaneously since you can only increase or decrease the size of the image in one direction.

Note for Dlp: Dlp pixels are not square so that is why we need 1:2 pixel size ratio to fill the otherwise square screen. More on this here.

The visual angles covered by the screen

We can change the size of our stimuli easily by giving inputs to PyschoPy stimulus generation functions. For example, we can write a code that simply says: "draw me a 20° circle in the middle of the screen". In order for PsychoPy to create the desired stimuli, it needs to understand the size of our stimulus screen in terms of visual angles (degrees). We calculate this using the subject's (fly's) distance to the screen and the width of the screen.

  1. Measure the fly's distance to the center of the screen
  2. Measure the width (height should be the same since it is a square)
  3. Enter these values in the PsychoPy Monitor Center (Tools menu in the app) in the monitor that is used (This has to correspond to the Dlp)
  4. Calculate the visual angle (done in the PyStim code psyTools.py > setup_params() )

Scaling the stimulus for non-square pixel sizes

Since Dlps have non-square pixels we need to tell PsychoPy to scale our stimulus accordingly since by default it assumes that all pixels are squares.

  1. Go to "view_settings.txt" under PyStim>stimuli
  2. Change the view_scale_x or view_scale_y to scale the stimulus Currently this x scale is 1 and y is 0.5 since our Dlp has 1:2 ratio of pixel edge size.

Run parameters

While you're running the PyStim, you'll see a UI that shows the run options (after selecting the stimulus input file). Here are these parameters:

  1. Monitor settings: Pick the monitor you created following the instructions here.
  2. use DLP: check this box if you're using DLP (light projector at Silies lab)
  3. use NIDAQ: check this box if you're starting an experiment where the information needs to be exchanged between the two photon microscope and the stimulus computer (e.g. trigger needs to come from the two photon microscope via NIDAQ).
  4. Refresh rate: Check the refresh rate of your monitor from the settings in your computer. Make sure it matches here.
  5. Stim win pos X: Make sure these are correct. Explained here.
  6. Stim win pos Y: Make sure these are correct. Explained here.
  7. Stim units: we use degrees.
  8. use warper: if you want to use the perspective correction check this box.
  9. view scale X: check the section scale the stimulus.
  10. view scale Y: check the section scale the stimulus.