how to calculate heart rate and spo2 from maxrefdes117

i used this example but i don't understand the concept of heart and spo2 calculation . can u explain how this calculation done . in my coding i am able to read the data from ir and red led but i want to know the process to calculate hr .
thanks