View on GitHub

Pupillometry

Self-assembly and user's guide for a cheap and lightweight pupillometry setup

Usage of the camera guided user interface (GUI)

Introduction

This is a guide to the graphical user interface (GUI) installed to ‘/home/pi/Code/pupillometry-raspi/’. The GUI lets you control the camera without having to issue any commands via command line. The following steps will show you how to use CamGUI.py with its various optional parameters.

Basic instructions

In order for the camera GUI to start, both the camera and the BrightPi need to be connected to the raspberry (see the assembly guide for more information on how to get set up). When everything is connected properly, the GUI is started by typing the following in a terminal window.

# Start CamGUI.py from its folder
python /home/pi/Code/pupillometry-raspi/CamGUI.py

GUI controls

Simple recording

Because of the way Raspbian overlays the live video feed with the screen, it can happen that the GUI window is covered by the video feed. In that case, press CTRL + c to terminate the GUI.

For a simple recording, start CamGUI.py with the above command and press “Start Preview”. Now adjust camera position and focus. If you want to see video on the screen during your recording, simply leave the preview on and press “Start Recording”. The camera will now record to the directory shown in terminal until “Stop Recording” is pressed. The default filename is constructed from the date and time of the recording. You can also specify a custom location and name to store the video in the “File name” dialog box or via the “Browse…” button.

Timed recording

If you want the recording to run for a specified amount of time, enter the time in seconds into the dialogue box. Open the preview and press “Start Recording”. A timer showing the remaining time will be displayed in the terminal window from which CamGUI.py was started. The recording will stop automatically after the specified amount of time.

Optional parameters

CamGUI.py can be started with optional parameters in the following format, without the brackets.

# Start CamGUI.py with optional parameters
python /home/pi/Code/pupillometry-raspi/CamGUI.py --[PARAMETER] [VALUE]

# Example with a larger video preview window
python /home/pi/Code/pupillometry-raspi/CamGUI.py --prevsize 700

# Example with large preview and low frame rate
python /home/pi/Code/pupillometry-raspi/CamGUI.py --prevsize 700 --framerate 5

Valid parameters are:

External triggering

CamGUI.py can accept external triggers on pin 40 (GPIO 21), or any other GPIO specified with --trigger_pin. When the appropriate box is ticked and once “Start Recording” is pressed, CamGUI.py will wait for the time specified with --timeout (default = 20 seconds) for the trigger to arrive, i.e. the pin to be pulled low. See below for an example with a push button between GND and GPIO21.

External triggering is also an easy way to synchronize recordings from two or more pupillometry setups. For example when simultaneously recording both eyes, or monitoring the breathing rate.

Start CamGUI.py via an executable

CamGUI.py can also be started from an executable file placed on the desktop, for example. Follow below steps to create such a file.

# Open an editor via terminal
sudo nano /home/pi/Desktop/start_camera.sh

Then enter the following lines. Add optional parameters as needed.

#!/bin/sh
python /home/pi/Code/pupillometry-raspi/CamGUI.py

Type CTRL + o to save and CTRL + x to exit. Now, run the below command to make the file executable.

sudo chmod +x /home/pi/Desktop/start_camera.sh

Home