Export Utility Functions

Export functions are utilities that will extract and save specific features from a raw recording file (.rec) into a binary file. All extracted binary files can be read into Matlab using a single function: readTrodesExtractedDataFile.m (in the TrodesToMatlab toolbox). Extracted binary files can also be read into Python using a single function: readTrodesExtractedDataFile.py (in the TrodesToPython toolbox).

Trodes Export Utility

Note: In Trodes versions before 2.0.0, export functions were separated into different command line programs for each data type (exportLFP, exportSpikes, etc.). These functions are now deprecated and have been combined into a single export tool called “trodesexport”. This program can either be run from the command line, or from Trodes when a recorded file is opened in playback mode. The following instructions are for use with trodesexport.

The trodesexport utility can run either from within the Trodes interface or from the command line. When finished, it will save the resulting .dat files in a subfolder in the same location as the .rec file. The subfolder will be named after the processing type.

Running from Trodes

To run the export utility from within Trodes, you will need to open a previously recorded .rec file in playback mode. See the basic usage documentation for how to open a file in playback mode. Once the file is open:

  • Go to File->Extract…

  • This will open a separate window names “Extract data from file”

  • On the left side of the window, check all of the processing modes that you want to run

  • Click the “Start” button

  • The export process, along with percentage complete, will show in the embedded console window.

The trodesexport program will use the settings (filters, references, LFP channel, spike detection thresholds, etc.) defined when the recording file was first created (embedded in the recording), or the settings in a workspace file (.trodesconf) located in the same folder as the .rec file and with the same name (for example, ‘myfile.rec’ and ‘myfile.trodesconf’).

Command Line Usage

Command line execution is useful for batch processing. It also exposes more options that are not available from the Trodes graphical interface.

The basic command line usage requires the following inputs:

trodesexport <-h -v> <-spikes -lfp -spikeband -raw -stim> -rec FILENAME <-optionflag1 optionvalue1> <optionflag2 optionvalue2> …

  • If the -h flag is entered, a full usage menu will print to the screen

  • If the -v flag is entered, the program’s version number will print to the screen

  • At least one of the processing flags must be provided (such as -spikes)

  • A rec file must be provided after the -rec flag

  • By default, the trodesexport program will use the settings defined when recording the data or the settings defined in an external workspace (see above). But you can override these via the command line options detailed below.

Processing modes (multiples allowed)

  • -spikes – Spike waveform export (spike snippets only).

  • -lfp – Continuous LFP band export.

  • -spikeband – Continuous spike band export.

  • -raw – Continuous raw band export.

  • -stim – Continuous stimulation band export for stimulation capable recording channels.

  • -dio – Digital IO channel state change export.

  • -analogio – Continuous analog IO export.

  • -mountainsort – One mountainsort file per ntrode (using raw band data)

  • -kilosort – One kilosort file per ntrode (using raw band data).

Option flags

  • -rec <filename> – Recording filename. Required. Muliple -rec <filename> entries can be used to append data in output.

  • -output <basename> – The base name for the output files. If not specified, the base name of the first .rec file is used.

  • -outputdirectory <directory> – A root directory to extract output files to (default is directory of .rec file).

  • -reconfig <filename> – Use a different workspace than the one embedded in the recording file.

  • -interp <integer> – (Default is -1 for infinite) Maximum number of dropped packets to interpolate over (linear). A value of -1 is infinite. 0 is no interpolation.

  • -sortingmode <0,1, or 2> – Used by mountainsort and kilosort modes. Can be a value of 0, 1 (default), or 2. 0 combines channels into one file. Channels in the file will be in the same order as that in the workspace, but won’t be divided into separate ntrodes. A value of 1 separates files by nTrodes. A value of 2 separates files by their designated sorting group.

  • -abortbaddata <1 or 0> – Whether or not to abort export if data appears corrupted.

  • -paddingbytes <integer> – Used to add extra bytes to the expected packet size if an override is required

Datatype-specific options

LFP data band

  • -lfplowpass <integer> – Low pass filter value for the LFP band. Overrides settings in workspace for all nTrodes.

  • -lfpoutputrate <integer> – (Default 1500) The LFP band output can have a sampling rate less than the full sampling rate.

  • -uselfprefs <1 or 0> – Override what is in the workspace for lfp band reference on/off settings for all nTrodes.

  • -uselfpfilters <1 or 0> – Override what is in the workspace for lfp filter on/off settings for all nTrodes.

Spike data band

  • -spikehighpass <integer> – High pass filter value for the spike band. Overrides settings in workspace for all nTrodes.

  • -spikelowpass <integer> – Low pass filter value for the spike band. Overrides settings in workspace for all nTrodes.

  • -invert <1 or 0> – (Default 1) Sets whether or not to invert spikes to go upward.

  • -usespikerefs <1 or 0> – Override what is in the workspace for spike band reference on/off settings for all nTrodes.

  • -usespikefilters <1 or 0> – Override what is in the workspace for spike filter on/off settings for all nTrodes.

Spike event processing

  • -thresh <integer> – Overrides the thresholds for each nTrode stored in the workspace and applies the new threshold to all nTrodes.

Raw data band

  • -userawrefs <1 or 0> – Override what is in the workspace for raw band reference on/off settings for all nTrodes.

Other Export Utilities

Some export formats are not included in the main trodesexport utility. These are provided as separate command line programs:

exportofflinesorter (Offline Sorter)

Used to extract continous data from a raw rec file and save to binary file that can be imported with Offline Sorter.

exportofflinesorter -rec INPUTFILENAME OPTION1 VALUE1 OPTION2 VALUE2 …

Input argument defaults:

  • -outputrate -1 (full)

  • -usespikefilters 1 (Filter the channels with the saved spike filters)

  • -interp -1 (interpolation not supported, do not change)

  • -combinechannels 1 (combine neural channels into one file. Instead use one file per channel.)

  • -appendauxdata 0 (do not append DIO and analog data into the file)

  • -userefs 1 (Use the digital reference channels designated in the file)

To import the binary file into Offline Sorter, from the main menu of Offline Sorter select File | Import | Binary File with Continuously Digitized Data. Choose the following settings:

  • Number of channels: the total number of channels in the exported file

  • Data offset: 0

  • Digitization freq: 30000 or 20000 (depending on what you actually used)

  • A/D Conversion resolution: 16

  • Maximum Voltage (mV): 6.39

  • Swap bytes: No