Custom Post-processing and Custom Graphics

I often get requests from NeuroExplorer users asking to add something to numerical results (for example, add location of the second peak in the spectrum to summary of numerical results). Another long-standing request is to be able to add custom graphics commands NeuroExplorer graphs.

Let’s consider a spectrum example. Here is a result of Power Spectral Densities analysis:

psd-nopeaks

It would be nice to be able to find the peaks in the spectra, draw ‘x’ marks at peak locations and add text labels showing peak frequencies:

 

psdpeaks

All this can now be done using new post-processing options in NeuroExplorer. Double-click in the graph to invoke Analysis Properties dialog, then go to Post-processing tab and click ‘Post-Processing Script Options’ button:

post-proc

Specify your script in the Post-Processing Script Options dialog:

post-processing-script-options

/downloads/Scripts.zip file contains PostProcPeaks.py script that was used to find peaks and add custom graphics commands shown above. Download Scripts.zip file and extract the scripts to C:\Users\<your__user__name>\Documents\NeuroExplorer 5\Scripts folder.

See also Analysis Functions/Set Property topic in NeuroExplorer help:

neuroexplorer-help-set-property

Python Scripting in NeuroExplorer

For many years, NeuroExplorer has had the capability to automate repetitive tasks:

  • Repeat analysis on all the data files in a folder,
  • Edit data or post-process analysis results without sending data or results to an external program

To support scripting, a custom NexScript language was developed. NexScript supports simple variables and has basic flow control capabilities. However, there are many limitations of NexScript that make writing scripts difficult. Adding new capabilities to NexScript (for example, adding support for arrays) would require a considerable effort. An alternative approach is to integrate existing programming language into NeuroExplorer.

We are pleased to announce that starting with version 5.022, NeuroExplorer scripts can also be written in Python.

NexScript - RepeatAnalysis2

Here are some of the benefits of using Python:

  • Python is very well documented
  • Shorter scripts
    • Access to NeuroExplorer data via Python lists eliminate many loops
    • User-defined functions replace repetitive code
  • Scripts can use thousands of Python functions

Old NexScript scripts can be automatically converted to Python using Tools | Convert to Python menu command in NexScript editor.

NeuroExplorer uses Python 2.7.10. There is no need to install Python. All the Python files needed for scripting are installed by NeuroExplorer setup program.

New Phase Analysis Reveals Phase Relationship between Single-Cell Activity and Local Field Potentials

NeuroExplorer 5.017 released on July 22, 2015 has two new analyses: Find Oscillations analysis and Firing Phase analysis.

Find Oscillations analysis identifies episodes of oscillatory activity in the specified frequency band in recorded analog signals. The algorithm is described in Klausberger, Magill, Marton, Roberts, Cobden, Buzsaki and Somogyi. Brain-state- and cell-type-specific firing of hippocampal interneurons in vivo. Nature, 2003 Feb 20;421(6925):844-8

The user specifies two frequency bands (for example, theta band and delta band). NeuroExplorer finds the segments of LFP signal where theta to delta frequency power ratio exceeds a certain threshold. The LFP signal is then band-filtered and oscillation cycle start times are identified via Hilbert transform. This analysis adds several new variables to the data file. The data viewer screenshot below shows the results of analyzing variable LFP01. NeuroExplorer added three new variables: Theta_Epochs, Theta_Filtered and Theta_ZeroPhase:

FIndOsc1D

The LFP01_Theta_ZeroPhase event is than used in Firing Phase analysis that calculates probability of a neuron firing in a certain phase of theta cycle:

FiringPhase

By the way, I added these new analyses after several users asked me whether a phase-of-firing analysis is available in NeuroExplorer.

Do you need new analyses or new features in NeuroExplorer? Please send your requests to [email protected]

Nex5 File Format

NeuroExplorer Version 5.016 (released on July 3, 2015) supports new .nex5 data file format that is more flexible than .nex file format:

  • Allows NeuroExplorer to save files larger than 2 GB
  • Allows to save unlimited metadata for the whole file and for every file variable in JSON format

nex5 format is designed to be similar to .nex format so that the code that reads and writes .nex files would need only small modifications to implement reading and writing .nex5 files.

Full .nex5 file format specification as well as C++ code and Matlab code for reading and writing .nex5 files are available in the following files:

 

Dealing with Noise and Artifacts in Data Viewer

Often you can visually identify periods of noise or artifacts in 1D Data Viewer:

scratching artifact2

In NeuroExplorer version 5.014 or later, you can identify time intervals corresponding to artifacts using mouse:

– Right-click in 1D View to invoke context menu:

1dmenu1

– Specify ‘Select Interval Variable…’ menu command. NeuroExplorer will display the following dialog:

Specify Interval Variable to Add Intervals to

– Click ‘Create New Interval Variable…’ button:

New Variable Name

– Let’s create a new interval variable with the name noise. Type ‘noise’ (without quotes) and click OK to close this dialog, then click OK to close Select Interval Variable dialog.

– Note that the cursor now has ‘plus interval’ graphic:

intadd

– Press the left mouse button at the start of the noise interval, then drag the mouse until the end of the noise interval and release left mouse button. The new interval is added to noise interval variable:

added interval

– Add a second interval:

2intervals

– Hit ESC key to exit Add Interval mode

– We want to analyze data that is NOT in the noise intervals. To make this possible, right-click in 1D view again and select ‘Invert Interval Variable’ menu command:

invertintvar

– In the Invert Interval Variable dialog, select noise variable to be inverted:

Invert Interval Variable

– Now noise_inverted interval variable contains time intervals corresponding to our data without noise:

noiseinverted

– We can use noise_inverted variable in a Data Selection page of analysis properties dialog:

Analysis Properties data sel

and the data in noise intervals will be ignored.

There is also a faster way to get rid of noisy data — you can delete all the data in specified time intervals. To do this, right-click in 1D view and select ‘On Mouse Click and Drag, Delete…’ menu command:

deletemenu

– Now when you click and drag with the left mouse button, all the data in selected time interval are deleted:

deleted2

deleted3

Note that delete operation cannot be undone right away. You will need to reload the data file to restore original data.