Events

Documentation for the functions in the events module.

pyneurotrace.events.ewma(data, weight=0.1)

Performs smoothing on each row using the Exponentially Weighted Moving Average (EWMA) method.

EWMA: Exponentially Weighted Moving Average https://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average Performs smoothing on each row, given how strongly to weight new values (vs existing average)

Parameters:
  • data (array) – Data array to be smoothed.

  • weight (float, optional) – Weight for new values versus existing average. Default is 0.1.

Returns:

smoothed_data – Smoothed data array.

Return type:

array

pyneurotrace.events.cusum(data, slack=1.0)

Calculates the Cumulative Sum (CUSUM) of movement above the mean for each row in the data.

CUSUM: Cumulative sum of movement above the mean. https://en.wikipedia.org/wiki/CUSUM Subtracts the rolling average from each point, then accumulates how far it is above a slack noise value.

Parameters:
  • data (array) – Data array to be analyzed.

  • slack (float, optional) – Slack noise value. Default is 1.0.

Returns:

cusum_data – CUSUM data array.

Return type:

array

pyneurotrace.events.matchedFilter(data, hz, windowSize, A=2.0, riseRate=0.028, decayRate=0.39)

Performs a likelihood ratio test using a Matched Filter (MF) to see how well a previous window matches a desired signal over no signal.

MF: Matched Filter https://en.wikipedia.org/wiki/Matched_filter Performs a (log) likelihood ratio test, to see how well a previous window matches a desired signal over no signal.

Parameters:
  • data (array) – Data array to be filtered.

  • hz (int) – Sampling rate in Hz.

  • windowSize (int) – Size of the window to match.

  • A (float, optional) – Amplitude of the desired signal. Default is 2.0.

  • riseRate (float, optional) – Rise rate of the desired signal. Default is 0.028.

  • decayRate (float, optional) – Decay rate of the desired signal. Default is 0.39.

Returns:

mf_data – Matched filter data array.

Return type:

array

pyneurotrace.events.thresholdEvents(data, threshold, minBelowBefore=1)

Turns an event detector into event yes/no indicators by applying a threshold and only keeping events that occur after a minimum number of non-event samples.

Parameters:
  • data (array) – Data array containing event detector outputs.

  • threshold (float) – Confidence threshold for events.

  • minBelowBefore (int, optional) – Minimum number of non-event samples before an event is considered. Default is 1.

Returns:

events – Array indicating detected events.

Return type:

array