Skip to content

What are NI sessions objects?

Axel edited this page Oct 23, 2024 · 2 revisions

About Sessions

The function defining_sessions.m create session objects for configuring and operating data acquisition devices from (here) National Instrument. Documentation about the interface can be found in the MATLAB documentation directly.

Important note ⚠️: the Session interface will become deprecated/unsupported at some point in the future, MATLAB is therefore pushing users to update to the DataAcquisition interface. We haven't made that move yet.

Main goals of defining_sessions

  1. Global variable definition and initialization

    • Purpose: Declares and initializes all necessary global variables that are used throughout the data acquisition sessions e.g. session_start_time, trial_start_time
    • Key Actions:
      • Sets up global variables for rewards, stimuli, logging, session parameters, counters, and data buffers.
      • Initializes variables for continuous plotting of the different data streams
      • Create output folder for current behavioural session
  2. Sampling rate configuration

    • Purpose: Defines the sampling rates for various data acquisition sessions.
    • Key Actions:
      • Sets sampling rates for main control, stimuli, rewards, triggers, and logging sessions.
      • Configures frame rates and other frequency-related settings for camera and stimulus operations.
  3. Data acquisition (DAQ) Session creation

    • Purpose: Establishes multiple DAQ sessions tailored for different aspects of the experiment, such as control, logging, triggering, rewarding, and stimulus generation. All outputs, inputs, triggers must be correctly specified as per the setup. The standard connectic is that of present in the default GUI script. The general rule is to adapt the setup to this, and not the contrary.

    • Main Sessions:

      • Main Control Session (Main_S): Handles primary data inputs and triggers callbacks for controlling the experiment flow.

      • Logging Session (Log_S): Captures and logs multiple input channels (e.g., lick sensors, scanner positions, TTL signals) continuously. This session saves the data in log_continuous.bin, the content of which should follow the standard in the lab with:

        • ai0: lick sensor data
        • ai1: galvo scanner position for imaging
        • ai2: trial start TTLs
        • ai3: camera 1 exposure times
        • ai4: camera 2 exposure times
        • ai5: context transition TTLs
      • Trigger Session (Trigger_S): Manages digital outputs for initiating stimuli, valve opening.

      • Reward Session (Reward_S): Controls the delivery of rewards based on experimental triggers and conditions.

      • Stimulus Session (Stim_S): Generates and sends analog and digital stimuli (e.g., auditory tones, whisker stimulations) to the experimental setup.

      • Camera Session (Camera_S): Configures continuous video filming parameters for behavior cameras, including frame rate, exposure times, camera start delay.

      • Context Session (Context_S): Context transitions for context tasks.

    • Conditional & specialized Sessions

      • Optogenetics Setup (opto_setup): Initializes Opto_S session and setting for optogenetic manipulations if enabled.
      • WF Imaging Setup (wf_setup and wf_imaging_continuous): Configures and starts wide-field imaging WF_S session, handling both continuous and triggered recording modes.
      • See dedicated scripts for more information.
  4. After session creation and execution

  • Once all sessions are created, key global variables are initialized.
  • Session parameters are updated in the GUI with update_parameters.m
  • Acquisition starts, which will call main_control.m

Summary

  • This function sets up up and initializes various data acquisition sessions required for running behavioural experiments / elicit stimuli to the mouse. It handles:
  • Global variable management: Ensuring all necessary variables are accessible across different functions and sessions.
  • DAQ Session configuration: Creating and configuring multiple sessions tailored for specific tasks like control, logging, triggering, rewarding, and stimulus generation. This can also be conditional for more specific experimental needs such as optogenetics or imaging. (Note: imaging can be incorporated as a session here because the sampling rate is lower than for the behaviour and therefore it can be encapsulated here - unlike ephys.)
  • In theory, there is no need to create new sessions at this point as the present here should handle everything.