pypore.strategies.baseline_strategy module

class pypore.strategies.baseline_strategy.BaselineStrategy

Bases: object

This is an abstract class defining how find_events() handles computing the baseline.

Example implementations–

  • FixedBaselineStrategy – baseline is fixed.
  • AdaptiveBaselineStrategy – applies a first-order recursive filter to adapt the baseline as the data changes.

When a BaselineStrategy is passed to find_events(), find_events() will call the following methods, so Subclasses must override these methods.

__init__

(double baseline=0.0, double variance=0.0)

Parameters:
  • baseline (double) – baseline
  • variance (double) – variance
baseline
compute_baseline(double data_point)

(Note: this is a cpdef wrapper around the cdef function compute_baseline_c(). This function can be called directly from Python. If calling from Cython, you can call the cdef version compute_baseline_c())

When a BaselineType or subclass is passed in a Parameters object to find_events(), it will call this method with each new data_point as it linearly loops through its data.

This method will raise a NotImplementedError, so it should be overridden. Subclasses can use this data_point to compute/modify the baseline.

Parameters:data_point (double) – When called from find_events(), data_point is the most recent data point.
Returns:the new baseline. Subclasses should return BaselineStrategy.compute_baseline_c(self, data_point).
compute_variance(double data_point)

(Note: this is a cpdef wrapper around the cdef function compute_variance_c(). This function can be called directly from Python. If calling from Cython, you can call the cdef version compute_variance_c())

When a BaselineType or subclass is passed in a Parameters object to find_events(), it will call this method with each new data_point as it linearly loops through its data.

This method will raise a NotImplementedError, so it should be overridden. Subclasses can use this data_point to compute/modify the variance.

Parameters:data_point (double) – When called from find_events(), data_point is the most recent data point.
Returns:the new variance. Subclasses should return BaselineStrategy.compute_variance_c(self, data_point).
get_baseline()

(Note: this is a cpdef wrapper around the cdef function get_baseline_c(). This function can be called directly from Python. If calling from Cython, you can call the cdef version get_baseline_c())

Returns:the current baseline.
get_variance()

(Note: this is a cpdef wrapper around the cdef function get_variance_c(). This function can be called directly from Python. If calling from Cython, you can call the cdef version get_variance_c())

Returns:the current variance.
initialize(double baseline)

(Note: this is a cpdef wrapper around the cdef function initialize_c(). This function can be called directly from Python. If calling from Cython, you can call the cdef version initialize_c())

When a BaselineType or subclass is passed in a Parameters object to find_events(), it will call this method with the first 100 data points or so.

This method will raise a NotImplementedError, so it should be overridden. Subclasses can use the initialization_points initialize_c the baseline and the variance.

Parameters:initialization_points (numpy.ndarray[numpy.float]) – When called from find_events(), this is the first 100 data points or so.
variance