Skip to content

Example MATLAB Workbooks for Offline Analysis

These examples assume you downloaded our example data sets and extracted them into the TDTMatlabSDK\Examples directory.

TDT Examples

Averaging Example

Averaging Example

Import stream and epoc data into MATLAB using TDTbin2mat.

Plot the average waveform around the epoc event.

Good for Evoked Potential detection.

LFP Plot Example

LFP Plot Example

Import streaming LFP data into MATLAB using TDTbin2mat.

Plot the power spectrum and RMS of the waveform.

Good for sleep scoring and behavioral discrimination.

Note Filter Example

Note Filter Example

Import streaming EEG data into MATLAB using TDTbin2mat

Filter around behavioral events that were timestamped by the user using the Run-time Notes feature in Synapse.

Plot each occurrence in a subplot organized by Note type.

Good for sleep scoring and behavioral discrimination.

Raster Peristimulus Time Histogram (PSTH) Example

Raster Peristimulus Time Histogram (PSTH) Example

Import snippet and epoc data into MATLAB using TDTbin2mat.

Generate peristimulus raster and histogram plots over all trials.

Good for stim-response experiments, such as optogenetic or electrical stimulation.

Filter and Threshold Raw Data Into Snippets

Filter and Threshold Raw Data Into Snippets

Import raw streaming data into MATLAB using TDTbin2mat.

Digitally filter the single unit data using TDTdigitalfilter.

Threshold and extract snippets using TDTthresh.

Snippet Plot Example

Snippet Plot Example

Import snippet data into MATLAB using TDTbin2mat.

Sort snippets based on channel number and sort code for any number of channels and sort codes.

Plot the average waveform shape and standard deviation for 16 channels and three sort codes.

Good for spike sorting and first-pass visualization of sorted waveforms.

Stream Plot Example

Stream Plot Example

Import continuous data into MATLAB using TDTbin2mat.

Plot a single channel of data with various filtering schemes.

Good for first-pass visualization of streamed data.

Export Continuous Data to Binary File

Export Continuous Data to Binary File

Import continuous data into MATLAB using TDTbin2mat.

Export the data to a binary file (f32 floating point or 16-bit integer).

Channels are interlaced in the final output file.

Good for exporting to other data analysis applications.

TDT Community Examples

Fiber Photometry Epoch Averaging Example

Fiber Photometry Epoch Averaging Example

This example goes through fiber photometry analysis using techniques such as data smoothing, bleach detrending, and z-score analysis. The epoch averaging was done using TDTfilter.

Author Contributions:
TDT, David Root, and the Morales Lab contributed to the writing and/or conceptualization of the code.
The signal processing pipeline was inspired by the workflow developed by David Barker et al. (2017) for the Morales Lab.
The data used in the example were provided by David Root.

Author Information:
David H. Root
Assistant Professor
Department of Psychology & Neuroscience
University of Colorado, Boulder
Lab Website: https://www.root-lab.org
david.root@colorado.edu

About the authors:
The Root lab and Morales lab investigate the neurobiology of reward, aversion, addiction, and depression.

TDT edits all user submissions in coordination with the contributing author(s) prior to publishing.

Licking Bout Epoc Filtering

Licking Bout Epoc Filtering

This example looks at fiber photometry data in the VTA where subjects are provided sucrose water after a fasting period.

Lick events are captured as TTL pulses. Objective is to combine many consecutive licking events into a single event based on time difference and lick count thresholds.

New lick bout events can then be used for clear peri-event filtering.

We think that cultivating a strong and open community of TDT users is essential for maximizing research efficiency. The cross-pollination of ideas and methods across labs, especially those with similar research interests and using the same equipment, makes the science more rigorous overall. As such, we would like YOU to consider contributing to the TDT community with an example analysis and workbook, like the ones at the top of this page.

You can submit your examples to TDT by emailing support@tdt.com. Include your name, lab information, research interests, MATLAB script, and a link to the block of data used in the analysis. Accepted submissions will be featured on this webpage, along with a description of the analysis and a bio of the submitting researcher. We hope that this exposure will help our users learn more about what great research others in the TDT community are doing!

Please note that, as with all our example workbooks, these workbooks represent one way of processing data. Moreover, the goal is really to show users how they might implement certain techniques on their data. These examples should not represent complete pipelines for your data analysis, and critical thought about which processing techniques and statistical analyses are most appropriate for your data set should be taken.