This is the Graphical User Interface for controlling the Olfactometer System over the Computer.
We have divided the main window using smaller frames. To enhance the visual separation between the different control frames, we used various background colors.
Experimental Control
In this frame, the user can set the Parameters of the experiment. These include the names of the three odors, the name of the mouse and specifying the name of the protocol used for the experiment. There is also the option to import a previous protocol by clicking on the “Previous Setup” button. The “Save” button allows saving these Parameters in an excel file to a location on the server the user chooses.
Moreover, there is the “Status:” function providing information about the experiment and the “Progress” bar, that will turn from grey to green depending on the progress of the experimental run.
Manual Control
The manual control frame allows for the user to choose the mode in which the olfactometer should run (“Resting”, “Purge”, “Odor 1”, “Odor 2”, “Odor 3”). It also lets the user choose the duration of the selected mode. If the user wishes to run a new set of experimental runs, the “Reset history”-button can be pressed to delete the history. While the “Run”-button will start the experiment, the “Purge and Stop”-button will immediately stop the odor delivery, followed by a 10 second purging mode.
Excel Control
This frame contains an “Add file”-button which, when clicked, will let the user choose an excel file with an experimental setup from the local repository. The “Run file”-button will immediately start running the experiment from the excel file.
Valve Setup
In this section, the user finds an overview of all valves in the olfactometer. Open valves are represented by green circles, while red circles represent closed valves. depending on themode selected on the “Manual Control”-frame, the valves will change their color according to the chosen setup to help the user understand the olfactometer configuration for the chosen mode.
Water Control
In this frame, the user is asked to choose a mode (“Odor 1”, “Odor 2”, “Odor 3”, “None”) to be coupled to water release. When the chosen odor is delivered, the water valve will be opened and the mouse will have access to water during the mode.
Plot Experiment
While the experiment is running, the modes will be plotted against their duration in this frame. That way, the user can visually follow the progress of the experiment.
Miniscope Feedback and Camera Feedback
These frames provide feedback over whether or not a miniscope and camera have been detected by the system.
Cracking the Code: What's Behind this GUI?
Delving into the intricacies of our implementation process, we owe credit to the preceding team whose foundational work provided a robust framework. Leveraging their prior efforts, we retrieved the requisite co
debase from our GitHub repository, accessible via the following link: GitHub Link.
app.py
Serving as the cornerstone, this Python script orchestrates the creation of a GUI application for olfactometer control using the tkinter library. It embodies the MVC paradigm, wherein the Olfactometer class governs device functionality, the View class oversees GUI presentation, and the Controller class acts as the intermediary. The script initialises and interconnects these components, subsequently initiating the event loop to sustain GUI functionality.
controller.py
This module encapsulates a Controller class tasked with managing interactions between the GUI (View) and the underlying device model (Olfactometer). It encompasses methods facilitating experimental mode activation, experiment loading from files, experiment execution, status retrieval, progress monitoring, and post-experiment cleanup.
experiment.py
Implemented in Python and leveraging tkinter and matplotlib for data visualization, this script generates bar charts depicting programming language popularity. Additionally, it updates a CSV file with simulated data reflecting pin states over time.
model.py
Central to the system, this Python file defines the Olfactometer class, facilitating communication with Arduino boards for component control. It initialises pins, configures experiment parameters, and furnishes methods for experiment execution, mode configuration, and pin status retrieval.
modes.py
This module introduces an enumeration, 'Modes', employing the enum module to delineate various system operation modes. Notably, it defines constants, 'CLOSE' and 'OPEN', signifying pin states. Each mode comprises a tuple specifying valve configurations, encompassing Resting, Purging, and distinct Odor modes.
view.py
Herein lies the graphical user interface (GUI) responsible for administering olfactometer experiments, as detailed above.
water.py
This Python script features a 'Bottle' class engineered to interface with Arduino boards, facilitating water dispensation control through the pyfirmata library. Functionality includes mode and duration configuration, pin initialization, and status retrieval. Additionally, 'open_water_valve()' is included, likely serving as a conduit for interaction with the graphical user interface or other system components.
water_modes.py
Finally, this script introduces an enumeration class, 'Water', employing the enum module to delineate states pertinent to water dispensation. It encompasses 'NO_WATER' and 'WATER' states, corresponding to 'CLOSE' (with a value of 1) and 'OPEN' (with a value of 0), respectively, likely serving as pivotal indicators for governing water flow within the system.
Ready, set, go! How to start the program:
To operate the olfactometer through the graphical user interface (GUI), follow these steps:
Import our GitHub repository to your local GitHub program on your computer by accessing the repository via the provided link.
Connect the olfactometer's power supply and then plug the Arduino into your computer's USB port. Ensure the port in the codes conforms the arduino's port. (If you change the arduino, the port might change. You can check the port with the Arduino IDE program.)
Open the Anaconda prompt and navigate to the folder where your olfactometer code is saved by using the "cd" command followed by the folder's path.
Once in the appropriate directory, execute the command "python app.py" to run the app.py file, which will initiate the GUI. Through the GUI, you can effectively manage and control the olfactometer.