📖 Overview
lickcalc is a web-based application for analysing licking microstructure in rodent behavioural experiments. It processes timestamp data from licking events and provides detailed statistical analysis including:
- Session-level analysis: Overall licking patterns over time
- Microstructural analysis: Burst patterns, intraburst frequency, and lick durations
- Statistical modeling: Weibull distribution fitting for burst probability
- Data export: Excel exports with customizable data selection
The application is based on the lickcalc function from the trompy module. More details about installing trompy and using lickcalc to code lick microstructure can be found in the section, Using lickcalc without the app
🚀 Getting Started
Choose your data file format from the dropdown:
- Med Associates: For .txt files from Med-PC systems. Options for column and array based
- CSV/TXT: For comma-separated or tab-separated files
- DD Lab: For DD Lab specific format files
- KM Lab: For KM Lab specific format files
Upload your data file by either:
- Dragging and dropping the file onto the upload area
- Clicking "Select Files" to browse for your file
Select which columns contain your data:
- Onset Array: Column containing lick onset timestamps (required)
- Offset Array: Column containing lick offset timestamps (optional, for lick duration analysis)
Once your data are loaded:
- Adjust analysis parameters using the sliders
- View real-time updates in the graphs and statistics
- Export data to Excel for further analysis
- Add results to the results table
Customize default analysis parameters by uploading a configuration file:
- Create a YAML file with your preferred default values
- Download
custom_config_example.yamlto use as a template - Upload via the configuration section (top right)
- Settings will apply immediately and persist until app is reloaded/refreshed
📁 Supported File Formats
Text files from Med-PC systems with column format:
Text files from Med-PC systems with array format:
Comma or tab-separated files with columns:
Custom DD Lab format with specific parsing rules.
Download example fileCustom KM Lab format with specific parsing rules.
Download example fileExamples of each file format can be viewed and downloaded here or from the Github repository. If you need a custom format for your data please contact j.mccutcheon@uit.no.
📊 Session Analysis
Session Overview Graph
The session graph shows the overall pattern of licking throughout your experimental session. You can choose between two visualization modes:
Shows licks per time bin, allowing you to see periods of high and low licking activity.
Shows the cumulative number of licks over time, useful for seeing overall session progress.
Bin Size Control
Adjust the time bin size to change the temporal resolution of your analysis. Smaller bins show more detail but may be noisier.
Session Length
By default, the session length will be based on the length of the data. If you want a specific session length, you can set it here or by using a custom config file.
🔬 Microstructural Analysis
Burst Definition: A sequence of licks separated by intervals shorter than the interburst interval threshold.
Key Metrics:
- Number of Bursts: Total burst count in session
- Mean Licks per Burst: Average burst size
- Weibull Parameters: α and β parameters from probability distribution fitting
Definition: The frequency of licking within bursts, calculated from interlick intervals (ILIs) within bursts.
Typical Values:
- Normal range: 6-8 Hz
- Displayed as histogram of ILIs
Requirements: Both onset and offset data must be available.
Lick Lengths
- Histogram of individual lick durations
- Typically range from 50-200ms
- Longer licks may indicate suboptimal placement of sipper
Long Licks
- Licks exceeding the long lick threshold
- Count and maximum duration reported
- Can be excluded from analysis if desired
⚙️ Parameters Explained
🕐 Interburst Interval (IBI)
Typical range: 0.25 - 1.0 seconds
Default: 0.5 seconds
The minimum gap between licks that defines the end of one burst and the beginning of another. Shorter intervals = more bursts with fewer licks each.
📊 Minimum Licks per Burst
Typical range: 1 - 5 licks
Default: 3 licks
The minimum number of licks required to classify a sequence as a burst. Sequences with fewer licks are excluded from burst analysis.
⏱️ Long Lick Threshold
Typical range: 0.1 - 1.0 seconds
Default: 0.3 seconds
Licks longer than this duration are classified as "long licks" and indicate suboptimal sipper placement.
Remove Long Licks: Optional checkbox to exclude long licks from all analyses. When enabled, licks exceeding the threshold are filtered out. Requires offset data.
Customizing Default Settings
You can customize default analysis parameters by uploading a custom configuration file:
Available Settings:
- Microstructure parameters: Inter-burst interval, min licks per burst, long lick threshold, min bursts for Weibull analysis
- Session settings: Default length, length unit, figure type, bin size
- Output settings: Default animal ID
- Use YAML format (key: value pairs)
- Download
custom_config_example.yamlto use as a template - Upload via the config upload section in the app
💾 Data Export
Excel Export Options
Export your analysis results to Excel format with customizable data selection:
Available Data Types:
- Session Histogram Data: Time bins and lick counts
- Intraburst Frequency Data: ILI distributions
- Lick Lengths Data: Duration histograms (requires offset data)
- Burst Histogram Data: Burst size distributions
- Burst Probability Data: Weibull fitting data
- Burst Details Data: Individual burst information (start/end times, lick counts, etc.)
Export Features:
- Multiple Excel sheets per export
- Summary sheet with all key statistics
- Animal ID and timestamp tracking
- Source filename preservation
📋 Results Management
Analyzing Session Subdivisions
The app supports dividing your session into temporal or burst-based epochs for detailed analysis:
Analysis Epoch Options:
- Whole Session: Analyze entire session (default)
- Divide by 2/3/4: Split session into equal parts
- First n Bursts: Analyze only the first N bursts
- Between times: Analyze a specific time window (see below)
Division Methods:
- By Time: Split session into equal time intervals
- By Burst Number: Split based on burst count (e.g., first vs. last half of bursts)
Use Cases:
- Compare early vs. late session behavior
- Track learning or satiation effects over time
- Analyze acquisition phase (first N bursts only)
- Assess stability of licking patterns
Analyzing Specific Time Windows
The "Between times" option allows you to analyze licking behavior within a custom time range, providing flexibility for targeted analyses:
How to Use:
- Select "Between times" from the Analysis Epoch dropdown
- Enter your desired Start time (when to begin analysis)
- Enter your desired Stop time (when to end analysis)
- Select the time Unit (seconds, minutes, or hours)
- Click "Add Current Results to Table"
Common Use Cases:
- Baseline Period: Analyze initial behavior (e.g., 0-300s)
- Post-Treatment: Focus on a specific window after intervention
- Steady State: Skip initial adaptation period (e.g., 300-3600s)
- Comparison Windows: Analyze multiple specific periods separately
- Exclude Artifacts: Remove problematic time segments from analysis
Example Workflow:
To compare early vs. late session behavior using specific time windows:
- Load your data file
- Select "Between times" and enter 0 to 5 minutes for early session
- Click "Add Current Results to Table"
- Change times to 25 to 30 minutes for late session
- Click "Add Current Results to Table" again
- Both analyses will appear as separate rows for comparison
Results Summary Table
Collect and compare results from multiple analyses in an interactive table:
Table Features:
- Add Results: Add current analysis to comparison table
- Edit Cells: Modify Animal IDs and other editable fields
- Delete Rows: Remove unwanted entries
- Export Options: Export individual rows or full table
- Clear All: Remove all entries at once
Automatic Statistics:
When you have multiple entries, the table automatically calculates:
- Sum: Sum of values across all rows
- Mean: Average (mean) value across all rows
- SD: Standard deviation
- N: Sample size for each measure
- SE: Standard error of the mean
Processing Multiple Files at Once
The batch processing feature allows you to analyze multiple data files simultaneously using the same parameters, dramatically speeding up your workflow for large datasets.
How to Use Batch Processing:
- Set Parameters: Configure all analysis parameters (interburst interval, min burst size, etc.) in the main interface
- Choose Analysis Epoch: Select your desired epoch (whole session, divisions, first n bursts, or between times)
- Open Batch Modal: Click the "Batch Process Files" button at the top of the interface
- Upload Files: Drag and drop or click to select multiple data files (any supported format)
- Configure Export:
- Check "Export per-file Excel" to get individual Excel files for each data file
- Check "Include all sheets" to force export of all data sheets (histograms, bursts, etc.)
- Start Processing: Click "Start Batch Processing"
- Monitor Progress: Watch the progress indicator and status messages
- Download Results: When complete, download the ZIP file containing all results
Key Features:
- Unified Parameters: All files processed with the same settings
- Epoch Awareness: Respects your chosen analysis epoch (divisions, between times, etc.)
- Auto Offset Detection: Automatically identifies offset columns when available
- Progress Tracking: Visual feedback during processing
- Results Table: All results automatically added to the comparison table
- ZIP Export: Optional individual Excel files packaged in a convenient ZIP
- Full Data Sheets: Per-file Excel exports include all data sheets (same as single-file export)
Export Options Explained:
Results are added to the comparison table only. No individual files created. Use this for quick data collection when you plan to export the full table later.
Each data file gets its own Excel workbook (matching single-file export format) plus results in the comparison table. All Excel files are packaged in a ZIP. Use this when you need both individual detailed exports and a combined summary.
- Batch processing uses automatic offset detection. The app will search for appropriate offset columns based on naming patterns and validation rules.
- If a file cannot be processed (e.g., invalid format, missing data), an error will be reported but processing will continue for remaining files.
- When using "Between times" with batch processing, the same time window is applied to all files.
- Large batch jobs may take several minutes depending on file size and number of files.
Example Workflow:
Processing 20 experimental sessions with time-based divisions:
- Load one representative file and optimize your parameters
- Select "Divide by 4" and "By Time" to split each session into quarters
- Open the Batch Processing modal
- Upload all 20 data files
- Check "Export per-file Excel" for detailed per-subject records
- Click "Start Batch Processing"
- Wait for completion (progress bar will show X/20 files processed)
- Download the ZIP file containing 20 Excel workbooks
- Export the complete results table for statistical analysis (now containing 80 rows: 4 divisions × 20 subjects)
Advanced Batch Mode
Enable the toggle Advanced mode: select columns per file in the Batch modal to unlock per‑file controls and more flexible processing:
- Per‑file onset/offset multi‑selects: Choose one or more onset columns for each file. Offsets are optional; if none are selected, analysis runs on onset times only. Each chosen onset column yields its own row(s) based on the selected epoch (whole session, divisions, first n bursts, between times, or trial‑based).
- Automatic offset pairing: For each onset column, selected offsets are validated automatically (length difference ≤ 1, offset never before onset, and never after the next onset). Invalid pairs are skipped.
- Global selections: Use the Global selections card at the top to pick onset/offset columns once, then click Apply to all files. Only columns that exist in a given file are applied; missing ones are ignored.
- Trial‑based in batch: If the main epoch dropdown is set to Trial-based, the app auto‑detects trials using your minimum ITI and outputs one row per trial for each onset column. If no trials are detected, the whole session is treated as a single trial.
- Per‑file Excel export: When enabled, each file also gets a session‑level Excel workbook (same structure as single‑file export) packaged into a ZIP. Per‑epoch/per‑onset sheets are planned for a future update.
Trial-based is selected before launching the batch process.
📄 Advanced Use
Installing locally
Reasons to install locally include working offline, avoiding server outages, and enabling modification or customization. Follow these steps to install using Anaconda or Mamba:
- Clone the repository using git:
git clone https://github.com/uit-no/lickcalc.git
cd lickcalc
- Create and activate the environment:
conda env create -f environment.yml
conda activate lickcalc
- Run the app:
python app.py
- Open a browser and go to
localhost:8050
Using underpinning functions
The application is based on a utility included in the package trompy. It can be installed via pip and is hosted on Github at https://www.github.com/mccutcheonlab/trompy.
The function lickcalc calls a class, Lickcalc, and is documented fully in the parent package. trompy also includes the file parsers and some helper functions
Some example code using the function follows:
🔧 Troubleshooting
Solutions:
- Check file format matches selected type
- Ensure file is not corrupted
- Verify file contains numeric timestamp data
- Try a smaller test file first
Solutions:
- Ensure onset array is selected correctly
- Check that your data contains valid timestamps
- Try adjusting parameter sliders
- Refresh the browser page
Solutions:
- Ensure you have both onset and offset data
- Select proper offset array (not "None")
- Check that onset and offset arrays have matching lengths
- Verify offset timestamps are after onset timestamps
Solutions:
- Ensure data is loaded and analyzed first
- Select at least one data type for export
- Enter a valid Animal ID
- Check browser download settings
Cause: Insufficient number of bursts for statistical fitting
Solutions:
- Check if you have at least 10 bursts (default minimum threshold)
- Decrease the interburst interval to identify more bursts
- Decrease minimum licks per burst threshold
- Ensure your time window captures enough bursting behavior
- Adjust the minimum burst threshold in your config file if appropriate for your experiment
Cause: Browser caching of file uploads
Solutions:
- Change the file type dropdown before re-uploading (this triggers re-parsing)
- Upload a different file, then upload the original file again
- Refresh the browser page and upload again
Solutions:
- Ensure file is valid YAML format (check indentation with spaces, not tabs)
- Use the provided
custom_config_example.yamlas a template - Verify all parameter values are within valid ranges
- Check for typos in parameter names
- Ensure numeric values don't have quotes around them
📄 Theoretical and Practical Considerations
Historical background
Microstructural analysis was first described in Davis and Smith (1992) and has since then been used understand diverse phenomena. In-depth reviews on many of these, and microstructural parameters used to study them, are available (Johnson, 2018; Naneix et al., 2020; Smith, 2001). Briefly, although much of the foundational work on drinking microstruture was on licking for nutritive solutions (e.g., sucrose solutions), microstructural analysis can also be used to study intake of water (McKay & Daniels, 2013; Santollo et al., 2021), ethanol (Patwell et al., 2021), and other tastants such as non-caloric artificial sweeteners, sodium, and quinine (Lin et al., 2012; Spector & St. John, 1998; Verharen et al., 2019). Lick microstructure has been used to shed light on, for example, how licking is affected by neuropeptides (McKay & Daniels, 2013), enzymes in the mouth (Chometton et al., 2022), ovarian hormones (Santollo et al., 2021), nutrient restriction (Naneix et al., 2020), response to alcohol (Patwell et al., 2021), and diet (Johnson, 2012). The number of lick bouts over a session are thought to reflect postingestive feedback from the consumed fluid, wheras the number of licks in a bout are thought to reflect palatability of the solution.
Interpreting microstructure data
Lick microstructure can provide a great deal of interesting information about why an animal is drinking. Often, changes in microstructure are accompanied by changes in total intake, but this is not always the case: sometimes, equal intake will be achieved by quite different licking patterns that indicate changes in orosensory and postingestive feedback (Johnson et al., 2010; Volcko et al., 2020). Analyzing lick microstructure is therefore highly valuable in understanding how a manipulation affects appetite; if X causes an animal to feel more satiated after drinking, that may lead to a different interpretation than if X were to reduce the palatability of the solution.
Hardware considerations
Traditionally, researchers have used contact lickometers to detect individual licks. These generally pass a small amount of current through the animal and contacts with a (metal) spout cause completion of the circuit and lick detection. Recently, capacitive touch is more commonly used or deflections of a piezo or optic fibre. Several open-source lickometer designs are now available (e.g., Frie & Khokhar, 2024; Monfared et al., 2024; Petersen et al., 2024; Raymond et al., 2018; Silva et al., 2024).
Practical considerations: extended contacts
One problem that can arise are extended contacts with the spout, generally due to a fluid bridge forming between the animal's tongue and the spout. This can lead to very long "licks" that are in fact not individual licks but rather extended contacts. These can be prevented by ensuring that the sipper is recessed some distance from the wall of the chamber. To be sure that extended contacts do not affect the analysis, we recommend recording the offset time of each lick in addition to the onset time. In lickcalc, it is then possible to check for extended contacts and either adjust the behavioural setup (e.g., by moving the bottle back) or filter out extended contacts.
Setting up hardware to capture offsets
The instructions below refer to Med Associates hardware but the general principles can likely be transferred to other systems. First, in Med it is critical to adjust the jumper on the card so that the inputs from the lickometers are set to 'Level' mode rather than 'Toggle'. We then use state sets to track whether the tongue is in contact or not with the spout at all times but only write changes to this value to our data arrays. Example code can be downloaded from here and adapted as needed.
📚 Glossary
- Burst
- A sequence of licks separated by intervals shorter than the interburst interval threshold
- Interlick Interval (ILI)
- Time between consecutive lick onsets
- Intraburst Frequency
- Rate of licking within bursts, typically 6-8 Hz in rodents
- Interburst Interval (IBI)
- Minimum gap between licks that defines burst boundaries
- Long Lick
- Lick duration exceeding the long lick threshold, may indicate suboptimal sipper placement
- Onset
- Timestamp when tongue contact begins (required data)
- Offset
- Timestamp when tongue contact ends (optional, enables lick duration analysis)
- Weibull Distribution
- Statistical model used to fit burst size probability distributions (see Davis, 1998)
- Microstructure
- Fine-grained temporal patterns of licking behavior within and between bursts
- Session
- Complete behavioral recording period, analyzed for overall licking patterns