{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "PsychoPy PLR\n", "============\n", "\n", "If you decide that a standard computer monitor is sufficient for presenting a light stimulus, you could use *PyPlr* with PsychoPy. This minimal example presentes a 1-second white flash on a monitor and saves a recording with an annotation marking the onset of the flash. Just make sure the participant's head is stabelised and that the Pupil Core world camera can see the screen." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "```Python\n", "#!/usr/bin/env python3\n", "# -*- coding: utf-8 -*-\n", "\n", "import sys\n", "from time import sleep\n", "\n", "from psychopy import core, visual\n", "\n", "from pyplr.pupil import PupilCore\n", "\n", "def main(subject='test', display_size=(1024,768)): \n", " \n", " # Set up Pupil Core\n", " p = PupilCore()\n", " \n", " # Setup windows and stimulus\n", " win = visual.Window(size=display_size, screen=1, color='black')\n", " white = visual.Rect(win, units='pix', size=display_size)\n", " white.color='white'\n", " black = visual.Rect(win, units='pix', size=display_size)\n", " black.color='black'\n", " \n", " # Set up pupil trigger\n", " annotation = p.new_annotation('LIGHT_ON')\n", " \n", " # Start recording\n", " p.command('R {}'.format(subject))\n", " sleep(2.)\n", " \n", " # Start light_stamper\n", " lst_future = p.light_stamper(annotation, threshold=15, timeout=6.)\n", " \n", " # Baseline\n", " sleep(2.)\n", " \n", " # Present stimulus\n", " white.draw()\n", " win.flip()\n", " core.wait(1.0)\n", " black.draw()\n", " win.flip()\n", " core.wait(6.0)\n", " \n", " # Close the window\n", " win.close()\n", " \n", " # Close PsychoPy\n", " core.quit()\n", " \n", "if __name__ == '__main__': \n", " try:\n", " main()\n", " except KeyboardInterrupt:\n", " print('Killed by user')\n", " sys.exit(0)\n", "``` " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Check out the PLR STLAB example for ideas on how to make an automated pupillometer with *PyPlr* and PsychoPy. Also, try comparing pupil responses to the red and blue channels of your monitor. You might just see a PIPR..." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.7" } }, "nbformat": 4, "nbformat_minor": 4 }