<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 ROP Exam Analysis for NIRS and Pulse Ox
Finalized notebook to combine Masimo and NIRS Data into one iPython Notebook.
Select ROP Subject Number and Input Times
Step1:  Baseline Average Calculation
From first point of data collection to the first eye drops
Step2:  First Eye Drop Avg Every 10 Sec For 5 Minutes
Step3:  Second Eye Drop Avg Every 10 Sec For 5 Minutes
Step4:  Third Eye Drop Avg Every 10 Sec For 5 Minutes
Step5:  Average Every 10 Sec During ROP Exam for first 4 minutes
Step6:  Average Every 5 Mins Hour 1-2 After ROP Exam
Step7:  Average Every 15 Mins Hour 2-3 After ROP Exam
Step8:  Average Every 30 Mins Hour 3-4 After ROP Exam
Step9:  Average Every Hour 4-24 Hours Post ROP Exam
Step10:  Mild, Moderate, and Severe Desaturation Events
<ASSISTANT_TASK:>
Python Code:
from ROP import *
#Takes a little bit, wait a while.
#ROP Number syntax: ###
#Eye Drop syntax: HH MM HH MM HH MM
#Exam Syntax: HH MM HH MM
Explanation: ROP Exam Analysis for NIRS and Pulse Ox
Finalized notebook to combine Masimo and NIRS Data into one iPython Notebook.
Select ROP Subject Number and Input Times
End of explanation
print 'Baseline Averages\n', 'NIRS :\t', avg0NIRS, '\nPI :\t',avg0PI, '\nSpO2 :\t',avg0O2,'\nPR :\t',avg0PR,
Explanation: Baseline Average Calculation
From first point of data collection to the first eye drops
End of explanation
print resultdrops1
Explanation: First Eye Drop Avg Every 10 Sec For 5 Minutes
End of explanation
print resultdrops2
Explanation: Second Eye Drop Avg Every 10 Sec For 5 Minutes
End of explanation
print resultdrops3
Explanation: Third Eye Drop Avg Every 10 Sec For 5 Minutes
End of explanation
print result1
Explanation: Average Every 10 Sec During ROP Exam for first 4 minutes
End of explanation
print result2
Explanation: Average Every 5 Mins Hour 1-2 After ROP Exam
End of explanation
print result3
Explanation: Average Every 15 Mins Hour 2-3 After ROP Exam
End of explanation
print result4
Explanation: Average Every 30 Mins Hour 3-4 After ROP Exam
End of explanation
print result5
Explanation: Average Every Hour 4-24 Hours Post ROP Exam
End of explanation
print "Desat Counts for X mins\n"
print "Pre Mild Desat (85-89) Count: %s\t" %above, "for %s min" %((a_len*2)/60.)
print "Pre Mod Desat (81-84) Count: %s\t" %middle, "for %s min" %((m_len*2)/60.)
print "Pre Sev Desat (=< 80) Count: %s\t" %below, "for %s min\n" %((b_len*2)/60.)
print "Post Mild Desat (85-89) Count: %s\t" %above2, "for %s min" %((a_len2*2)/60.)
print "Post Mod Desat (81-84) Count: %s\t" %middle2, "for %s min" %((m_len2*2)/60.)
print "Post Sev Desat (=< 80) Count: %s\t" %below2, "for %s min\n" %((b_len2*2)/60.)
print "Data Recording Time!"
print '*' * 10
print "Pre-Exam Data Recording Length\t", X - Y # start of exam - first data point
print "Post-Exam Data Recording Length\t", Q - Z #last data point - end of exam
print "Total Data Recording Length\t", Q - Y #last data point - first data point
Explanation: Mild, Moderate, and Severe Desaturation Events
End of explanation
<END_TASK>