Link Search Menu Expand Document

Perform custom analysis directly from NeuroScope2

You can add your own custom functions that can be run from NeuroScope2 from the menu called Analysis. You must create a wrapper function for what you want to call outside NeuroScope2. There are a lot of examples included, that you can take inspiration from. The analysis tools are located in the +analysis_tools folder. Please see the wrapper example at the bottom of this page.

Organization of analysis tools and included functions

The analysis menu and underlying +analysis_tools folder are organized according to the underlying data types of CellExplorer. Various functions are already included:


  • 2D and
  • 3D plot of behavior


  • run ProcessCellMetrics
  • open CellExplorer
  • Plot metrics for a subset of cells, including CCGs and other built-in plots from CellExplorer


  • detect ripples. Shows a dialog first, allowing for defining input parameters


  • generate the .lfp file from the raw data


  • Plot channel coordinates


  • Detect monosynaptic connections
  • plot CCGs
  • plot spike-rasters


  • Detect brain states using SleepScoreMaster - requires the Buzcode toolbox.
  • Edit brain states in TheStateEditor - requires the Buzcode toolbox.


  • open StateExplorer


  • Plot correlation between channels
  • Plot RMS noise across channels
  • Show power spectral density across channels on a linear scale
  • Show power spectral density across channels on a log scale
  • Show temporal offsets between channels

The folder structure is purely for organization but the names are hard-coded in NeuroScope2, so they should not be altered.

Wrapper example provided

The wrapper example is located in the +traces folder (wrapper_example.m), use it to built your own analysis functions.

function out = wrapper_example(varargin)
% This is a wrapper example file for NeuroScope2. 
% Use this wrapper example to make calls from NeuroScope to any other analysis that can be applied to the traces, raw data or any derived data types.
% This function can be called from NeuroScope2 via the menu Analysis 

p = inputParser;

% The inputs are NeuroScope2 variables:
addParameter(p,'UI',[],@isstruct); % UI: struct with UI elements and settings of NeuroScope2
addParameter(p,'ephys',[],@isstruct); % ephys: Struct with ephys data for current shown time interval, e.g. ephys.raw (raw unprocessed data), ephys.traces (processed data)
addParameter(p,'data',[],@isstruct); % data: contains all external data loaded like data.session, data.spikes,, data.states, data.behavior

ephys = p.Results.ephys;
UI = p.Results.UI;  
data =;

out = [];

% % % % % % % % % % % % % % % %
% Function content below
% % % % % % % % % % % % % % % % 

% Your function content should go here