g-PRIME
Physiology Recording & Identification of Multiple Events

Gus K. Lott III, Ph.D.

Software Oscilloscope & Data Logging
Spike Detection & Analysis
Real time & Offline


[ Home | Download | Documentation | Future Goals | Source | About the Author ]
[ Applications of g-PRIME (screenshots & data) ]

Stimulus Generation Offline Analysis



Real-Time Analysis

Fully activated RT analysis features. RT Correlation, Parameter display,
Threshold Event Detection, and Histogram

3.1 Connecting to an Active Signal and Visualizing

The analysis window is accessed through the yellow "Data Analysis Mode" Button in the right portion of the g-PRIME scope window. The user may link the analysis window to a real time source by selecting the “Scope Channel” option from the Source menu in the g-PRIME Analysis window. Once the “Scope Channel” mode is selected, the user may select which of the active traces to connect to from the “Source Chan” pop-up menu under the data display trace.

The user may frame the real time data through the Zoom/Pan function in the main Data panel. Zoom to specify a vertical range on an active data trace. When the next sweep occurs, the data trace horizontal limits will be reset to the sweep width.

Depending on the time base of the main scope display, the real time analysis window will have 50ms, 100ms, or 200ms of data per sweep. Any scope sweep width higher than 200ms will report 200ms sweep widths to the analysis interface for calculations.

3.2 Signal Conditioning

Analysis modes and signal conditioning
The user may apply high and low pass filters by selecting from the drop down “Analysis” menu. The critical frequencies for the filters are indicated. These filters are third order “Butterworth” digital filters with critical frequency indicated by the drop down menu value. During real-time signal analysis, the filter is immediately applied when selected. Note that filters with critical frequency higher than the Nyquist rate for a given channel sample rate will not be available.

The user may also apply arbitrary FIR filter coefficients in an ASCII Text file. The coefficients should be of a form suitable for the matlab "filter" function. The first column of the text file should be the "b" coefficients and the second column should be the "a" coefficients. If there is only one column, "a" is assumed to just be 1 and the column of values is assumed to be "b" otherwise, the two columns must have the same length (pad with zeroes if necessary). When the user has selected and/or loaded all of the filters that they wish to apply to the signal, the entire filter spectrum (amplitude and phase) may be visualized from the option in the analysis drop down menu.

The user may also “Rectify” the signal for easy threshold based detection (i.e. negative sweeping values will be captured by a positive threshold level). When “Rectify (for detection only)” is selected from the “Analysis” menu, the absolute value of signal amplitudes is displayed and will be used to detect events. Analysis metrics are calculated from un-rectified data.

3.3 Amplitude Threshold Event Detection (Single & Double)


Two Thresholds detecting spikes which peak in a certain
range of amplitudes. Detected events are colored red.
Thresholds are set by either manually entering a value in the edit box next to the threshold activation check box or by dragging the horizontal threshold line up or down on the data visualization display.

Two thresholds are available for event detection. Threshold crosses are detected in a direction relative to the mean value of the signal. If the threshold is placed below the mean of the signal, falling edge events are detected which cross the negative threshold relative to the mean. If the threshold is placed above the mean of the signal, rising edge events are detected.

The active threshold closest to the mean value of the signal will trigger all event detection above that level. Analysis is carried out on all of these events. If a second threshold level is set, detected events with peak amplitudes between the two thresholds are kept while values that peak outside of the threshold range are discarded.

g-PRIME will detect events that cross the threshold and center the analysis window based on the selection from the “Window Center on Threshold” menu under the “Analysis” menu. The default is 50% of the window before the threshold cross.

If you wish to have the system display a full red trace overlay of the exact data points of a detected event, this option is available from the analysis menu. If this option is not selected, events are indicated by a vertical red line centered at the time of the threshold crossing and extending from the min to max amplitude of the window.

3.4 Analysis Metrics (the g-PRIME transform)

When an event is detected, several analysis values are calculated and may be displayed in the analysis graph at the bottom of the screen. When data is saved to a file, interval and rate data is not stored. It is assumed that the user can calculate these values given the event time offline. Also included in the offline analysis results file are the time of the max and time of the minimum events.

  1. Event Time (sec)
    • Relative to start of the last input reset or beginning of the file
  2. Rate Between Events (Hz)
    • Inverse of difference between event times
  3. Interval Between Events (sec)
    • Difference between event times
  4. Minimum Amplitude in Window (V)
    • This value is used to reject events outside of the two-threshold range if thresholds are set below the mean value of the signal
  5. Maximum Amplitude in Window (V)
    • This value is used to reject events outside of the two-threshold range if thresholds are set above the mean value of the signal
  6. Peak Frequency Component (Hz)
    • The mean value of the window is subtracted from the signal and the Fast Fourier Transform (FFT) is taken. The peak value of the FFT is calculated. This value tends to be highly quantized at low frequencies. The frequency resolution is inversely proportional to the window width. This value is proportional to the derivative of the main component of the signal. It is the frequency component of the largest sinusoidal contribution to the signal (thus it is a metric inversely proportional to pulse width)
  7. Energy Density
    • Energy density is the sum of the FFT divided by the number of points in the FFT. This number yields a general “Size” description of your event. It is a fairly clean relative measure of signal energy as noise sources will tend to have constant energy density. The energy density of signals relative to one another then depends only on the contribution from the signal source. This is the best “amplitude” measurement in most cases.

3.5 Visualizing Analysis Parameters

The analysis display is manipulated by controls in the bottom right of the analysis window.

Histogram Y
Selecting histogram display casts the data values displayed on the vertical axis of the analysis plot into a 50 bin histogram spread over the range of all events in the data set for that given parameter.

Y-Axis Metric
Any of the parameters may be cast as the Y-axis value of the data display. Select a parameter from the pop-up menu and select an axis range mode (auto on/off) and an axis scale (log/linear) for display.

X-Axis Metric
Similarly, any parameter may be cast on the X-axis to form a 2 parameter space in an attempt to see differentiation amongst the data values. If Event time is selected during real-time analysis mode, this axis will be automatically controlled and actively changed as time passes. The axis will have a fixed window width defined by a selection in the displayed width pop-up menu and the data will scroll from right to left as events are detected and time passes.

3.6 Real-Time Analysis Parameter Thresholding

Thresholding based on amplitude and peak frequency component. Here, a female electric fish is detected by an amplitude and frequency threshold range and the male spikes are rejected.

While amplitude thresholds in the raw data trace offer some limited event discrimination, further event discrimination may be activated in terms of threshold ranges in the “Energy Density” and “Peak Frequency” space.

Select either parameter as the Y-Axis Metric value and independent checkboxes will appear which allow for threshold activation. When an analysis based threshold is activated, you may drag the two lines in the analysis plane to specify the acceptance region for events.

When an analysis parameter region is selected, you may then switch to another display mode such as Rate, Interval, or amplitude and monitor only the behavior of the subset of events. For example, frequency thresholds may be used to select a single type of discharge (in the above figure, an electric fish discharge) and the rate behavior of a single element (rasping or decaying) may be visualized in real time.

3.7 Real-Time Event Correlation (Autocorrelation or Cross Correlation)

While the user will not have access to the raw trace information as displayed with offline analysis, the user may actively accomplish a cross-correlation or an autocorrelation of signals. Signals are actively acquired into a running event triggered average. The pair of thresholds may be used to limit the amplitude range of event for the real time correlation. Peak Frequency and Energy Density thresholds (as described in the last section) may also be activated to discriminate correlated events.

To activate the correlation interface, select “Real Time Correlation” from the “Analysis” menu. A trace window will appear and controls will activate that will allow you to select a window width for signal averaging, a source for the time triggered average, and whether or not to center the average window on the threshold cross or to use the threshold cross as the beginning of the average window. The user may also use the “Reset Avg” button to clear the contents of the correlation window. The threshold cross time amplitude value of the target region is set to zero in all extracted traces.




Small signals may be autocorrelated (top) to create matched filters for optimal signal to noise enhancement. Cross channel (bottom) correlation may be accomplished to detect network behavior (in this case, post synaptic potentials in a muscle are detected by correlating a single action potential class in a nerve innervating this invertebrate muscle).

3.8 Saving Analysis

During Real-Time Analysis, only the 1000 latest events are stored unless the “Retain all Real-Time Analysis” option is checked in the “Analysis” menu (to prevent processor loading from graphics updates of many thousands of points). At any time, all stored analysis values may be saved to a text file (one event per row of columns) via the “Save All Analysis” option in the “Results” menu.

Saved .txt files with analysis parameters consist of 7 columns of data points and a number of rows of data equal to the number of detected events. Rate and Interval are not stored as these are easily obtained from the event time value. In addition to the above mentioned values, the time codes for the maximum and minimum amplitudes are stored. The columns in saved analysis text files are as follows:

Column 1: Time of Threshold Crossing
Column 2: Time of Maximum Window Amplitude
Column 3: Value of Maximum Window Amplitude
Column 4: Time of Minimum Window Amplitude
Column 5: Value of Minimum Window Amplitude
Column 6: Peak Frequency in FFT of the Event Window
Column 7: Energy Density of Event Window

This table is available in the help menu in the analysis window for reference.

3.9 Histogram Generation

Event histograms may be generated for any of the parameters in the interface. Selecting a specific variable from the “Generate Histograms” option in the “Results” menu launches a figure containing the histogram for saving as a graphic.

Histogram of energy density of three distinct units in a 30 second multi-unit nerve recording in the crayfish periphery
Stimulus Generation Offline Analysis


(c) Gus Lott 2007