/// <summary> /// Returns the Alignment Function that the processor determined /// </summary> /// <returns></returns> public LcmsWarpAlignmentFunction GetAlignmentFunction() { var func = new LcmsWarpAlignmentFunction(_options.CalibrationType, _options.AlignType); List <double> aligneeNets; List <double> referenceNets; _lcmsWarp.AlignmentFunction(out aligneeNets, out referenceNets); if (_aligningToMassTagDb) { func.SetNetFunction(aligneeNets, referenceNets); } else { var referenceScans = referenceNets.Select( rNet => _minReferenceDatasetScan + rNet * (_maxReferenceDatasetScan - _minReferenceDatasetScan)).ToList(); var referenceTimes = referenceNets.Select( rNet => _minReferenceDatasetTime + rNet * (_maxReferenceDatasetTime - _minReferenceDatasetTime)).ToList(); func.SetNetFunction(aligneeNets, referenceNets, referenceScans, referenceTimes); } if (_options.AlignType == LcmsWarpAlignmentType.NET_WARP) { return(func); } var minAligneeNet = _lcmsWarp.MinNet; var maxAligneeNet = _lcmsWarp.MaxNet; // Get the mass calibration function with time var numXSlices = _options.MassCalibNumXSlices; if (_options.CalibrationType == LcmsWarpCalibrationType.NetRegression || _options.CalibrationType == LcmsWarpCalibrationType.Both) { // get the PPM for each X slice var aligneeNetMassFunc = new List <double>(); var aligneePpmShiftMassFunc = new List <double>(); for (var sliceIndex = 0; sliceIndex < numXSlices; sliceIndex++) { var net = minAligneeNet + ((maxAligneeNet - minAligneeNet) * sliceIndex) / numXSlices; aligneeNetMassFunc.Add(net); aligneePpmShiftMassFunc.Add(_lcmsWarp.GetPpmShiftFromNet(net)); } func.SetMassCalibrationFunctionWithNet(aligneeNetMassFunc, aligneePpmShiftMassFunc); } if (_options.CalibrationType == LcmsWarpCalibrationType.MzRegression || _options.CalibrationType == LcmsWarpCalibrationType.Both) { // Get the ppm for each X slice var aligneeMzMassFunc = new List <double>(); var aligneePpmShiftMassFunc = new List <double>(); for (var sliceIndex = 0; sliceIndex < numXSlices; sliceIndex++) { var net = sliceIndex * 1.0 / numXSlices; var mz = _minAligneeDatasetMz + (int)((_maxAligneeDatasetMz - _minAligneeDatasetMz) * net); aligneeMzMassFunc.Add(mz); aligneePpmShiftMassFunc.Add(_lcmsWarp.GetPpmShiftFromMz(mz)); } func.SetMassCalibrationFunctionWithMz(aligneeMzMassFunc, aligneePpmShiftMassFunc); } return(func); }
/// <summary> /// Returns the Alignment Function that the processor determined /// </summary> /// <returns></returns> public LcmsWarpAlignmentFunction GetAlignmentFunction() { var func = new LcmsWarpAlignmentFunction(Options.CalibrationType, Options.AlignType); var aligneeNets = new List <double>(); var referenceNets = new List <double>(); m_lcmsWarp.AlignmentFunction(ref aligneeNets, ref referenceNets); if (AligningToMassTagDb) { func.SetNetFunction(ref aligneeNets, ref referenceNets); } else { var referenceScans = new List <double>(); var numSections = referenceNets.Count; for (var sectionNum = 0; sectionNum < numSections; sectionNum++) { referenceScans.Add(m_minReferenceDatasetScan + referenceNets[sectionNum] * (m_maxReferenceDatasetScan - m_minReferenceDatasetScan)); } func.SetNetFunction(ref aligneeNets, ref referenceNets, ref referenceScans); } if (Options.AlignType == AlignmentType.NET_WARP) { return(func); } var minAligneeNet = m_lcmsWarp.MinNet; var maxAligneeNet = m_lcmsWarp.MaxNet; // Get the mass calibration function with time var numXKnots = Options.MassCalibNumXSlices; var aligneeMzMassFunc = new List <double>(); var aligneeNetMassFunc = new List <double>(); var aligneePpmShiftMassFunc = new List <double>(); if (Options.CalibrationType == LcmsWarpCalibrationType.ScanRegression || Options.CalibrationType == LcmsWarpCalibrationType.Both) { // get the PPM for each knot for (var knotNum = 0; knotNum < numXKnots; knotNum++) { var net = minAligneeNet + ((maxAligneeNet - minAligneeNet) * knotNum) / numXKnots; var ppm = m_lcmsWarp.GetPpmShiftFromNet(net); aligneeNetMassFunc.Add(net); aligneePpmShiftMassFunc.Add(ppm); } func.SetMassCalibrationFunctionWithTime(ref aligneeNetMassFunc, ref aligneePpmShiftMassFunc); } if (Options.CalibrationType != LcmsWarpCalibrationType.MzRegression && Options.CalibrationType != LcmsWarpCalibrationType.Both) { return(func); } // Get the ppm for each knot for (var knotNum = 0; knotNum < numXKnots; knotNum++) { var net = knotNum * 1.0 / numXKnots; var mz = m_minAligneeDatasetMz + (int)((m_maxAligneeDatasetMz - m_minAligneeDatasetMz) * net); var ppm = m_lcmsWarp.GetPpmShiftFromMz(mz); aligneeMzMassFunc.Add(mz); aligneePpmShiftMassFunc.Add(ppm); } func.SetMassCalibrationFunctionWithMz(aligneeMzMassFunc, aligneePpmShiftMassFunc); return(func); }