Skip to content

gklrajan/HT-LMD

Repository files navigation

DOI

HT-LMD: High-Throughput Learning, Memory, and Drug-Testing Platform for Small Aquatic Models

This repository contains all hardware and scripts for building and operating HT-LMD — a 3×3 behavioral platform designed for automated aversive conditioning in small animal models. The system is optimized for parallel delivery of visual stimuli (CS) and precise electric shocks (US), enabling studies in learning, memory, and pharmacological interventions.


Overview

HT-LMD integrates:

  • An Arduino-controlled shock delivery system
  • A modular 3×3 animal arena with shared row-wise shock control
  • Visual CS delivery through programmable LED indicators
  • A suite of MATLAB scripts for protocol control, trajectory tracking, cleaning, parameter extraction, and statistical evaluation

This platform is built for scalability, reproducibility, and compatibility with general-purpose overhead cameras and IR backlighting setups.


Arena Description

HT-LMD Arena

The bottom surface of the arena is made with transparent acrylic bottom screen and the upright acrylic at the borders is black. This way the floor acts as a whole field screen for projection from the bottom. This is done using a cold mirror. There is a whole field backlighting of infra-red light and the camera has a bandpass IR filter to image animal with a clean IR background without any interference from the visual stimulation. The IR-LEDs act as stimulus status indicators. The analysis script makes use of these indicators to know the stimulus status. This makes it a very flexible, plug-and-play system that can be used on any imaging setup easily.

The horizontal dividers where the electrodes connect are made with a thin sheet of aluminium (manufaturer: RS Pro (ES); RS Code: 434-043) cut to perfectly fit the gap.

HT-LMD arena dividers

The vertical dividers made using black acrylic is designed as a comb to directly sit on the metal plates. This keeps the electrical continuity while blocking the adjacent animal from each other.

HT-LMD arena dividers

Circuit Description

The core of the shock system is an Arduino Uno that controls a TIP120 NPN Darlington transistor as a low-side switch. Digital output pin 7 triggers the shock via the transistor. Five additional pins are used to control LEDs that indicate stimulus status for each arena column.

  • Shock voltage: 12 V DC
  • Controlled by: Digital pin 7 (no Arduino loop — triggered externally)
  • Indicator LEDs: Digital pins 9–12 (for CS/non-CS display synchronization)

HT-LMD Shock Circuit

(simulated on AUTODESK Tinkercad)

Electrical Characteristics

Water Resistivity Calculation

The resistance of each water-filled row is determined by its geometry and the conductivity of the medium. We use approximate dimensions to do the calculations here. The idea is to communicte the rationale so that it can be easily adapted to any setup.

We begin by converting conductivity (σ) to resistivity (ρ) using typical water conductivity levels used (change as per your aquarium's water conductivity):

σ = 350 μS/cm = 350 × 10⁻⁶ S/cm
ρ = 1 / σ = 1 / (350 × 10⁻⁶) Ω·cm ≈ 2857.14 Ω·cm

Arena Geometry

  • Electrode gap (L): 4 cm
  • Water depth: 0.5 cm
  • Electrode width: 18 cm
  • Cross-sectional area (A):

A = 18 cm × 0.5 cm = 9 cm²

Resistance Per Row

R = ρ × (L / A)
= 2857.14 Ω·cm × (4 cm / 9 cm²)
≈ 1269 Ω

Parallel Resistance of 3 Rows

Since the 3 water-filled rows are electrically in parallel:

R_total = R / 3 = 1269 Ω / 3 ≈ 423 Ω

Shock Current and Electric Field

Given a measured shock voltage of 11.3 V across the water rails:

  • Current per row:
    I_row = V / R = 11.3 V / 1269 Ω ≈ 8.9 mA

  • Total current across all 3 rows:
    I_total = 3 × I_row = 3 × 8.9 mA ≈ 26.7 mA

  • Electric field strength:
    E = V / d = 11.3 V / 4 cm = 2.825 V/cm

This electric field is strong enough to reliably serve as the unconditioned stimulus (US) for small aquatic animal models.

Note on Darlington transistor

The TIP120 Darlington transistor used in HT-LMD's shock delivery circuit may allow a small collector–emitter leakage current even when nominally OFF. This leakage can result in a weak voltage across the water rails — typically observed when no proper load is present.

In HT-LMD, this is mitigated by design: the three parallel water-filled channels act as a passive drain resistance (~423 Ω total), naturally sinking any leakage current and clamping the voltage across the tank in the OFF state. The resulting electric field is typically very low across the 4 cm tank — far below any behavioral significance. This makes the system safe and silent during inter-trial periods, without requiring additional hardware.

For more electrically sensitive models, or where OFF-state electric silence is critical, you may optionally add an additional external pull-down resistor (e.g., 470–1000 Ω) in parallel across the shock electrodes to further reduce any residual voltage to zero. This passive suppression mechanism is often sufficient and avoids the need for mechanical relays or complex switching systems which are of course also an option if needed.


Experimental Setup

Each of the 3 rows in the 3×3 arena is connected to a shared shock rail system. The columns are separated optically using acrylic dividers. LED indicators above each arena show the CS condition (checkerboard) and control for experimental alignment.

  • Row-based shock: All 3 rows receive the US simultaneously
  • Shock duration: 100 ms, precisely triggered by the MATLAB control script

Firmware Behavior

The Arduino does not run an internal loop. All digital pin changes (for both shock and LEDs) are handled via serial communication from MATLAB.

Pin assignments:

Pin Function
D09 LED indicator — CS1
D10 LED indicator — CS2
D11 LED indicator — CS full field
D12 LED indicator — US
D07 Shock trigger (connected to TIP120 base via 240 Ω)

All state transitions are coordinated through A01_fullProtocol_classicalCond.m.


Repository Contents

File Overview

Script Description
A00_initialCalib.m Calibration script for visual and electrical stimulation. Used to: (1) locate arena midlines, (2) check LED alignment, (3) verify delay between LED and US.
A01_fullProtocol_classicalCon.m Main experimental control script for training, testing, reversal, and extinction protocols using Psychtoolbox and Arduino-triggered LEDs/shock.
B01_getTraj.m Trajectory extraction from .avi files. Uses blob detection to track centroid per arena.
B02_calAllParams.m Computes key behavioral metrics such as speed, normalized X/Y, midpoint crossings, and performance index.
B03_cleanData.m Filters the data to retain only those animals that have both pre and post trials for valid statistical comparison.
B04_stats.m Performs t-tests between groups (t1 vs c1) across d1, d2, and d3 post-trials. Plots results with scatter and SEM bars.
Z01_postHocCoordFlipping.m Post-hoc flipping of X-coordinates to account for stimulus inversion during the experiment (if flipping wasn’t corrected during processing).

Behavioral Protocols

The core experimental script (A01_fullProtocol_classicalCon.m) supports the following:

  • Full classical conditioning (train/test): bias check + training with shock + test.
  • Test-only: assess learning/memory without training.
  • Extinction: repeated exposure to CS without shock.
  • Reverse learning: flips visual cues to test re-learning.

Major Editable Parameters:

  • protocol'train', 'test', 'reverse', or 'extinction'
  • biasTime, shock, isi, trials → experiment duration, shock intensity/timing
  • screenNumber, BGFullImage, csHalfImage → stimulus configuration

All stimulus logic is handled via Psychtoolbox on a specified screen and synchronized with Arduino-triggered LEDs and shock circuits. The stimulus images itself might need some simple dimension adjustments based on the thickness of vertical and horizontal dividers used and the resolution of the screen projection used. These adjustments ensure that visual cues align accurately with the physical layout of each chamber and are perceived consistently by the animal across trials.

Parameters Computed (via B02_calAllParams.m)

  • Position: Raw and normalized X_mm, Y_mm
  • Speed: Instantaneous and smoothed speed_mmps
  • Midpoint Crossings: Frequency of transitions across the midline
  • Performance Index: Binary index reflecting zone preference
  • Binned Data: All metrics are binned (10s or 30s bins) for trial-level summary

Cleaning and Quality Control (B03_cleanData.m)

Removes:

  • ROIs with zero tracking (no valid position data)
  • Entries without both pre and post phase data (per group/day/ROI)

Statistical Analysis (B04_stats.m)

  • Compares test group (t1) vs control group (c1) for days d1, d2, and d3 (post-phase only).
  • Uses two-sample t-tests
  • Plots group-wise means ± SEM, overlaid with scatter of individual ROIs
  • Outputs p-values directly on plot

Post-hoc Correction (Z01_postHocCoordFlipping.m)

If stimulus was flipped during the experiment but not during trajectory extraction, this script mirrors X coordinates for the time windows when the flip occurred.

  • Requires cs2_start_idx, arena centers, and raw coords.
  • Can be used independently of getTraj to retroactively fix data.

Modularity and Extensibility

While this repository provides a working pipeline end-to-end, it is designed to be modular and easily extensible:

  • Trajectory Extraction: B01_getTraj.m uses basic blob detection to extract centroids. You may replace or augment this with:

    • DeepLabCut
    • YOLO-based tracking
    • IDtracker
    • SLEAP
      if your camera resolution and training datasets support it.
  • Analysis: Beyond the default parameters, you can compute:

    • Path entropy, turning angles, exploration metrics
    • Hidden Markov Models (HMMs) for state segmentation
    • ML/DL models for behavior classification
  • Stats: Current t-tests can be extended to:

    • ANOVA, mixed-effects models
    • Longitudinal tracking
    • Unsupervised clustering or PCA on behavior vectors

Just plug in your preferred toolkits — MATLAB, Python, R — using the extracted coordinates as input.

Output

All cleaned data are saved to:

processedAnimalData.mat
cleanedAnimalData.mat

These files contain:

  • All metadata (day, group, phase, roi)
  • All computed metrics
  • Ready for downstream statistical or machine learning analyses.

Biological Relevance

This platform is designed to offer a versatile and scalable assay system for probing a wide range of cognitive and behavioral phenomena in small aquatic models such as Danionella or zebrafish. Below are three representative use cases demonstrating the biological significance of the HT-LMD framework:

Learning and Memory Assays with Customizable Stimuli

HT-LMD supports classical conditioning paradigms in which animals learn to associate specific visual cues (conditioned stimuli or CS) with reinforcement (e.g., mild shock or illumination). The system provides customizable stimulus templates (e.g., lnm_stim) that can be easily modified to suit experimental needs, including spatial patterns, textures, or colors.

Moreover, the same infrastructure supports binary or multi-choice preference assays, such as evaluating innate color preference using templates like those in the colorPref_stim folder. Simply switch off the shocker module and use the setup for preference evaluation. Below is example of such evaluation. This is based on a non-trained, naive group of animals, demonstrating spontaneous, unbiased behavior when exposed to symmetric visual stimuli.

kinematics

Note: Any experiment involving reinforcement learning protocols or aversive stimuli (e.g., electric shock) must adhere to institutional and national guidelines for animal research. Appropriate ethical permissions should be obtained prior to conducting such assays.

Drug Testing and Visual Response Assays in Freely Swimming Animals

The system allows for high-throughput evaluation of pharmacological interventions in freely swimming fish across multiple arenas. Effects of such interventions can be tested on spontaenous behavior as well as on learning and memory.

In addition, HT-LMD is compatible with a wide variety of dynamic stimuli including:

  • Looming objects
  • Moving dot fields
  • Temporally modulated light patterns
  • Naturalistic motion cues

The below example showcases a simple evaluation of kinematics in a group of animals (n=9) with various treamtments -- which here corresponds to simply differing background colors. Such an approach enables studies on drug testing, visual salience, threat detection, and sensory integration, particularly in adult or juvenile animals.

variousTests

Note: Any experiment involving drug-testing must adhere to institutional and national guidelines for animal research. Appropriate ethical permissions should be obtained prior to conducting such assays.

Social Behavior and Group Dynamics with Expandable Arena Layouts

By removing or adjusting the vertical dividers (the "comb" structure that creates individual arenas), the physical space can be expanded into a larger continuous arena, allowing controlled group-size manipulations. Such a modification supports:

  • Social preference assays (e.g., one-vs-many conspecific choice)
  • Shoaling and schooling measurements
  • Group-size-dependent behavioral modulation
  • Social learning or contagion studies

tracking_example

Because of the modular arena structure and the open-source tracking pipeline, HT-LMD can be readily adapted to test social behavior in group settings, with precise control over group composition and arena geometry.

These use cases highlight the flexibility and biological breadth of the HT-LMD platform — from individual learning to collective dynamics — empowering researchers to explore cognition, pharmacology, and ethology in aquatic model organisms with scalable precision.


Protocol Notes

  • Fill water to 5 mm height in all arenas
  • Confirm conductivity is 350 μS/cm prior to each session
  • Use identical electrode geometry for reproducibility
  • The CS and US timing is synchronized through MATLAB
  • LEDs provide visible feedback on stimulus delivery, enabling plug-and-play deployment with standard top-down video cameras

Safety and Calibration

  • Shock duration and amplitude should be verified with an oscilloscope
  • No current flows through the animal body; current passes around the body through conductive water
  • Ensure proper grounding of Arduino, 12 V supply, and electrode rails
  • Do not leave power applied when electrodes are dry or disconnected

DISCLAIMER

Ethical Compliance Notice

All experiments described in this repository — including behavioral assays, reinforcement protocols, and drug or stimulus exposures — must be conducted in strict accordance with applicable institutional animal care and use guidelines, as well as national and international laws governing the ethical treatment of animals in research.

Prior to implementation, all procedures should be reviewed and approved by the relevant Institutional Animal Ethics Committee (IAEC), Institutional Review Board (IRB), or equivalent regulatory body. This includes, but is not limited to:

  • Use of electrical shock or visual reinforcement
  • Surgical or pharmacological interventions
  • Protocols involving stress, learning, or conditioning
  • Modifications to arena structure or social housing

The authors of this repository assume no responsibility for unauthorized or unethical use of the tools and protocols provided herein. Users are solely responsible for ensuring that all experimental work complies with the ethical standards of their home institution and jurisdiction.


Author

Developed by Gokul Rajan. Orger Lab, Champalimaud Foundation.


Citation

Rajan, G. (2025). HT-LMD: High-Throughput Learning, Memory, and Drug-Testing Platform for Small Aquatic Models (v1.0.0). Zenodo. https://doi.org/10.5281/zenodo.17162479


Acknowledgement

This was developed at the Champalimaud Foundation (CF) in the Vision to Action Laboratory of Michael B. Orger.


License

HT-LMD is licensed under the GNU General Public License v3.0.
See the LICENSE file for details.

About

High-Throughput Learning, Memory, and Drug-Testing Platform for Small Aquatic Models

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages