User-defined task #1
In this instruction, OperantHouse0.927_Tutorial.py is used as a skeleton program. You are going to add cords to implement new tasks by following the following instructions. The code after the tutorial is OperantHouse0.927_Tutorial_final.py.
OperantHouse allows you to modify existing tasks or create your own original tasks if you know the basics of Python programming.
Here, I will explain the code of the simplest conditioning task (Task 90) where single panel touching is rewarded as water access. Then I’ll show how to make it more complex and versatile task by adding codes. Throughout this process, you can learn how the OperantHouse’s codes work and how to custom it.
Raspi is not a good environment for the coding because of its low performance, here I’ll explain the case of using Windows PC.
First, install Anaconda3 and PyCharm for the programming environment. After those installations, specify Anaconda's python.exe in PyCharm (File -> Setting -> Project:*** -> Project Interpreter).
Next, connect the Arduino and camera of the OperantHouse and PC through USB cable.
Open OperantHouse*.py in the PyCharm. You’ll see its code in the right space. This is a main code of the OperantHouse but you don’t need to understand all of them.
We have to change the code a little bit to run in windows. Find “General setting” codes.
#========General setting====================================================================================
RaspberryMode = 0 # 0:PC mode, 1:Raspberry mode
Assign “0” to “RaspberryMode” variable to run the program as windows mode.
SingleMonitorMode = 0 # If 1, the windows arranged for single monitor operation
Set to “0” if your monitor workspace is more than 2500 pixels wide to show the main window and touch window side-by-side. Otherwise set to “1” to show the touchwindow over the main window.
IsHousingAnalysis = 1 # If housing analysis is working, the value = 1, otherwise = 0
If this number is “1”, the ceiling light will automatically turn on and off according to the time set in the setting.
TouchDetectSensorType = 0 # 0:Detect with camera 1:Detect with mouse cursor(for PC & airbar)
1If “0”, the camera detects panel nose poking. If “1”, the program uses IR sensor bar to detect panel touching.
if RaspberryMode==0:
PortName='COM4' # You can check this port name through device manager
Enter the port number for Arduino connection here. If you don't know the number, you can find it in the device manager. You can open device manager as followed,
Control panel → View by Large icons → Device manager → Port(COM & LPT) → Arduino UNO(COM*)
Assign “COM*” to the “PortName” variable.
CameraID=0 # This value is used for starting recording with opencv (If there is only 1 camera, assign 0. If miniscope is connected, assign 1)
You can indicate which camera you want to use. When multiple cameras are connected to the PC (including the built-in camera), each camera is numbered as 0,1,2.... If you don’t know which ID is assigned to the USB camera, leave it at 0 for now.
Now let's start OperantHouse. Right-click on the Programs tab and select Run (you can also rename the file here).
このように画面が出てくれば成功です。
The task 90 is provided for learning purposes and you will modify it in the following instruction. Please check out how this task works here.
Once you understand the task, click the “Exit” button to end the program.