AllenNeuralDynamics / dynamic-foraging-task

Bonsai/Harp workflow for Dynamic Foraging with Python GUI for visualization and control
MIT License
5 stars 4 forks source link

Dynamic Foraging Task

A Bonsai workflow for lick-based foraging experiments, with a PyQt frontend for visualizing performance and modifying task parameters.

Table of contents

Prerequisites

Operating system

Deployment

For initial installation:

To launch the software:

Automatic Updates

To configure automatic updates consistent with the update protocol,please use TaskScheduler to automatically run three batch files at specified times of the week (instructions)

Block Diagram

image

User Manual

GUI-screenshot

Menu

File

Toolbars

(copy of some of the useful functions from the menu)

Training Parameters

Animal/task/tower information

Trial-related parameters

Automatic training

  1. In the main dialog, press Auto Train button or Ctrl + Alt + A to open the Automatic Training dialog

    [!IMPORTANT] If the dialog fails to open, check AWS credentials at ~/.aws/credentials. See instructions

  2. For the first session of a new mouse:

    1. So far, the automatic training system cannot handle our previous Stage 1.1 --> Stage 1.2.
    2. Confirm that this is a new mouse in the automatic training system

    3. In "Curriculum Manager", select a desired curriculum for the new mouse. Double-check curriculum_name, curriculum_version, and curriculum_schema_version.


    4. (Optional) Click buttons to see interative diagrams in browser
    5. Click Set curriculum button to confirm
    6. Now a new entry with session = 0 is added in Training history, and STAGE_1_WARMUP of the selected curriculum is suggested by default.


  3. For a mouse that already started training

    1. Its training history and curriculum is automatically loaded
    2. (Optional) Uncheck show this mouse only to see training history from all mice
    3. (Optional) Press Show auto-training history in Streamlit to open the Streamlit app showing all training history in browser
  4. Apply and lock training parameters

    1. Check the curriculum name and stage name shown on the huge green button

    2. (Optional) Toggle the "Preview changes" to preview/revert the parameters that will be changed by the currently chosen stage. image

    3. Press the button to apply and lock all curriculum-controlled training parameters in the main GUI (including the "Task").

    4. Note that you can still modify some items in Training parameters, such as Valve open time, Give left/right, and Next block.

    5. You could now close the Auto Training dialog.

    6. Start the training as usual.

  5. Override parameters (not recommended)

    1. Once Apply and lock is pressed, you can press it again to unlock the parameters and override any of them. But in this case, the automatic training mode is disengaged, and this session is considered "off-curriculum".
      image
  6. Override stage (not recommended)

    1. Check Override stage to override the suggested stage. In the example below, STAGE_FINAL is suggested, but STAGE_3 will be actually used (see the green button).
  7. Override curriculum (not recommended)

    1. If you somehow decide to change the curriculum during training, press Override curriculum and set a new curriculum.
    2. In this case, since all stages from the old curriculum now become "irrelevant", you should always manually select a stage in the new curriculum to override.

Water Calibration

(Your content here)

Laser Calibration

(Your content here)

Optogenetics

(Your content here)

Camera

(Your content here)

Motor Stage

(Your content here)

Data Format

Data for each session is saved as a JSON file with the following files:

Behavioral events and timestamps

Training paramters

Here is an overview of the trial structure using a rewarded trial, an unrewarded trial, and an ignored trial as examples. image

Behavior structure

Developer Instructions

The user interface of the GUI was designed based on Qt-designer (introduction available here).

Update Protocol

Add a widget

Create a dialogue

Add a new task

If the new task structure is similar to the current foraging workflow, we can change the dynamic-foraging-task\src\foraging_gui\MyFunctions\GenerateTrials to add a new task. Otherwise, the Bonsai workflow will need to be updated as well.