GithubHelp home page GithubHelp logo

salapakalab-simbiosys / step-detection-algorithm Goto Github PK

View Code? Open in Web Editor NEW
2.0 0.0 0.0 4.08 MB

Tool for detecting abrupt step changes in noisy signals

License: GNU General Public License v3.0

Python 100.00%
biochemistry biophysics change-detection change-detection-algorithms change-detector molecular-motors single-molecule-force-spectroscopy step-detection step-detector

step-detection-algorithm's Introduction

Step Detection Algorithm (SDA): A toolbox for detecting steps of unknown size and location in a noisy signal.

How to use

Here is a sample code to get the estimate of step signals from noisy measurements.

# Noise standard deviation
sigma = 0.3162 #0.3162 Corresponds to an SNR of 5 for signal of size 1 and a duty ratio of 0.5 


# =============================================================================
# Generating noisy stepping data 
# This section is needed only for sample signal generation. Replace this section 
# with your data. That is, instead of generating the measured signal 'y', 
# assign 'y' to your signal of interest 
# =============================================================================
d = 10 # No. of steps
dt = 0.1 # Sampling interval in s
N = 1000 # total number of samples 
L = 1 # Step size
iterations = 50 # No. of SDA iterations
resolution = 0.05 # Resolution of the SDA
seed = 5 # For reproducibility (change seed for a new signal)
include_dynamics = False # Choose to simulate sensor dynamics 

# Simulating sensor dynamics
SDynObj = SDADynamics()
num = [1] # Specify numerator of sensor transfer function
den = [0.1, 0.8, 1, 1] # Specify denominator of sensor transfer function
sysd = SDynObj.get_DT_sys(num, den, dt)


# Generating a sample stepping signal
SIGObj = SampleSignals()
# Stepping signal
x = SIGObj.get_step_sample(step_size = L, no_steps = d, no_samples = N, bidirectional = 0, seed = seed)
# Noise
noise = SIGObj.get_gaussian_noise(std = sigma, no_samples = N, seed = seed)

if(include_dynamics == True):
    [T, x_sensor] = SIGObj.sensor_dynamics(num, den, dt, x)
    x_sensor = np.expand_dims(x_sensor, axis = 0)
else:
    x_sensor = x
    sysd = None

y = x_sensor + noise  # Noisy measurements

# =============================================================================

# To use the SDA to estimate the stepping signal from data, 
# you would need the standard deviation of noise in the signal.
# Here the standard deviation of noise is denoted by 'sigma'.  
SDAObj = SDA()
[step_estimate, est_array, hist_array]= SDAObj.SDA_dynamics(sigma, y)
SDAObj.plot_SDA_stages(x.T, y, est_array, hist_array)

Example

Here is an example of the Step Detection Algorithm in action. The SDA works in stages, refining & learning about the underlying signal in each stage. Shown below is the signal estimate and step size histogram after the first stage.

After two stages, the step size histogram has been refined, with some of the erroneous sizes eleminated.

The refinement process continues in stage 3...

and in stage 4.

At stage 5, no further refinements are achieved in this example and the algorithm stops. The result of this final stage is the output of the SDA.

Citation

To cite SDA, please use the Automatica publication:

  • Rajaganapathy, Sivaraman, James Melbourne, and Murti V. Salapaka. "Change detection using an iterative algorithm with guarantees." Automatica 136 (2022): 110075.

Additional References

  • Rajaganapathy, Sivaraman, James Melbourne, Tanuj Aggarwal, Rachit Shrivastava, and Murti V. Salapaka. "Learning and Estimation of Single Molecule Behavior." In 2018 Annual American Control Conference (ACC), pp. 5125-5130. IEEE, 2018.

  • Aggarwal, Tanuj, Donatello Materassi, Robert Davison, Thomas Hays, and Murti Salapaka. "Detection of steps in single molecule data." Cellular and molecular bioengineering 5, no. 1 (2012): 14-31.

step-detection-algorithm's People

Contributors

huacailong avatar sivrmn avatar

Stargazers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.