Here's a small script I wrote for detecting contractions (beats) in cardiac myocytes. The input is a series of timepoints vs sarcomere lengths. I first used a moving average to smooth the data and took the derivative to look for changes in value i.e. a contraction corresponds to decreasing moving average (detection is threshold based). The slew rate is calculated based off the estimated start/end contraction time points. Finally quality control is implemented using a scatter plot to show where the detected points are.