Esempio n. 1
0
        /// <summary>根据标样曲线,进行多点校正/// </summary>
        /// <param name="std_papl">标样列表</param>
        /// <param name="unknown_papl">未知样品</param>
        /// <param name="am">分析参数</param>
        /// <returns>QualitativeErrorInfo枚举值</returns>
        public static QualitativeErrorInfo QA_MultiPointFitting(List <PeakAndPointList> std_papl, PeakAndPointList unknown_papl, AnalyzerMethod am)
        {
            if (std_papl == null || std_papl.Count <= 0 || unknown_papl == null)
            {
                return(QualitativeErrorInfo.PeakListError);
            }

            QualitativeErrorInfo _rc = QualitativeErrorInfo.Success;

            //检查标样的浓度是否正常
            if (SampleIsError(std_papl))
            {
                Debug.WriteLine("The sample doesn't meet the requirements for calculation.");
                return(QualitativeErrorInfo.ConcentrationEmpty);
            }

            //计算标样的峰信息
            _rc = CCalculationFactory.ComputePeakInfo(std_papl[0].PeakList, std_papl[0].PointList, am.CalculationMethod);
            if (_rc != QualitativeErrorInfo.Success)
            {
                return(_rc);
            }

            List <Peak> _valid_standard_list = std_papl[0].PeakList.FindAll(CPeakFilter.FindCheckedPeak);

            if (_valid_standard_list == null)
            {
                return(QualitativeErrorInfo.StandardSampleError);
            }
            //计算校准曲线
            //List<PeakAndPointList> _unknown_std_papl = std_papl.GetRange(1, std_papl.Count - 1);
            //_rc = QA_CreateCalibrationCoeff(_unknown_std_papl, _valid_standard_list, am);
            _rc = QA_CreateCalibrationCoeff(std_papl, _valid_standard_list, am);

            //计算未知样的峰信息
            ResetPeakList(unknown_papl.PeakList);
            _rc = CCalculationFactory.ComputePeakInfo(unknown_papl.PeakList, unknown_papl.PointList, am.CalculationMethod);
            if (_rc != QualitativeErrorInfo.Success)
            {
                return(_rc);
            }

            //定性未知峰
            List <Peak> _target_list = CIdentificationFactory.Identify(_valid_standard_list, unknown_papl.PeakList, am.IdentificationMethod);

            if (_target_list == null)
            {
                return(QualitativeErrorInfo.IdentifyPeakError);
            }

            //定量
            _rc = CQuantificationFactory.Quantitate(_target_list, am.QuantificationMethod);
            return(_rc);
        }
Esempio n. 2
0
        /// <summary>单点校正函数,此单点校正有不止一个标样,按多个标样的平均值计算。</summary>
        /// <param name="std_papl">标样列表</param>
        /// <param name="unknown_papl">未知样品</param>
        /// <param name="am">分析参数</param>
        /// <returns>QualitativeErrorInfo枚举值</returns>
        public static QualitativeErrorInfo QA_SinglePointFitting(List <PeakAndPointList> std_papl, PeakAndPointList unknown_papl, AnalyzerMethod am)
        {
            QualitativeErrorInfo _rc = QualitativeErrorInfo.Success;

            if (std_papl == null || std_papl.Count <= 0)
            {
                return(QualitativeErrorInfo.PeakListError);
            }

            //计算标样的峰信息
            foreach (PeakAndPointList _papl in std_papl)
            {
                CCalculationFactory.ComputePeakInfo(_papl.PeakList, _papl.PointList, am.CalculationMethod);
            }

            List <Peak> _std_list = std_papl[0].PeakList.FindAll(CPeakFilter.FindCheckedPeak);

            if (_std_list == null)
            {
                return(QualitativeErrorInfo.StandardSampleError);
            }

            _rc = CQuantificationFactory.GetAdjustFactor(_std_list, am.QuantificationMethod);
            if (_rc != QualitativeErrorInfo.Success)
            {
                return(_rc);
            }

            //如果存在多组标样,需要首先定性这些标样
            if (std_papl.Count > 1)
            {
                List <Peak> _aver_std_list = GetAverStandardPeakList(std_papl, _std_list, am.IdentificationMethod, am.QuantificationMethod);
                if (_aver_std_list != null)
                {
                    _std_list = _aver_std_list;
                }
            }
            //计算未知峰信息
            ResetPeakList(unknown_papl.PeakList);

            CCalculationFactory.ComputePeakInfo(unknown_papl.PeakList, unknown_papl.PointList, am.CalculationMethod);

            //定性未知样
            List <Peak> _target_list = CIdentificationFactory.Identify(_std_list, unknown_papl.PeakList, am.IdentificationMethod);

            if (_target_list == null)
            {
                return(QualitativeErrorInfo.IdentifyPeakError);
            }

            //定量未知样
            _rc = CQuantificationFactory.Quantitate(_target_list, am.QuantificationMethod);
            return(_rc);
        }
Esempio n. 3
0
        public static QualitativeErrorInfo QA_CreateCalibrationCoeff(List <PeakAndPointList> standard_papl, List <Peak> peak_param, AnalyzerMethod am)
        {
            if ((standard_papl == null) || (standard_papl.Count == 0) || (peak_param == null) || (peak_param.Count == 0))
            {
                return(QualitativeErrorInfo.PeakListError);
            }

            QualitativeErrorInfo _rc = QualitativeErrorInfo.Success;

            //计算标样的峰信息
            foreach (PeakAndPointList _papl in standard_papl)
            {
                _rc = CCalculationFactory.ComputePeakInfo(_papl.PeakList, _papl.PointList, am.CalculationMethod);
                if (_rc != QualitativeErrorInfo.Success)
                {
                    continue;
                }

                CIdentificationFactory.Identify(peak_param, _papl.PeakList, am.IdentificationMethod);
            }

            foreach (Peak _p in peak_param)
            {
                List <Peak> _peak_list = CQuantificationFactory.GetStandardPeakList(standard_papl, _p.Name, am.QuantificationMethod);
                if (_peak_list == null)
                {
                    continue;
                }

                _p.Coefficient = CQuantificationFactory.GetCoefficient(_peak_list, am.QuantificationMethod);
                if (_p.Coefficient == null)
                {
                    continue;
                }

                string _fitting_formula = CQuantificationFactory.GetFittingFormula(_p.Coefficient, am.QuantificationMethod);

                foreach (Peak _p0 in _peak_list)
                {
                    if ((_p0.InternalStandard == null) || _p0.InternalStandard.Trim() == "")
                    {
                        _p0.Coefficient    = _p.Coefficient.GetRange(0, _p.Coefficient.Count);
                        _p0.FittingFormula = _fitting_formula;
                    }
                }
            }
            return(_rc);
        }
Esempio n. 4
0
        /// <summary>归一化法</summary>
        /// <param name="std_papl">标准样品</param>
        /// <param name="unknown_papl">未知样品</param>
        /// <param name="pcm">计算方法参数</param>
        /// <param name="pqm">定量方法参数</param>
        /// <returns>QualitativeErrorInfo枚举值</returns>
        public static QualitativeErrorInfo QA_CorrectedNormalization(PeakAndPointList std_papl, PeakAndPointList unknown_papl, AnalyzerMethod am)
        {
            QualitativeErrorInfo _rc = QualitativeErrorInfo.Success;

            //计算标样峰信息
            _rc = CCalculationFactory.ComputePeakInfo(std_papl.PeakList, std_papl.PointList, am.CalculationMethod);
            if (_rc != QualitativeErrorInfo.Success)
            {
                return(_rc);
            }

            //计算标样校正因子
            _rc = CQuantificationFactory.GetAdjustFactor(std_papl.PeakList, am.QuantificationMethod);
            if (_rc != QualitativeErrorInfo.Success)
            {
                return(_rc);
            }

            ResetPeakList(unknown_papl.PeakList);

            //计算未知样峰信息
            _rc = CCalculationFactory.ComputePeakInfo(unknown_papl.PeakList, unknown_papl.PointList, am.CalculationMethod);
            if (_rc != QualitativeErrorInfo.Success)
            {
                return(_rc);
            }

            //定性未知样
            List <Peak> _target_list = CIdentificationFactory.Identify(std_papl.PeakList, unknown_papl.PeakList, am.IdentificationMethod);

            if (_target_list == null)
            {
                return(QualitativeErrorInfo.IdentifyPeakError);
            }

            //未知样定量
            _rc = CQuantificationFactory.Quantitate(_target_list, am.QuantificationMethod);

            return(_rc);
        }
Esempio n. 5
0
        private static List <Peak> GetAverStandardPeakList(List <PeakAndPointList> unknown_std_papl, List <Peak> standard_list, PeakIdentificationMethod pim, PeakQuantificationMethod pqm)
        {
            QualitativeErrorInfo _rc = QualitativeErrorInfo.Success;

            if ((unknown_std_papl == null) || (unknown_std_papl.Count == 0) || (standard_list == null) || (standard_list.Count == 0))
            {
                return(null);
            }

            int[]    _std_count = new int[standard_list.Count];
            double[] _std_rt    = new double[standard_list.Count];

            List <Peak> _aver_std_list = new List <Peak>();

            for (int i = 0; i < standard_list.Count; i++)
            {
                _std_count[i] = 0;
                _std_rt[i]    = 0;

                Peak _p = new Peak();

                _p.Name    = standard_list[i].Name;
                _p.Checked = true;
                _p.Index   = i;

                _aver_std_list.Add(_p);
            }

            foreach (PeakAndPointList _papl in unknown_std_papl)
            {
                List <Peak> _unknown_std_list = _papl.PeakList.FindAll(CPeakFilter.FindNaturalPeak);
                if (_unknown_std_list == null)
                {
                    continue;
                }

                //定性标样峰
                List <Peak> _target_list = CIdentificationFactory.Identify(standard_list, _unknown_std_list, pim);
                if (_target_list == null)
                {
                    continue;
                }

                _rc = CQuantificationFactory.GetAdjustFactor(_target_list, pqm);    //计算校正因子
                if (_rc != QualitativeErrorInfo.Success)
                {
                    continue;
                }

                foreach (Peak _p in _aver_std_list)
                {
                    foreach (Peak _p0 in _target_list)
                    {
                        if (_p.Name == _p0.Name)
                        {
                            _p.Capacity     += _p0.Capacity;
                            _p.PeakHeight   += _p0.PeakHeight;
                            _p.PeakArea     += _p0.PeakArea;
                            _p.AdjustFactor += _p0.AdjustFactor;

                            _std_count[_p.Index]++;
                            _std_rt[_p.Index] += _p0.PeakPoint.X;

                            _target_list.Remove(_p0);
                            break;
                        }
                    }
                }
            }

            foreach (Peak _p in _aver_std_list)
            {
                int _count = _std_count[_p.Index];

                _std_rt[_p.Index] /= _count;

                _p.Capacity     /= _count;
                _p.PeakHeight   /= _count;
                _p.PeakArea     /= _count;
                _p.AdjustFactor /= _count;

                _p.PeakPoint = new PointF((float)_std_rt[_p.Index], 0);
            }

            return((_aver_std_list.Count > 0) ? _aver_std_list : null);
        }