Commit 81254b2e authored by mirandaa's avatar mirandaa
Browse files

better estimation of variation using stdev in cases where possible

parent ee13fccb
......@@ -100,13 +100,24 @@ def main(file):
def isElbowIIT(rawfile, end, scanNum, filterLine):
nextScan = min(scanNum + 1, end)
nextNextScan = min(scanNum + 2, end)
next_filterLine = rawfile.GetFilterForScanNum(nextScan)
if filterLine != next_filterLine:
nextNext_filterLine = rawfile.GetFilterForScanNum(nextNextScan)
if filterLine != next_filterLine or nextScan == end: # there is no elbow
return False
ion_injection_time = rawfile.GetTrailerExtraForScanNum(scanNum)['Ion Injection Time (ms)']
next_ion_injection_time = rawfile.GetTrailerExtraForScanNum(nextScan)['Ion Injection Time (ms)']
isElbow = ion_injection_time > next_ion_injection_time * 2
return isElbow
if next_filterLine != nextNext_filterLine: # can't average so use estimation
return ion_injection_time > next_ion_injection_time + (math.sqrt(next_ion_injection_time)*3)
nextNext_ion_injection_time = rawfile.GetTrailerExtraForScanNum(nextNextScan)['Ion Injection Time (ms)']
average = (next_ion_injection_time + nextNext_ion_injection_time)/2
stdev = math.sqrt((next_ion_injection_time-average)**2+(nextNext_ion_injection_time-average)**2)
# TODO use pandas dataframe and getdo groupby and average to get these numbers
return ion_injection_time > average + max((stdev*3), (math.sqrt(next_ion_injection_time)*3)) # max used because sometimes the deviation is too small
def ThermoRawfile2Scans(file_path, dropElbowIIT = True):
# NOTE: for testing use ThermoRawfile2Scans_sample instead
......@@ -115,7 +126,7 @@ def ThermoRawfile2Scans(file_path, dropElbowIIT = True):
start = rawfile.FirstSpectrumNumber
end = rawfile.GetLastSpectrumNumber()
MSrawscans = []
for scanNum in range(start, end+1):
peak_datas = rawfile.GetLabelData(scanNum)[0]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment