Segment the heart and measure it's area for each frame. Then find the peak displacement. Finding displacements per second means you need a time window over which you will count the number of displacements. You can find peaks with findpeaks(), and you can count them with conv(). Then divide by the width of the window in seconds to get the count per second.