本文整理汇总了C#中SortedSet.Median方法的典型用法代码示例。如果您正苦于以下问题:C# SortedSet.Median方法的具体用法?C# SortedSet.Median怎么用?C# SortedSet.Median使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SortedSet
的用法示例。
在下文中一共展示了SortedSet.Median方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FilterNosieByLocalWindow
public void FilterNosieByLocalWindow(double signalToNoiseRatio = 1.4826, int windowPpm = 10000)
{
var filteredPeaks = new List<Peak>();
var tolerance = new Tolerance(windowPpm);
var st = 0;
var ed = 0;
var prevSt = 0;
var prevEd = 0;
var intensityValues = new SortedSet<double>();
foreach (var peak in Peaks)
{
var mzWindowWidth = tolerance.GetToleranceAsTh(peak.Mz);
var mzStart = peak.Mz - mzWindowWidth;
var mzEnd = peak.Mz + mzWindowWidth;
while (st < Peaks.Length)
{
if (st < Peaks.Length - 1 && Peaks[st].Mz < mzStart) st++;
else break;
}
while (ed < Peaks.Length)
{
if (ed < Peaks.Length - 1 && Peaks[ed].Mz < mzEnd) ed++;
else break;
}
if (ed - st + 1 < 2)
{
filteredPeaks.Add(peak);
continue;
}
if (intensityValues.Count < 1)
{
for (var i = st; i <= ed; i++) intensityValues.Add(Peaks[i].Intensity);
}
else
{
if (prevEd >= st)
{
for (var i = prevSt; i < ed; i++) intensityValues.Remove(Peaks[i].Intensity);
for (var i = prevEd+1; i <= ed; i++) intensityValues.Add(Peaks[i].Intensity);
}
else
{
for (var i = prevSt; i <= prevEd; i++) intensityValues.Remove(Peaks[i].Intensity);
}
}
var intensityMedian = intensityValues.Median();
if (peak.Intensity > intensityMedian*signalToNoiseRatio) filteredPeaks.Add(peak);
prevSt = st;
prevEd = ed;
}
filteredPeaks.Sort();
Peaks = filteredPeaks.ToArray();
}